fix: modal not closing in many model chat

This commit is contained in:
Timothy J. Baek 2024-08-07 14:47:43 +02:00
parent 0c231fd387
commit 7e473f194d

View File

@ -118,47 +118,47 @@
currentMessageId = message.id; currentMessageId = message.id;
let messageId = message.id; let messageId = message.id;
console.log(messageId); console.log(messageId);
// //
let messageChildrenIds = history.messages[messageId].childrenIds; let messageChildrenIds = history.messages[messageId].childrenIds;
while (messageChildrenIds.length !== 0) { while (messageChildrenIds.length !== 0) {
messageId = messageChildrenIds.at(-1); messageId = messageChildrenIds.at(-1);
messageChildrenIds = history.messages[messageId].childrenIds; messageChildrenIds = history.messages[messageId].childrenIds;
} }
history.currentId = messageId; history.currentId = messageId;
dispatch('change'); dispatch('change');
} }
}} }}
> >
<ResponseMessage {#key history.currentId}
message={groupedMessages[model].messages[groupedMessagesIdx[model]]} <ResponseMessage
siblings={groupedMessages[model].messages.map((m) => m.id)} message={groupedMessages[model].messages[groupedMessagesIdx[model]]}
isLastMessage={true} siblings={groupedMessages[model].messages.map((m) => m.id)}
{updateChatMessages} isLastMessage={true}
{confirmEditResponseMessage} {updateChatMessages}
showPreviousMessage={() => showPreviousMessage(model)} {confirmEditResponseMessage}
showNextMessage={() => showNextMessage(model)} showPreviousMessage={() => showPreviousMessage(model)}
{readOnly} showNextMessage={() => showNextMessage(model)}
{rateMessage} {readOnly}
{copyToClipboard} {rateMessage}
{continueGeneration} {copyToClipboard}
regenerateResponse={async (message) => { {continueGeneration}
regenerateResponse(message); regenerateResponse={async (message) => {
await tick(); regenerateResponse(message);
groupedMessagesIdx[model] = groupedMessages[model].messages.length - 1; await tick();
}} groupedMessagesIdx[model] = groupedMessages[model].messages.length - 1;
on:save={async (e) => { }}
console.log('save', e); on:save={async (e) => {
console.log('save', e);
const message = e.detail; const message = e.detail;
history.messages[message.id] = message; history.messages[message.id] = message;
await updateChatById(localStorage.token, chatId, { await updateChatById(localStorage.token, chatId, {
messages: messages, messages: messages,
history: history history: history
}); });
}} }}
/> />
{/key}
</div> </div>
{/if} {/if}
{/each} {/each}