misc: change $site to a $state

This commit is contained in:
James Xylight committed 2025-02-09 11:17:01 -08:00
1 parent a94dd5f3d4
commit 8dcca84e60
85 files changed
+153 -140

No files matched your search

+6 -8
View File
@@ -1,18 +1,16 @@
import { profile } from '$lib/auth.svelte'
import { get } from 'svelte/store'
import { getClient } from '$lib/lemmy.js'
import { site as siteStore } from '$lib/lemmy'
import { getClient } from '$lib/lemmy.svelte.js'
import { site as siteStore } from '$lib/lemmy.svelte.js'
export async function load({ fetch }) {
let site = get(siteStore)
let site = siteStore
if (!site) {
if (!site.data) {
const res = await getClient(undefined, fetch).getSite()
site = res
site.data = res
}
return {
site: site,
site: site.data,
}
}
+1 -1
View File
@@ -1,5 +1,5 @@
import { profile } from '$lib/auth.svelte'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import { get } from 'svelte/store'
export async function load({ data, fetch, url }) {
@@ -3,7 +3,7 @@
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import SectionTitle from '$lib/components/ui/SectionTitle.svelte'
import { Material, toast } from 'mono-svelte'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import type {
ApproveRegistrationApplication,
RegistrationApplicationView,
+4 -4
View File
@@ -10,7 +10,7 @@
Switch,
toast,
} from 'mono-svelte'
import { getClient, site } from '$lib/lemmy.js'
import { getClient, site } from '$lib/lemmy.svelte.js'
import type { EditSite } from 'lemmy-js-client'
import type { PageData } from './$types.js'
import { Button, Checkbox, Select, TextInput } from 'mono-svelte'
@@ -246,7 +246,7 @@
<SectionTitle>{$t('form.profile.languages.title')}</SectionTitle>
<p>{$t('form.profile.languages.description')}</p>
<Material rounding="xl" color="uniform" class="dark:bg-zinc-950">
{#if $site}
{#if site.data}
<div class="flex gap-2 flex-wrap flex-row">
<Menu class="gap-px">
{#snippet target()}
@@ -257,7 +257,7 @@
</Badge>
</button>
{/snippet}
{#each $site.all_languages.filter((l) => !formData.discussion_languages?.includes(l.id)) as language, index}
{#each site.data.all_languages.filter((l) => !formData.discussion_languages?.includes(l.id)) as language, index}
<MenuButton
class="min-h-[16px] py-0"
onclick={() => {
@@ -269,7 +269,7 @@
{/each}
</Menu>
{#each formData.discussion_languages ?? [] as languageId, index}
{@const language = $site.all_languages.find(
{@const language = site.data.all_languages.find(
(l) => l.id == languageId,
)}
<button
+1 -1
View File
@@ -6,7 +6,7 @@
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import RelativeDate from '$lib/components/util/RelativeDate.svelte'
import { publishedToDate } from '$lib/components/util/date.js'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import { t } from '$lib/translations.js'
import { trycatch } from '$lib/util.svelte.js'
import type { Instance } from 'lemmy-js-client'
+1 -1
View File
@@ -1,5 +1,5 @@
import { profile } from '$lib/auth.svelte'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import { get } from 'svelte/store'
export async function load({ fetch, parent }) {
+1 -1
View File
@@ -6,7 +6,7 @@
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { toast } from 'mono-svelte'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import type { Tagline } from 'lemmy-js-client'
import { Button } from 'mono-svelte'
import { Icon, Plus, QuestionMarkCircle, Trash } from 'svelte-hero-icons'
+1 -1
View File
@@ -6,7 +6,7 @@
import Placeholder from '$lib/components/ui/Placeholder.svelte'
import { toast } from 'mono-svelte'
import { instance } from '$lib/instance.js'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import { addAdmin } from '$lib/lemmy/user.js'
import { removeItem, trycatch } from '$lib/util.svelte.js'
import { Button, TextInput } from 'mono-svelte'