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

+2 -3
View File
@@ -1,5 +1,4 @@
import { instance } from '$lib/instance.js'
import { getInstance } from '$lib/lemmy.js'
import { profile } from '$lib/auth.svelte.js'
import { error, redirect } from '@sveltejs/kit'
import { get } from 'svelte/store'
@@ -7,7 +6,7 @@ export function load({ params, url }) {
if (Number(params.instance)) {
const split = url.pathname.split('/')
split.splice(2, 0, `${getInstance()?.toLowerCase()}`)
split.splice(2, 0, `${profile.data.instance?.toLowerCase()}`)
const newUrl = new URL(url)
newUrl.pathname = split.join('/')
@@ -114,7 +114,7 @@
onMount(async () => {
if (
!(data.post.post_view.read && settings.markPostsAsRead) &&
$profile?.jwt
profile.data?.jwt
) {
getClient().markPostAsRead({
read: settings.markPostsAsRead,
@@ -237,12 +237,12 @@
<span class="text-primary-900 dark:text-primary-100 font-bold">
{$t('routes.post.remoteView')}
</span>
{#if $profile?.jwt}
{#if profile.data?.jwt}
<Button
class="ml-auto"
onclick={() => {
if ($profile?.jwt) {
fetchOnHome($profile?.jwt)
if (profile.data?.jwt) {
fetchOnHome(profile.data?.jwt)
}
}}
>
@@ -50,7 +50,7 @@
})
</script>
{#if $profile?.jwt}
{#if profile.data?.jwt}
{#if !commenting}
<EndPlaceholder class="">
<Button color="primary" onclick={() => (commenting = true)}>
@@ -89,8 +89,8 @@
}}
locked={(post.post_view.post.locked &&
!(
$profile?.user?.local_user_view.local_user.admin ||
$profile?.user?.moderates
profile.data?.user?.local_user_view.local_user.admin ||
profile.data?.user?.moderates
.map((c) => c.community.id)
.includes(post.community_view.community.id)
)) ||
@@ -106,7 +106,7 @@
{/if}
{/if}
{#if commenting || !$profile.jwt}
{#if commenting || !profile.data.jwt}
<div class="gap-2 flex items-center">
<Select size="md" bind:value={sort} onchange={onupdate}>
<Option icon={Fire} value="Hot">{$t('filter.sort.hot')}</Option>