migrate: fix reactivity issues in data lists

This commit is contained in:
James Xylight committed 2025-02-02 17:41:46 -08:00
1 parent 104a99f394
commit 87fba8af04
4 files changed
+22 -13

No files matched your search

+11 -6
View File
@@ -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 @@
<ul
class="flex flex-col divide-y divide-slate-100 dark:divide-zinc-800 my-6 h-full"
>
{#if data.communities.length == 0}
{#if communities.length == 0}
<Placeholder
icon={QuestionMarkCircle}
title={$t('routes.search.noResults.title')}
@@ -114,7 +119,7 @@
<div
class="grid md:grid-cols-2 lg:grid-cols-3 gap-4 items-center mb-6 !border-0"
>
{#each data.communities.slice(0, 3) as community, index (community.community.id)}
{#each communities.slice(0, 3) as community, index (community.community.id)}
<div
class="h-full"
in:fly|global={{
@@ -142,13 +147,13 @@
</div>
{/if}
{#if data.communities.slice(showTop ? 3 : 0).length > 0}
{#if communities.slice(showTop ? 3 : 0).length > 0}
<SectionTitle class="!border-0 pb-2">
{$t('routes.search.other')}
</SectionTitle>
{/if}
{#if data.communities}
{@const sliced = data.communities.slice(showTop ? 3 : 0)}
{#if communities}
{@const sliced = communities.slice(showTop ? 3 : 0)}
<div class="-mx-4 sm:-mx-6 h-full">
{#each sliced as community, index (community.community.id)}
<div
@@ -167,7 +172,7 @@
</div>
{/if}
</ul>
{#if data.communities.length > 0}
{#if communities.length > 0}
<div
class="sticky z-30 mx-auto max-w-full"
style="bottom: max(1.5rem, {$contentPadding.bottom}px);"
+4 -1
View File
@@ -28,6 +28,9 @@
let { data } = $props()
let inbox = $state(data.data)
$effect(() => {
inbox = data.data
})
let markingAsRead = $state(false)
@@ -196,7 +199,7 @@ items-center px-2 w-max"
>
<Tabs routes={[]} class="mx-auto">
<Pageination
hasMore={!(!data.data || (inbox?.length ?? 0) < data.limit)}
hasMore={!(!inbox || (inbox?.length ?? 0) < (data?.limit ?? 0))}
page={data.page}
on:change={(p) => searchParam($page.url, 'page', p.detail.toString())}
/>
+6 -1
View File
@@ -20,6 +20,9 @@
let { data = $bindable() } = $props()
let reports = $state(data.items)
$effect(() => {
reports = data.items
})
</script>
<div class="mb-4 flex flex-col gap-4">
@@ -49,7 +52,9 @@
</Header>
</div>
{#if reports && reports.length > 0}
<div class="flex flex-col gap-4">
<div
class="flex flex-col *:py-4 divide-y divide-slate-200 dark:divide-zinc-800"
>
{#each reports as item}
<div
in:fly={{ y: -6, opacity: 0, duration: 500 }}