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

@@ -1,6 +1,6 @@
<script lang="ts">
import Avatar from '$lib/components/ui/Avatar.svelte'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import type { Community, CommunityView, ListingType } from 'lemmy-js-client'
import { MenuButton, Search } from 'mono-svelte'
import type { SearchProps } from 'mono-svelte/search/Search.svelte'
@@ -14,7 +14,7 @@
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import CommentActions from '$lib/components/lemmy/comment/CommentActions.svelte'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import { Disclosure, toast } from 'mono-svelte'
import { profile } from '$lib/auth.svelte.js'
import { Button, Modal } from 'mono-svelte'
@@ -1,6 +1,6 @@
<script lang="ts">
import type { CommentResponse } from 'lemmy-js-client'
import { getClient, site } from '$lib/lemmy.js'
import { getClient, site } from '$lib/lemmy.svelte.js'
import { createEventDispatcher } from 'svelte'
import Markdown from '$lib/components/markdown/Markdown.svelte'
import { profile } from '$lib/auth.svelte.js'
@@ -113,7 +113,7 @@
</Button>
{/snippet}
{#if $site}
{#if site.data}
<MenuButton
class="min-h-[16px] py-0"
onclick={() => (language = undefined)}
@@ -121,7 +121,7 @@
<Icon src={XMark} size="16" micro />
{$t('form.post.unset')}
</MenuButton>
{#each $site?.all_languages as languageOption}
{#each site.data?.all_languages as languageOption}
<MenuButton
class="min-h-[16px] py-0"
onclick={() => {
@@ -7,7 +7,7 @@
ChevronUp,
Icon,
} from 'svelte-hero-icons'
import { getClient, site } from '$lib/lemmy'
import { getClient, site } from '$lib/lemmy.svelte'
import { settings } from '$lib/settings.svelte'
import { profile } from '$lib/auth.svelte.js'
import FormattedNumber from '$lib/components/util/FormattedNumber.svelte'
@@ -5,7 +5,7 @@
import { page } from '$app/state'
import { onMount, setContext } from 'svelte'
import { Icon, ArrowDownCircle } from 'svelte-hero-icons'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import type { CommentView, Post } from 'lemmy-js-client'
import { fly } from 'svelte/transition'
import { toast } from 'mono-svelte'
@@ -83,7 +83,7 @@
modal,
action,
} from 'mono-svelte'
import { client, getClient } from '$lib/lemmy.js'
import { client, getClient } from '$lib/lemmy.svelte.js'
import { addSubscription } from '$lib/lemmy/user.js'
import { fullCommunityName } from '$lib/util.svelte.js'
import type { CommunityModeratorView, CommunityView } from 'lemmy-js-client'
@@ -5,7 +5,7 @@
import { profile } from '$lib/auth.svelte.js'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { Badge, ImageInput, MenuButton, Switch, toast } from 'mono-svelte'
import { client, getClient, site } from '$lib/lemmy.js'
import { client, getClient, site } from '$lib/lemmy.svelte.js'
import { addSubscription } from '$lib/lemmy/user.js'
import { Button, Checkbox, TextInput } from 'mono-svelte'
import { uploadImage } from '$lib/util.svelte.js'
@@ -238,7 +238,7 @@
<div class="space-y-1">
<SectionTitle>{$t('form.profile.languages.title')}</SectionTitle>
<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()}
@@ -249,7 +249,7 @@
</Badge>
</button>
{/snippet}
{#each $site.all_languages.filter((l) => !formData.languages?.includes(l.id)) as language, index}
{#each site.data.all_languages.filter((l) => !formData.languages?.includes(l.id)) as language, index}
<MenuButton
class="min-h-[16px] py-0"
onclick={() => {
@@ -264,7 +264,7 @@
{/each}
</Menu>
{#each formData.languages ?? [] as languageId, index}
{@const language = $site.all_languages.find(
{@const language = site.data.all_languages.find(
(l) => l.id == languageId,
)}
<button
@@ -4,7 +4,7 @@
import { profile } from '$lib/auth.svelte.js'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
import MarkdownEditor from '$lib/components/markdown/MarkdownEditor.svelte'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import { t } from '$lib/translations'
import type { Person } from 'lemmy-js-client'
import { Button, Modal, toast } from 'mono-svelte'
@@ -3,7 +3,7 @@
import Avatar from '$lib/components/ui/Avatar.svelte'
import type { Community, Person, PersonView } from 'lemmy-js-client'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import { toast } from 'mono-svelte'
import { profile } from '$lib/auth.svelte.js'
import { Button, Checkbox, Modal, TextInput } from 'mono-svelte'
@@ -1,5 +1,5 @@
<script lang="ts">
import { getClient } from '$lib/lemmy'
import { getClient } from '$lib/lemmy.svelte'
import type { CommentView, PostView } from 'lemmy-js-client'
import { amMod, ban, isAdmin, remove } from './moderation'
import {
@@ -4,7 +4,7 @@
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import Post from '$lib/components/lemmy/post/Post.svelte'
import { Select, Switch, toast } from 'mono-svelte'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import { isCommentView, isPostView } from '$lib/lemmy/item.js'
import type { CommentView, PostView } from 'lemmy-js-client'
import { profile } from '$lib/auth.svelte.js'
@@ -4,7 +4,7 @@
import Comment from '$lib/components/lemmy/comment/Comment.svelte'
import Post from '$lib/components/lemmy/post/Post.svelte'
import { toast } from 'mono-svelte'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import type {
CommentView,
PostView,
@@ -1,4 +1,4 @@
import { client } from '$lib/lemmy'
import { client } from '$lib/lemmy.svelte'
import type { SubmissionView } from '$lib/lemmy/contentview.js'
import type {
Comment,
@@ -1,7 +1,7 @@
<script lang="ts">
import type { PostView } from 'lemmy-js-client'
import PostVote from './PostVote.svelte'
import { site } from '$lib/lemmy.js'
import { site } from '$lib/lemmy.svelte.js'
import {
ArrowsUpDown,
ArrowTopRightOnSquare,
@@ -419,7 +419,7 @@
</MenuButton>
{/if}
{#if profile.data.user?.local_user_view.person.id != post.creator.id}
{#if feature('hidePosts', $site?.version)}
{#if feature('hidePosts', site.data?.version)}
<MenuButton
onclick={async () => {
if (!profile.data?.jwt) return
@@ -23,7 +23,7 @@
import { profile } from '$lib/auth.svelte.js'
import { vote as voteItem } from '$lib/lemmy/contentview.js'
import { Button, Popover, buttonColor, toast } from 'mono-svelte'
import { site } from '$lib/lemmy.js'
import { site } from '$lib/lemmy.svelte.js'
import { fade, fly } from 'svelte/transition'
import { backOut } from 'svelte/easing'
import { t } from '$lib/translations'
@@ -106,7 +106,7 @@
</span>
{/if}
</button>
{#if $site?.site_view.local_site.enable_downvotes ?? true}
{#if site.data?.site_view.local_site.enable_downvotes ?? true}
<button
onclick={() => castVote(vote == -1 ? 0 : -1)}
class="flex items-center flex-row-reverse gap-0.5 transition-colors
@@ -30,7 +30,7 @@
} from '@tanstack/svelte-virtual'
import { afterNavigate, beforeNavigate } from '$app/navigation'
import { combineCrossposts } from './crosspost.svelte'
import { client } from '$lib/lemmy'
import { client } from '$lib/lemmy.svelte'
import {
postFeeds,
type PostFeed,
@@ -2,7 +2,7 @@
import { run, preventDefault } from 'svelte/legacy'
import { createEventDispatcher, onDestroy, onMount } from 'svelte'
import { client, site } from '$lib/lemmy.js'
import { client, site } from '$lib/lemmy.svelte.js'
import type { Community, Post, PostView } from 'lemmy-js-client'
import { Select, Spinner, Switch, toast } from 'mono-svelte'
import {
@@ -433,7 +433,7 @@
{/if}
<Switch bind:checked={data.nsfw}>{$t('form.post.nsfw')}</Switch>
{#if data.language_id !== undefined}
{#if $site}
{#if site.data}
<Select
class="w-max"
label={$t('settings.app.lang.title')}
@@ -443,7 +443,7 @@
<Icon src={XMark} size="16" micro />
{$t('form.post.unset')}
</Option>
{#each $site?.all_languages as language}
{#each site.data?.all_languages as language}
<Option value={language.id.toString()}>{language.name}</Option>
{/each}
</Select>
+1 -1
View File
@@ -1,5 +1,5 @@
import { profile } from '$lib/auth.svelte'
import { client } from '$lib/lemmy.js'
import { client } from '$lib/lemmy.svelte.js'
import type { View } from '$lib/settings.svelte'
import { isImage, isVideo } from '$lib/ui/image'
import { canParseUrl, findClosestNumber } from '$lib/util.svelte'
@@ -1,6 +1,6 @@
<script lang="ts">
import Avatar from '$lib/components/ui/Avatar.svelte'
import { getClient } from '$lib/lemmy.js'
import { getClient } from '$lib/lemmy.svelte.js'
import type { Community, ListingType, Person } from 'lemmy-js-client'
import { MenuButton, Search } from 'mono-svelte'
import { createEventDispatcher } from 'svelte'
+5 -5
View File
@@ -6,7 +6,7 @@
isAdmin,
} from '$lib/components/lemmy/moderation/moderation.js'
import Avatar from '$lib/components/ui/Avatar.svelte'
import { site } from '$lib/lemmy.js'
import { site } from '$lib/lemmy.svelte.js'
import { Button, Menu, MenuButton, MenuDivider, Spinner } from 'mono-svelte'
import {
GlobeAlt,
@@ -57,10 +57,10 @@
>
{#snippet customIcon()}
{#if LINKED_INSTANCE_URL}
{#if $site}
{#if site.data}
<Avatar
alt={$site.site_view.site.name}
url={$site.site_view.site.icon}
alt={site.data.site_view.site.name}
url={site.data.site_view.site.icon}
width={32}
circle={false}
/>
@@ -135,7 +135,7 @@
href="/create/community"
disabled={!profile.data?.jwt ||
!profile.data?.user ||
($site?.site_view.local_site.community_creation_admin_only &&
(site.data?.site_view.local_site.community_creation_admin_only &&
!isAdmin(profile.data.user))}
>
{#snippet prefix()}
+6 -6
View File
@@ -35,7 +35,7 @@
} from 'svelte-hero-icons'
import { colorScheme } from '$lib/ui/colors'
import { settings } from '$lib/settings.svelte'
import { site } from '$lib/lemmy'
import { site } from '$lib/lemmy.svelte'
import SiteCard from '$lib/components/lemmy/SiteCard.svelte'
import { t } from '$lib/translations'
import UserLink from '$lib/components/lemmy/user/UserLink.svelte'
@@ -53,12 +53,12 @@
{#if showInstance}
<Modal bind:open={showInstance} title="Instance">
{#if $site}
{#if site.data}
<SiteCard
site={$site.site_view}
admins={$site.admins}
taglines={$site.taglines}
version={$site.version}
site={site.data.site_view}
admins={site.data.admins}
taglines={site.data.taglines}
version={site.data.version}
/>
{:else}
<Spinner />