fix: edit message issue

This commit is contained in:
Timothy J. Baek 2024-01-01 13:01:42 -08:00
parent 111288d689
commit 60658abbbc
3 changed files with 38 additions and 43 deletions

View file

@ -215,42 +215,44 @@
{#if messages.length == 0} {#if messages.length == 0}
<Placeholder models={selectedModels} modelfiles={selectedModelfiles} /> <Placeholder models={selectedModels} modelfiles={selectedModelfiles} />
{:else} {:else}
{#each messages as message, messageIdx} {#key chatId}
<div class=" w-full"> {#each messages as message, messageIdx}
<div class="flex justify-between px-5 mb-3 max-w-3xl mx-auto rounded-lg group"> <div class=" w-full">
{#if message.role === 'user'} <div class="flex justify-between px-5 mb-3 max-w-3xl mx-auto rounded-lg group">
<UserMessage {#if message.role === 'user'}
user={$user} <UserMessage
{message} user={$user}
siblings={message.parentId !== null {message}
? history.messages[message.parentId]?.childrenIds ?? [] siblings={message.parentId !== null
: Object.values(history.messages) ? history.messages[message.parentId]?.childrenIds ?? []
.filter((message) => message.parentId === null) : Object.values(history.messages)
.map((message) => message.id) ?? []} .filter((message) => message.parentId === null)
{confirmEditMessage} .map((message) => message.id) ?? []}
{showPreviousMessage} {confirmEditMessage}
{showNextMessage} {showPreviousMessage}
{copyToClipboard} {showNextMessage}
/> {copyToClipboard}
{:else} />
<ResponseMessage {:else}
{message} <ResponseMessage
modelfiles={selectedModelfiles} {message}
siblings={history.messages[message.parentId]?.childrenIds ?? []} modelfiles={selectedModelfiles}
isLastMessage={messageIdx + 1 === messages.length} siblings={history.messages[message.parentId]?.childrenIds ?? []}
{confirmEditResponseMessage} isLastMessage={messageIdx + 1 === messages.length}
{showPreviousMessage} {confirmEditResponseMessage}
{showNextMessage} {showPreviousMessage}
{rateMessage} {showNextMessage}
{copyToClipboard} {rateMessage}
{regenerateResponse} {copyToClipboard}
/> {regenerateResponse}
{/if} />
{/if}
</div>
</div> </div>
</div> {/each}
{/each}
{#if bottomPadding} {#if bottomPadding}
<div class=" mb-10" /> <div class=" mb-10" />
{/if} {/if}
{/key}
{/if} {/if}

View file

@ -33,8 +33,6 @@
let speaking = null; let speaking = null;
$: if (message) { $: if (message) {
edit = false;
editedContent = '';
renderStyling(); renderStyling();
} }

View file

@ -39,11 +39,6 @@
edit = false; edit = false;
editedContent = ''; editedContent = '';
}; };
$: if (message) {
edit = false;
editedContent = '';
}
</script> </script>
<div class=" flex w-full"> <div class=" flex w-full">