cleanup: use ReactiveState to provide $state with sveltekit (#492)

This commit is contained in:
Xylight authored and GitHub committed 2025-02-17 13:37:37 -08:00
1 parent 589db4dcc7
commit 7c46e616f8
18 files changed
+168 -168

No files matched your search

+7 -10
View File
@@ -26,11 +26,6 @@
let { data } = $props()
let inbox = $state(data.data)
$effect(() => {
inbox = data.data
})
let markingAsRead = $state(false)
async function markAllAsRead() {
@@ -167,7 +162,7 @@ items-center px-2 w-max top-6 lg:top-22"
<div
class="flex flex-col list-none flex-1 h-full divide-y divide-slate-200 dark:divide-zinc-900 *:py-4"
>
{#if !inbox || (inbox?.length ?? 0) == 0}
{#if !data.inbox?.value || (data.inbox.value?.length ?? 0) == 0}
<Placeholder
icon={Inbox}
title={$t('routes.inbox.empty.title')}
@@ -175,7 +170,7 @@ items-center px-2 w-max top-6 lg:top-22"
class="self-center justify-self-center my-auto"
/>
{:else}
{#each inbox as item, index (item.id)}
{#each data.inbox.value as item, index (item.id)}
<div
class="-mx-4 sm:-mx-6 px-4 sm:px-6
{item.read ? '' : 'bg-yellow-50/50 dark:bg-blue-500/5'}"
@@ -187,17 +182,19 @@ items-center px-2 w-max top-6 lg:top-22"
delay: index * 50,
}}
>
<InboxItem bind:item={inbox[index]} />
<InboxItem bind:item={data.inbox.value[index]} />
</div>
{/each}
{/if}
{#if !(data.page == 1 && (data?.data?.length ?? 0) == 0)}
{#if !(data.page == 1 && (data?.inbox?.value.length ?? 0) == 0)}
<div
class="sticky z-30 mx-auto max-w-full self-end mt-auto bottom-22 lg:bottom-6"
>
<Tabs routes={[]} class="mx-auto">
<Pageination
hasMore={!(!inbox || (inbox?.length ?? 0) < (data?.limit ?? 0))}
hasMore={!(
!data.inbox || (data.inbox.value?.length ?? 0) < (data?.limit ?? 0)
)}
page={data.page}
href={(page) => `?page=${page}`}
/>
+2 -1
View File
@@ -6,6 +6,7 @@ import {
generalizePersonMention,
generalizePrivateMessage,
} from '$lib/lemmy/inbox.js'
import { ReactiveState } from '$lib/promise.svelte.js'
import { get } from 'svelte/store'
type InboxFeedType = 'replies' | 'mentions' | 'messages' | 'all'
@@ -61,7 +62,7 @@ export async function load({ url, fetch }) {
unreadOnly: unreadOnly,
type: type,
page: page,
data: data,
inbox: new ReactiveState(data),
limit: 20,
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
import { client } from '$lib/lemmy.svelte.js'
import { awaitIfServer } from '$lib/promise.js'
import { awaitIfServer } from '$lib/promise.svelte.js'
export async function load({ fetch, url }) {
const page = Number(url.searchParams.get('page')) || 1
@@ -1,5 +1,5 @@
import { client } from '$lib/lemmy.svelte.js'
import { awaitIfServer } from '$lib/promise.js'
import { awaitIfServer } from '$lib/promise.svelte.js'
export async function load({ fetch, params }) {
const creator = Number(params.user_id)