fix: save comment expand state

This commit is contained in:
James Xylight committed 2025-02-03 20:28:44 -08:00
1 parent 25b1fcf42a
commit e46422c27b
2 files changed
+7 -6

No files matched your search

@@ -52,7 +52,6 @@
op = false, op = false,
actions = true, actions = true,
meta = true, meta = true,
open = $bindable(true),
replying = $bindable(false), replying = $bindable(false),
contentClass = '', contentClass = '',
class: clazz = '', class: clazz = '',
@@ -137,7 +136,7 @@
> >
{#if meta} {#if meta}
<button <button
onclick={() => (open = !open)} onclick={() => (node.expanded = !node.expanded)}
class="flex flex-row cursor-pointer gap-2 items-center group text-[13px] flex-wrap w-full class="flex flex-row cursor-pointer gap-2 items-center group text-[13px] flex-wrap w-full
z-0 group relative" z-0 group relative"
> >
@@ -155,10 +154,10 @@
></FormattedNumber> ></FormattedNumber>
{/if} {/if}
<Icon <Icon
src={open ? Minus : Plus} src={node.expanded ? Minus : Plus}
size="16" size="16"
micro micro
class="transition-transform duration-[400ms] ease-out {open class="transition-transform duration-[400ms] ease-out {node.expanded
? '' ? ''
: 'rotate-90'} text-primary-900 dark:text-primary-100" : 'rotate-90'} text-primary-900 dark:text-primary-100"
/> />
@@ -213,7 +212,7 @@
</span> </span>
</button> </button>
{/if} {/if}
{#if open} {#if node.expanded}
<div <div
class="relative {contentClass}" class="relative {contentClass}"
transition:slide={{ duration: 400, easing: expoOut }} transition:slide={{ duration: 400, easing: expoOut }}
@@ -5,6 +5,7 @@ export interface CommentNodeI {
children: Array<CommentNodeI> children: Array<CommentNodeI>
depth: number depth: number
loading?: boolean loading?: boolean
expanded?: boolean
} }
function getCommentParentId(comment?: Comment): number | undefined { function getCommentParentId(comment?: Comment): number | undefined {
@@ -36,7 +37,8 @@ export function buildCommentsTree(
const node: CommentNodeI = { const node: CommentNodeI = {
comment_view, comment_view,
children: [], children: [],
depth: depth depth: depth,
expanded: true
} }
min_depth = Math.min(min_depth, depth) min_depth = Math.min(min_depth, depth)
if (filter(comment_view)) { if (filter(comment_view)) {