Spaces:
Running
Running
fix: force rerender on message ID change
Browse files
src/lib/components/chat/ChatMessage.svelte
CHANGED
@@ -529,65 +529,68 @@
|
|
529 |
{/if}
|
530 |
|
531 |
{#if nChildren > 0}
|
532 |
-
|
533 |
-
|
534 |
-
|
535 |
-
|
536 |
-
|
537 |
-
|
538 |
-
|
539 |
-
|
540 |
-
|
541 |
-
|
542 |
-
|
543 |
-
|
544 |
-
|
545 |
-
|
546 |
-
|
547 |
-
|
548 |
-
|
549 |
-
class="inline text-lg font-thin text-gray-400 hover:text-gray-800 disabled:pointer-events-none disabled:opacity-25 dark:text-gray-500 dark:hover:text-gray-200"
|
550 |
-
on:click={() => (childrenToRender = Math.max(0, childrenToRender - 1))}
|
551 |
-
disabled={childrenToRender === 0 || loading}
|
552 |
-
>
|
553 |
-
<CarbonChevronLeft class="text-sm" />
|
554 |
-
</button>
|
555 |
-
<span class=" text-gray-400 dark:text-gray-500">
|
556 |
-
{childrenToRender + 1} / {nChildren}
|
557 |
-
</span>
|
558 |
-
<button
|
559 |
-
class="inline text-lg font-thin text-gray-400 hover:text-gray-800 disabled:pointer-events-none disabled:opacity-25 dark:text-gray-500 dark:hover:text-gray-200"
|
560 |
-
on:click={() =>
|
561 |
-
(childrenToRender = Math.min(
|
562 |
-
message?.children?.length ?? 1 - 1,
|
563 |
-
childrenToRender + 1
|
564 |
-
))}
|
565 |
-
disabled={childrenToRender === nChildren - 1 || loading}
|
566 |
>
|
567 |
-
<
|
568 |
-
|
569 |
-
|
570 |
-
|
571 |
-
action="?/deleteBranch"
|
572 |
-
class="hidden group-hover/navbranch:block"
|
573 |
-
use:enhance={({ cancel }) => {
|
574 |
-
if (!confirm("Are you sure you want to delete this branch?")) {
|
575 |
-
cancel();
|
576 |
-
}
|
577 |
-
}}
|
578 |
>
|
579 |
-
<
|
580 |
-
|
581 |
-
|
582 |
-
|
583 |
-
|
584 |
-
|
585 |
-
|
586 |
-
|
587 |
-
|
588 |
-
|
589 |
-
|
590 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
591 |
{/if}
|
592 |
|
593 |
<style>
|
|
|
529 |
{/if}
|
530 |
|
531 |
{#if nChildren > 0}
|
532 |
+
{@const messageId = messages.find((m) => m.id === id)?.children?.[childrenToRender]}
|
533 |
+
{#key messageId}
|
534 |
+
<svelte:self
|
535 |
+
{loading}
|
536 |
+
{messages}
|
537 |
+
{isAuthor}
|
538 |
+
{readOnly}
|
539 |
+
{model}
|
540 |
+
id={messageId}
|
541 |
+
on:retry
|
542 |
+
on:vote
|
543 |
+
on:continue
|
544 |
+
>
|
545 |
+
<svelte:fragment slot="childrenNav">
|
546 |
+
{#if nChildren > 1 && $convTreeStore.editing === null}
|
547 |
+
<div
|
548 |
+
class="font-white group/navbranch z-10 -mt-1 ml-3.5 mr-auto flex h-6 w-fit select-none flex-row items-center justify-center gap-1 text-sm"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
549 |
>
|
550 |
+
<button
|
551 |
+
class="inline text-lg font-thin text-gray-400 hover:text-gray-800 disabled:pointer-events-none disabled:opacity-25 dark:text-gray-500 dark:hover:text-gray-200"
|
552 |
+
on:click={() => (childrenToRender = Math.max(0, childrenToRender - 1))}
|
553 |
+
disabled={childrenToRender === 0 || loading}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
554 |
>
|
555 |
+
<CarbonChevronLeft class="text-sm" />
|
556 |
+
</button>
|
557 |
+
<span class=" text-gray-400 dark:text-gray-500">
|
558 |
+
{childrenToRender + 1} / {nChildren}
|
559 |
+
</span>
|
560 |
+
<button
|
561 |
+
class="inline text-lg font-thin text-gray-400 hover:text-gray-800 disabled:pointer-events-none disabled:opacity-25 dark:text-gray-500 dark:hover:text-gray-200"
|
562 |
+
on:click={() =>
|
563 |
+
(childrenToRender = Math.min(
|
564 |
+
message?.children?.length ?? 1 - 1,
|
565 |
+
childrenToRender + 1
|
566 |
+
))}
|
567 |
+
disabled={childrenToRender === nChildren - 1 || loading}
|
568 |
+
>
|
569 |
+
<CarbonChevronRight class="text-sm" />
|
570 |
+
</button>
|
571 |
+
{#if !loading && message.children}<form
|
572 |
+
method="POST"
|
573 |
+
action="?/deleteBranch"
|
574 |
+
class="hidden group-hover/navbranch:block"
|
575 |
+
use:enhance={({ cancel }) => {
|
576 |
+
if (!confirm("Are you sure you want to delete this branch?")) {
|
577 |
+
cancel();
|
578 |
+
}
|
579 |
+
}}
|
580 |
+
>
|
581 |
+
<input name="messageId" value={message.children[childrenToRender]} type="hidden" />
|
582 |
+
<button
|
583 |
+
class="flex items-center justify-center text-xs text-gray-400 hover:text-gray-800 dark:text-gray-500 dark:hover:text-gray-200"
|
584 |
+
type="submit"
|
585 |
+
><CarbonTrashCan />
|
586 |
+
</button>
|
587 |
+
</form>
|
588 |
+
{/if}
|
589 |
+
</div>
|
590 |
+
{/if}
|
591 |
+
</svelte:fragment>
|
592 |
+
</svelte:self>
|
593 |
+
{/key}
|
594 |
{/if}
|
595 |
|
596 |
<style>
|