feat: use state based auth instead of store based (#488)

* misc: switch to state for auth

* fix: class based auth not working
This commit is contained in:
Xylight authored and GitHub committed 2025-02-08 13:49:09 -08:00
1 parent 8c6ff77fac
commit 5651ad475d
83 files changed
+395 -469

No files matched your search

@@ -25,7 +25,7 @@
animate:flip={{ duration: 500, easing: expoOut }}
>
<div class="flex-none grid group">
{#if $profile && !hasFavorite($profile, follow.id)}
{#if profile && !hasFavorite(profile.data, follow.id)}
<Button
rounding="pill"
size="custom"
@@ -36,7 +36,7 @@
>
<Icon src={Star} size="16" mini />
</Button>
{:else if isFavorites && $profile && hasFavorite($profile, follow.id)}
{:else if isFavorites && profile && hasFavorite(profile.data, follow.id)}
<Button
rounding="pill"
size="custom"
@@ -53,7 +53,7 @@
alt={follow.name}
title={follow.title}
width={28}
class={!isFavorites && $profile && hasFavorite($profile, follow.id)
class={!isFavorites && profile && hasFavorite(profile.data, follow.id)
? ''
: 'group-hover:hidden'}
/>
@@ -23,21 +23,22 @@
alignment="left"
loading={switching}
loaderWidth={20}
selected={$profile?.id == prof.id}
selected={profile.data?.id == prof.id}
onclick={async () => {
switching = true
if ($profile?.id != prof.id) {
if (profile.data?.id != prof.id) {
await setUserID(prof.id)
}
await goto(page.url, {
invalidateAll: true,
})
console.log(page.url)
// await goto(page.url, {
// invalidateAll: true,
// })
switching = false
}}
class="w-full font-normal {$profile?.id == prof.id
class="w-full font-normal {profile.data?.id == prof.id
? '!bg-slate-100 dark:!bg-zinc-900'
: ''}"
>
@@ -46,11 +47,11 @@
profile={prof}
{index}
{guest}
selected={$profile?.id == prof.id}
selected={profile.data?.id == prof.id}
/>
{/snippet}
<span
class="inline-flex flex-col gap-0 {$profile?.id == prof.id
class="inline-flex flex-col gap-0 {profile.data?.id == prof.id
? 'font-semibold'
: ''}"
>
+15 -13
View File
@@ -33,7 +33,7 @@
gap-1 h-fit max-h-screen {clazz}"
{style}
>
{#if $profile?.jwt}
{#if profile.data?.jwt}
<SidebarButton icon={UserCircle} href="/profile">
{#snippet label()}
<span>
@@ -90,7 +90,7 @@
{/snippet}
</SidebarButton>
{/if}
{#if $profileData.profiles.length >= 1}
{#if profileData.profiles.length >= 1}
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
<Expandable
@@ -103,13 +103,13 @@
{$t('account.accounts')}
{#snippet action()}
<span class="dark:text-white text-black">
{$profileData.profiles.length}
{profileData.profiles.length}
</span>
{/snippet}
</EndPlaceholder>
</span>
{/snippet}
{#each [...$profileData.profiles] as prof, index}
{#each [...profileData.profiles] as prof, index}
<div class="w-full">
<ProfileButton {index} {prof} />
</div>
@@ -120,7 +120,7 @@
</Expandable>
{/if}
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
{#if $profile?.favorites && $profile?.favorites.length > 0}
{#if profile.data?.favorites && profile.data?.favorites.length > 0}
<Expandable
class="max-w-full min-w-0 w-full"
bind:open={settings.expand.favorites}
@@ -135,18 +135,18 @@
{$t('routes.profile.favorites')}
{#snippet action()}
<span class="dark:text-white text-black">
{$profile.favorites?.length}
{profile.data.favorites?.length}
</span>
{/snippet}
</EndPlaceholder>
</span>
{/snippet}
<CommunityList isFavorites items={$profile.favorites} />
<CommunityList isFavorites items={profile.data.favorites} />
</Expandable>
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
{/if}
{#if $profile?.user}
{#if $profile?.user.moderates.length > 0}
{#if profile.data?.user}
{#if profile.data?.user.moderates.length > 0}
<Expandable
class="max-w-full min-w-0 w-full"
bind:open={settings.expand.moderates}
@@ -161,14 +161,14 @@
{$t('routes.profile.moderates')}
{#snippet action()}
<span class="dark:text-white text-black">
{$profile.user?.moderates.length}
{profile.data.user?.moderates.length}
</span>
{/snippet}
</EndPlaceholder>
</span>
{/snippet}
<CommunityList
items={$profile.user.moderates.map((i) => i.community)}
items={profile.data.user.moderates.map((i) => i.community)}
/>
</Expandable>
<hr class="border-slate-200 dark:border-zinc-900 my-1" />
@@ -188,13 +188,15 @@
{$t('profile.subscribed')}
{#snippet action()}
<span class="dark:text-white text-black">
{$profile.user?.follows.length}
{profile.data.user?.follows.length}
</span>
{/snippet}
</EndPlaceholder>
</span>
{/snippet}
<CommunityList items={$profile.user.follows.map((i) => i.community)} />
<CommunityList
items={profile.data.user.follows.map((i) => i.community)}
/>
</Expandable>
{/if}
</nav>