From 87fba8af0418357a12cffbea1c1989c547c93c6b Mon Sep 17 00:00:00 2001 From: James Xylight Date: Sun, 2 Feb 2025 17:41:46 -0800 Subject: [PATCH] migrate: fix reactivity issues in data lists --- .../lemmy/post/link/PostLinkSources.svelte | 6 +----- src/routes/communities/+page.svelte | 17 +++++++++++------ src/routes/inbox/+page.svelte | 5 ++++- src/routes/moderation/+page.svelte | 7 ++++++- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/src/lib/components/lemmy/post/link/PostLinkSources.svelte b/src/lib/components/lemmy/post/link/PostLinkSources.svelte index b9dfc050..2ed98dde 100644 --- a/src/lib/components/lemmy/post/link/PostLinkSources.svelte +++ b/src/lib/components/lemmy/post/link/PostLinkSources.svelte @@ -53,11 +53,7 @@ let { url, type = 'embed', target, ...rest }: Props = $props() - - {#snippet target()} - {@render target?.()} - {/snippet} - + {$t('post.actions.link.title')} {#each sources as source} {#if source.type == type} diff --git a/src/routes/communities/+page.svelte b/src/routes/communities/+page.svelte index 60ac2b58..a566c39f 100644 --- a/src/routes/communities/+page.svelte +++ b/src/routes/communities/+page.svelte @@ -34,6 +34,11 @@ let { data } = $props() + let communities = $state(data.communities) + $effect(() => { + communities = data.communities + }) + let search = $state(data.query || '') let searchElement: HTMLInputElement | undefined = $state() let instance = '' @@ -99,7 +104,7 @@
    - {#if data.communities.length == 0} + {#if communities.length == 0} - {#each data.communities.slice(0, 3) as community, index (community.community.id)} + {#each communities.slice(0, 3) as community, index (community.community.id)}
    {/if} - {#if data.communities.slice(showTop ? 3 : 0).length > 0} + {#if communities.slice(showTop ? 3 : 0).length > 0} {$t('routes.search.other')} {/if} - {#if data.communities} - {@const sliced = data.communities.slice(showTop ? 3 : 0)} + {#if communities} + {@const sliced = communities.slice(showTop ? 3 : 0)}
    {#each sliced as community, index (community.community.id)}
    {/if}
-{#if data.communities.length > 0} +{#if communities.length > 0}
{ + inbox = data.data + }) let markingAsRead = $state(false) @@ -196,7 +199,7 @@ items-center px-2 w-max" > searchParam($page.url, 'page', p.detail.toString())} /> diff --git a/src/routes/moderation/+page.svelte b/src/routes/moderation/+page.svelte index 73afa009..de6215d2 100644 --- a/src/routes/moderation/+page.svelte +++ b/src/routes/moderation/+page.svelte @@ -20,6 +20,9 @@ let { data = $bindable() } = $props() let reports = $state(data.items) + $effect(() => { + reports = data.items + })
@@ -49,7 +52,9 @@
{#if reports && reports.length > 0} -
+
{#each reports as item}