fix?: remove useless $state.snapshot
This commit is contained in:
12 files changed
+125
-119
No files matched your search
@@ -20,12 +20,14 @@
|
||||
import { SvelteURL } from 'svelte/reactivity'
|
||||
import Subscribe from '../../../../routes/communities/Subscribe.svelte'
|
||||
import CommunityCard from './CommunityCard.svelte'
|
||||
import type { Snippet } from 'svelte'
|
||||
|
||||
interface Props {
|
||||
community: CommunityView
|
||||
view?: 'cozy' | 'compact'
|
||||
showCounts?: boolean
|
||||
resolveObject?: boolean
|
||||
children?: Snippet
|
||||
}
|
||||
|
||||
let {
|
||||
@@ -33,6 +35,7 @@
|
||||
view = 'compact',
|
||||
showCounts = true,
|
||||
resolveObject,
|
||||
children,
|
||||
}: Props = $props()
|
||||
</script>
|
||||
|
||||
@@ -52,104 +55,111 @@
|
||||
: ''}"
|
||||
orientation={view == 'cozy' ? 'vertical' : 'horizontal'}
|
||||
>
|
||||
{#if community.community.deleted}
|
||||
<Icon
|
||||
src={Trash}
|
||||
class="text-red-500 inline"
|
||||
micro
|
||||
size="14"
|
||||
title={$t('post.badges.deleted')}
|
||||
/>
|
||||
{/if}
|
||||
{#if community.community.nsfw}
|
||||
<Icon
|
||||
src={ExclamationTriangle}
|
||||
class="text-red-500 inline"
|
||||
micro
|
||||
size="14"
|
||||
title={$t('post.badges.nsfw')}
|
||||
/>
|
||||
{/if}
|
||||
{#if community.banned_from_community}
|
||||
<Icon
|
||||
src={NoSymbol}
|
||||
class="text-red-500 inline"
|
||||
micro
|
||||
size="14"
|
||||
title={$t('comment.banned')}
|
||||
/>
|
||||
{/if}
|
||||
{#if community.community.visibility == 'LocalOnly'}
|
||||
<Icon
|
||||
src={MapPin}
|
||||
class="text-green-500 inline"
|
||||
micro
|
||||
size="14"
|
||||
title={$t('routes.admin.config.listingType.local')}
|
||||
/>
|
||||
{/if}
|
||||
<Button
|
||||
rounding="xl"
|
||||
color="ghost"
|
||||
onclick={() =>
|
||||
modal({ title: $t('form.post.community'), snippet: communityInfo })}
|
||||
aria-label={$t('common.info')}
|
||||
size="square-md"
|
||||
>
|
||||
<Icon src={InformationCircle} size="16" mini />
|
||||
</Button>
|
||||
<Subscribe {community}>
|
||||
{#snippet children({ subscribe, subscribing })}
|
||||
{@const subscribed =
|
||||
community.subscribed == 'Subscribed' ||
|
||||
community.subscribed == 'Pending'}
|
||||
<Button
|
||||
disabled={subscribing || !profile.current?.jwt}
|
||||
loading={subscribing}
|
||||
onclick={async () => {
|
||||
const object =
|
||||
resolveObject &&
|
||||
(await client().resolveObject({
|
||||
q: community.community.actor_id,
|
||||
}))
|
||||
{#if !children}
|
||||
{#if community.community.deleted}
|
||||
<Icon
|
||||
src={Trash}
|
||||
class="text-red-500 inline"
|
||||
micro
|
||||
size="14"
|
||||
title={$t('post.badges.deleted')}
|
||||
/>
|
||||
{/if}
|
||||
{#if community.community.nsfw}
|
||||
<Icon
|
||||
src={ExclamationTriangle}
|
||||
class="text-red-500 inline"
|
||||
micro
|
||||
size="14"
|
||||
title={$t('post.badges.nsfw')}
|
||||
/>
|
||||
{/if}
|
||||
{#if community.banned_from_community}
|
||||
<Icon
|
||||
src={NoSymbol}
|
||||
class="text-red-500 inline"
|
||||
micro
|
||||
size="14"
|
||||
title={$t('comment.banned')}
|
||||
/>
|
||||
{/if}
|
||||
{#if community.community.visibility == 'LocalOnly'}
|
||||
<Icon
|
||||
src={MapPin}
|
||||
class="text-green-500 inline"
|
||||
micro
|
||||
size="14"
|
||||
title={$t('routes.admin.config.listingType.local')}
|
||||
/>
|
||||
{/if}
|
||||
<Button
|
||||
rounding="xl"
|
||||
color="ghost"
|
||||
onclick={() =>
|
||||
modal({ title: $t('form.post.community'), snippet: communityInfo })}
|
||||
aria-label={$t('common.info')}
|
||||
size="square-md"
|
||||
>
|
||||
<Icon src={InformationCircle} size="16" mini />
|
||||
</Button>
|
||||
<Subscribe {community}>
|
||||
{#snippet children({ subscribe, subscribing })}
|
||||
{@const subscribed =
|
||||
community.subscribed == 'Subscribed' ||
|
||||
community.subscribed == 'Pending'}
|
||||
<Button
|
||||
disabled={subscribing || !profile.current?.jwt}
|
||||
loading={subscribing}
|
||||
onclick={async () => {
|
||||
const object =
|
||||
resolveObject &&
|
||||
(await client().resolveObject({
|
||||
q: community.community.actor_id,
|
||||
}))
|
||||
|
||||
const res = object
|
||||
? await subscribe(object.community?.community.id)
|
||||
: await subscribe()
|
||||
const res = object
|
||||
? await subscribe(object.community?.community.id)
|
||||
: await subscribe()
|
||||
|
||||
if (res) {
|
||||
const newSubscribed =
|
||||
res.community_view.subscribed != 'NotSubscribed'
|
||||
? 'Subscribed'
|
||||
: 'NotSubscribed'
|
||||
if (res) {
|
||||
const newSubscribed =
|
||||
res.community_view.subscribed != 'NotSubscribed'
|
||||
? 'Subscribed'
|
||||
: 'NotSubscribed'
|
||||
|
||||
community.subscribed = newSubscribed
|
||||
addSubscription(community.community, newSubscribed == 'Subscribed')
|
||||
}
|
||||
}}
|
||||
size="custom"
|
||||
title={subscribed
|
||||
? $t('cards.community.subscribed')
|
||||
: $t('cards.community.subscribe')}
|
||||
color={subscribed ? 'secondary' : 'primary'}
|
||||
rounding="xl"
|
||||
class={[
|
||||
subscribed && 'text-slate-600 dark:text-zinc-400',
|
||||
' h-8.5 rounded-full',
|
||||
view == 'compact'
|
||||
? 'aspect-square @md:px-2 @md:min-w-30 @md:aspect-auto'
|
||||
: 'px-3',
|
||||
]}
|
||||
icon={subscribed ? Check : Plus}
|
||||
>
|
||||
<span class={[view == 'compact' && 'hidden', '@md:block']}>
|
||||
{#if subscribed}
|
||||
{$t('cards.community.subscribed')}
|
||||
{:else}
|
||||
{$t('cards.community.subscribe')}
|
||||
{/if}
|
||||
</span>
|
||||
</Button>
|
||||
{/snippet}
|
||||
</Subscribe>
|
||||
community.subscribed = newSubscribed
|
||||
addSubscription(
|
||||
community.community,
|
||||
newSubscribed == 'Subscribed',
|
||||
)
|
||||
}
|
||||
}}
|
||||
size="custom"
|
||||
title={subscribed
|
||||
? $t('cards.community.subscribed')
|
||||
: $t('cards.community.subscribe')}
|
||||
color={subscribed ? 'secondary' : 'primary'}
|
||||
rounding="xl"
|
||||
class={[
|
||||
subscribed && 'text-slate-600 dark:text-zinc-400',
|
||||
' h-8.5 rounded-full',
|
||||
view == 'compact'
|
||||
? 'aspect-square @md:px-2 @md:min-w-30 @md:aspect-auto'
|
||||
: 'px-3',
|
||||
]}
|
||||
icon={subscribed ? Check : Plus}
|
||||
>
|
||||
<span class={[view == 'compact' && 'hidden', '@md:block']}>
|
||||
{#if subscribed}
|
||||
{$t('cards.community.subscribed')}
|
||||
{:else}
|
||||
{$t('cards.community.subscribe')}
|
||||
{/if}
|
||||
</span>
|
||||
</Button>
|
||||
{/snippet}
|
||||
</Subscribe>
|
||||
{:else}
|
||||
{@render children?.()}
|
||||
{/if}
|
||||
</CommonItem>
|
||||
@@ -35,7 +35,6 @@
|
||||
|
||||
if (header) {
|
||||
type = 'tablecell'
|
||||
console.log(type)
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -97,7 +96,6 @@
|
||||
{/each}
|
||||
</TBody>
|
||||
{/if}
|
||||
{console.log($state.snapshot(token))}
|
||||
{/if}
|
||||
{/each}
|
||||
</Renderer>
|
||||
|
||||
@@ -32,8 +32,8 @@
|
||||
rounding="xl"
|
||||
{...rest}
|
||||
{href}
|
||||
weight="none"
|
||||
class={[
|
||||
'font-normal block',
|
||||
'hover:text-slate-900 hover:dark:text-zinc-50',
|
||||
selected
|
||||
? 'text-primary-900 dark:text-primary-100'
|
||||
|
||||
@@ -97,11 +97,6 @@ const config: Config = {
|
||||
key: '',
|
||||
loader: async () => (await import('./zh-Hant.json')).default,
|
||||
},
|
||||
{
|
||||
locale: 'tok',
|
||||
key: '',
|
||||
loader: async () => (await import('./tok.json')).default,
|
||||
},
|
||||
],
|
||||
fallbackLocale: 'en',
|
||||
}
|
||||
|
||||
@@ -32,8 +32,9 @@ export class Feed<Params, Response> {
|
||||
this.#lastParams &&
|
||||
params &&
|
||||
!recursiveEqual<Params>(params, this.#lastParams)
|
||||
)
|
||||
) {
|
||||
this.#data = undefined
|
||||
}
|
||||
this.#lastParams = params
|
||||
|
||||
if (this.#data == null) this.#data = await this.#fetch(params)
|
||||
@@ -56,7 +57,7 @@ export interface FeedTypes {
|
||||
{
|
||||
posts: PostView[]
|
||||
next_page?: string
|
||||
params: GetPostss & { page_cursor: string }
|
||||
params: GetPosts & { page_cursor: string }
|
||||
client: {
|
||||
itemHeights?: (number | null)[]
|
||||
lastSeen?: number
|
||||
|
||||
@@ -52,6 +52,12 @@
|
||||
}
|
||||
type ButtonRoundness = keyof typeof buttonRounding
|
||||
|
||||
const buttonWeight = {
|
||||
md: 'font-medium',
|
||||
none: '',
|
||||
}
|
||||
type ButtonWeight = keyof typeof buttonWeight
|
||||
|
||||
interface Props
|
||||
extends Omit<HTMLButtonAttributes | HTMLAnchorAttributes, 'prefix'> {
|
||||
loading?: boolean
|
||||
@@ -70,6 +76,7 @@
|
||||
suffix?: Snippet
|
||||
onclick?: HTMLButtonAttributes['onclick']
|
||||
icon?: IconSource
|
||||
weight?: ButtonWeight
|
||||
}
|
||||
|
||||
export type { Props as ButtonProps }
|
||||
@@ -103,6 +110,7 @@
|
||||
children,
|
||||
suffix,
|
||||
icon,
|
||||
weight = 'md',
|
||||
...rest
|
||||
}: Props = $props()
|
||||
</script>
|
||||
@@ -120,6 +128,7 @@
|
||||
buttonShadow[shadow],
|
||||
buttonColor[color],
|
||||
buttonAlignment[alignment],
|
||||
buttonWeight[weight],
|
||||
(disabled || loading) && 'btn-disabled',
|
||||
alignment == 'center'
|
||||
? 'origin-center'
|
||||
@@ -163,7 +172,6 @@
|
||||
align-items: center;
|
||||
font-size: var(--text-sm);
|
||||
gap: calc(var(--spacing) * 1.5);
|
||||
font-weight: var(--font-weight-medium);
|
||||
|
||||
transition: 75ms linear;
|
||||
|
||||
|
||||
@@ -43,11 +43,7 @@
|
||||
} from 'svelte-hero-icons'
|
||||
import type { Attachment } from 'svelte/attachments'
|
||||
import type { ClassValue, HTMLSelectAttributes } from 'svelte/elements'
|
||||
import {
|
||||
buttonColor,
|
||||
buttonShadow,
|
||||
buttonSize,
|
||||
} from '../../button/Button.svelte'
|
||||
import { buttonSize } from '../../button/Button.svelte'
|
||||
import Menu from '../../popover/Menu.svelte'
|
||||
import MenuButton from '../../popover/MenuButton.svelte'
|
||||
import Label from '../Label.svelte'
|
||||
|
||||
Reference in new issue
Block a user