fix?: remove useless $state.snapshot

This commit is contained in:
Xylight committed 2025-09-22 21:06:16 -07:00
1 parent 177ded3923
commit 15581e7b07
12 files changed
+125 -119

No files matched your search

@@ -20,12 +20,14 @@
import { SvelteURL } from 'svelte/reactivity' import { SvelteURL } from 'svelte/reactivity'
import Subscribe from '../../../../routes/communities/Subscribe.svelte' import Subscribe from '../../../../routes/communities/Subscribe.svelte'
import CommunityCard from './CommunityCard.svelte' import CommunityCard from './CommunityCard.svelte'
import type { Snippet } from 'svelte'
interface Props { interface Props {
community: CommunityView community: CommunityView
view?: 'cozy' | 'compact' view?: 'cozy' | 'compact'
showCounts?: boolean showCounts?: boolean
resolveObject?: boolean resolveObject?: boolean
children?: Snippet
} }
let { let {
@@ -33,6 +35,7 @@
view = 'compact', view = 'compact',
showCounts = true, showCounts = true,
resolveObject, resolveObject,
children,
}: Props = $props() }: Props = $props()
</script> </script>
@@ -52,104 +55,111 @@
: ''}" : ''}"
orientation={view == 'cozy' ? 'vertical' : 'horizontal'} orientation={view == 'cozy' ? 'vertical' : 'horizontal'}
> >
{#if community.community.deleted} {#if !children}
<Icon {#if community.community.deleted}
src={Trash} <Icon
class="text-red-500 inline" src={Trash}
micro class="text-red-500 inline"
size="14" micro
title={$t('post.badges.deleted')} size="14"
/> title={$t('post.badges.deleted')}
{/if} />
{#if community.community.nsfw} {/if}
<Icon {#if community.community.nsfw}
src={ExclamationTriangle} <Icon
class="text-red-500 inline" src={ExclamationTriangle}
micro class="text-red-500 inline"
size="14" micro
title={$t('post.badges.nsfw')} size="14"
/> title={$t('post.badges.nsfw')}
{/if} />
{#if community.banned_from_community} {/if}
<Icon {#if community.banned_from_community}
src={NoSymbol} <Icon
class="text-red-500 inline" src={NoSymbol}
micro class="text-red-500 inline"
size="14" micro
title={$t('comment.banned')} size="14"
/> title={$t('comment.banned')}
{/if} />
{#if community.community.visibility == 'LocalOnly'} {/if}
<Icon {#if community.community.visibility == 'LocalOnly'}
src={MapPin} <Icon
class="text-green-500 inline" src={MapPin}
micro class="text-green-500 inline"
size="14" micro
title={$t('routes.admin.config.listingType.local')} size="14"
/> title={$t('routes.admin.config.listingType.local')}
{/if} />
<Button {/if}
rounding="xl" <Button
color="ghost" rounding="xl"
onclick={() => color="ghost"
modal({ title: $t('form.post.community'), snippet: communityInfo })} onclick={() =>
aria-label={$t('common.info')} modal({ title: $t('form.post.community'), snippet: communityInfo })}
size="square-md" aria-label={$t('common.info')}
> size="square-md"
<Icon src={InformationCircle} size="16" mini /> >
</Button> <Icon src={InformationCircle} size="16" mini />
<Subscribe {community}> </Button>
{#snippet children({ subscribe, subscribing })} <Subscribe {community}>
{@const subscribed = {#snippet children({ subscribe, subscribing })}
community.subscribed == 'Subscribed' || {@const subscribed =
community.subscribed == 'Pending'} community.subscribed == 'Subscribed' ||
<Button community.subscribed == 'Pending'}
disabled={subscribing || !profile.current?.jwt} <Button
loading={subscribing} disabled={subscribing || !profile.current?.jwt}
onclick={async () => { loading={subscribing}
const object = onclick={async () => {
resolveObject && const object =
(await client().resolveObject({ resolveObject &&
q: community.community.actor_id, (await client().resolveObject({
})) q: community.community.actor_id,
}))
const res = object const res = object
? await subscribe(object.community?.community.id) ? await subscribe(object.community?.community.id)
: await subscribe() : await subscribe()
if (res) { if (res) {
const newSubscribed = const newSubscribed =
res.community_view.subscribed != 'NotSubscribed' res.community_view.subscribed != 'NotSubscribed'
? 'Subscribed' ? 'Subscribed'
: 'NotSubscribed' : 'NotSubscribed'
community.subscribed = newSubscribed community.subscribed = newSubscribed
addSubscription(community.community, newSubscribed == 'Subscribed') addSubscription(
} community.community,
}} newSubscribed == 'Subscribed',
size="custom" )
title={subscribed }
? $t('cards.community.subscribed') }}
: $t('cards.community.subscribe')} size="custom"
color={subscribed ? 'secondary' : 'primary'} title={subscribed
rounding="xl" ? $t('cards.community.subscribed')
class={[ : $t('cards.community.subscribe')}
subscribed && 'text-slate-600 dark:text-zinc-400', color={subscribed ? 'secondary' : 'primary'}
' h-8.5 rounded-full', rounding="xl"
view == 'compact' class={[
? 'aspect-square @md:px-2 @md:min-w-30 @md:aspect-auto' subscribed && 'text-slate-600 dark:text-zinc-400',
: 'px-3', ' h-8.5 rounded-full',
]} view == 'compact'
icon={subscribed ? Check : Plus} ? 'aspect-square @md:px-2 @md:min-w-30 @md:aspect-auto'
> : 'px-3',
<span class={[view == 'compact' && 'hidden', '@md:block']}> ]}
{#if subscribed} icon={subscribed ? Check : Plus}
{$t('cards.community.subscribed')} >
{:else} <span class={[view == 'compact' && 'hidden', '@md:block']}>
{$t('cards.community.subscribe')} {#if subscribed}
{/if} {$t('cards.community.subscribed')}
</span> {:else}
</Button> {$t('cards.community.subscribe')}
{/snippet} {/if}
</Subscribe> </span>
</Button>
{/snippet}
</Subscribe>
{:else}
{@render children?.()}
{/if}
</CommonItem> </CommonItem>
@@ -35,7 +35,6 @@
if (header) { if (header) {
type = 'tablecell' type = 'tablecell'
console.log(type)
} }
</script> </script>
@@ -97,7 +96,6 @@
{/each} {/each}
</TBody> </TBody>
{/if} {/if}
{console.log($state.snapshot(token))}
{/if} {/if}
{/each} {/each}
</Renderer> </Renderer>
@@ -32,8 +32,8 @@
rounding="xl" rounding="xl"
{...rest} {...rest}
{href} {href}
weight="none"
class={[ class={[
'font-normal block',
'hover:text-slate-900 hover:dark:text-zinc-50', 'hover:text-slate-900 hover:dark:text-zinc-50',
selected selected
? 'text-primary-900 dark:text-primary-100' ? 'text-primary-900 dark:text-primary-100'
-5
View File
@@ -97,11 +97,6 @@ const config: Config = {
key: '', key: '',
loader: async () => (await import('./zh-Hant.json')).default, loader: async () => (await import('./zh-Hant.json')).default,
}, },
{
locale: 'tok',
key: '',
loader: async () => (await import('./tok.json')).default,
},
], ],
fallbackLocale: 'en', fallbackLocale: 'en',
} }
+3 -2
View File
@@ -32,8 +32,9 @@ export class Feed<Params, Response> {
this.#lastParams && this.#lastParams &&
params && params &&
!recursiveEqual<Params>(params, this.#lastParams) !recursiveEqual<Params>(params, this.#lastParams)
) ) {
this.#data = undefined this.#data = undefined
}
this.#lastParams = params this.#lastParams = params
if (this.#data == null) this.#data = await this.#fetch(params) if (this.#data == null) this.#data = await this.#fetch(params)
@@ -56,7 +57,7 @@ export interface FeedTypes {
{ {
posts: PostView[] posts: PostView[]
next_page?: string next_page?: string
params: GetPostss & { page_cursor: string } params: GetPosts & { page_cursor: string }
client: { client: {
itemHeights?: (number | null)[] itemHeights?: (number | null)[]
lastSeen?: number lastSeen?: number
+9 -1
View File
@@ -52,6 +52,12 @@
} }
type ButtonRoundness = keyof typeof buttonRounding type ButtonRoundness = keyof typeof buttonRounding
const buttonWeight = {
md: 'font-medium',
none: '',
}
type ButtonWeight = keyof typeof buttonWeight
interface Props interface Props
extends Omit<HTMLButtonAttributes | HTMLAnchorAttributes, 'prefix'> { extends Omit<HTMLButtonAttributes | HTMLAnchorAttributes, 'prefix'> {
loading?: boolean loading?: boolean
@@ -70,6 +76,7 @@
suffix?: Snippet suffix?: Snippet
onclick?: HTMLButtonAttributes['onclick'] onclick?: HTMLButtonAttributes['onclick']
icon?: IconSource icon?: IconSource
weight?: ButtonWeight
} }
export type { Props as ButtonProps } export type { Props as ButtonProps }
@@ -103,6 +110,7 @@
children, children,
suffix, suffix,
icon, icon,
weight = 'md',
...rest ...rest
}: Props = $props() }: Props = $props()
</script> </script>
@@ -120,6 +128,7 @@
buttonShadow[shadow], buttonShadow[shadow],
buttonColor[color], buttonColor[color],
buttonAlignment[alignment], buttonAlignment[alignment],
buttonWeight[weight],
(disabled || loading) && 'btn-disabled', (disabled || loading) && 'btn-disabled',
alignment == 'center' alignment == 'center'
? 'origin-center' ? 'origin-center'
@@ -163,7 +172,6 @@
align-items: center; align-items: center;
font-size: var(--text-sm); font-size: var(--text-sm);
gap: calc(var(--spacing) * 1.5); gap: calc(var(--spacing) * 1.5);
font-weight: var(--font-weight-medium);
transition: 75ms linear; transition: 75ms linear;
+1 -5
View File
@@ -43,11 +43,7 @@
} from 'svelte-hero-icons' } from 'svelte-hero-icons'
import type { Attachment } from 'svelte/attachments' import type { Attachment } from 'svelte/attachments'
import type { ClassValue, HTMLSelectAttributes } from 'svelte/elements' import type { ClassValue, HTMLSelectAttributes } from 'svelte/elements'
import { import { buttonSize } from '../../button/Button.svelte'
buttonColor,
buttonShadow,
buttonSize,
} from '../../button/Button.svelte'
import Menu from '../../popover/Menu.svelte' import Menu from '../../popover/Menu.svelte'
import MenuButton from '../../popover/MenuButton.svelte' import MenuButton from '../../popover/MenuButton.svelte'
import Label from '../Label.svelte' import Label from '../Label.svelte'
+1 -1
View File
@@ -47,7 +47,7 @@
<Header pageHeader class="lg:flex-row justify-between flex-col"> <Header pageHeader class="lg:flex-row justify-between flex-col">
{$t('routes.inbox.title')} {$t('routes.inbox.title')}
<div class="flex gap-2 tracking-normal"> <div class="flex gap-2 tracking-normal items-center">
<Button <Button
onclick={() => goto(page.url, { invalidateAll: true })} onclick={() => goto(page.url, { invalidateAll: true })}
size="custom" size="custom"
+1 -1
View File
@@ -158,7 +158,7 @@
else data.client = { name: 'piefed', baseUrl: '/api/alpha' } else data.client = { name: 'piefed', baseUrl: '/api/alpha' }
} }
} }
class="border-0 rounded-none! border-l" class="border-y-0! border-r-0! rounded-none! border-l"
> >
<Option value="lemmyv3">Lemmy</Option> <Option value="lemmyv3">Lemmy</Option>
<Option value="piefedvalpha">Piefed</Option> <Option value="piefedvalpha">Piefed</Option>
+1 -1
View File
@@ -94,7 +94,7 @@
else form.client = { name: 'piefed', baseUrl: '/api/alpha' } else form.client = { name: 'piefed', baseUrl: '/api/alpha' }
} }
} }
class="border-0 rounded-none! border-l" class="border-y-0! border-r-0! rounded-none! border-l"
> >
<Option value="lemmyv3">Lemmy</Option> <Option value="lemmyv3">Lemmy</Option>
<Option value="piefedvalpha">Piefed</Option> <Option value="piefedvalpha">Piefed</Option>
+1 -1
View File
@@ -37,7 +37,7 @@
</script> </script>
<li <li
class="flex flex-col w-full justify-between gap-2 max-w-full setting @container/setting" class="flex flex-col w-full justify-between gap-x-2 max-w-full setting @container/setting"
> >
{#if Object.values(supportedPlatforms).some((v) => v == false) || beta} {#if Object.values(supportedPlatforms).some((v) => v == false) || beta}
<div class="flex items-center gap-2 flex-wrap"> <div class="flex items-center gap-2 flex-wrap">
-2
View File
@@ -62,8 +62,6 @@
['ru', { name: 'Русский' }], ['ru', { name: 'Русский' }],
['zh-Hans', { name: '简体中文' }], ['zh-Hans', { name: '简体中文' }],
['zh-Hant', { name: '繁體中文' }], ['zh-Hant', { name: '繁體中文' }],
['placeholder', { name: 'Unofficial' }],
['tok', { name: 'toki pona' }],
]) ])
</script> </script>