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

+1 -1
View File
@@ -105,7 +105,7 @@ export let resumables = resumableStore()
export function addFavorite(item: Community, add: boolean = true) {
const pd = get(profileData)
const p = pd.profiles.find((p) => p.id == get(profile)?.id)
const p = pd.profiles.find((p) => p.id == profile.data?.id)
if (!p) return
let favs = p.favorites ?? []
+4 -4
View File
@@ -5,7 +5,7 @@ import type { Community, MyUserInfo, PersonView } from 'lemmy-js-client'
import { get } from 'svelte/store'
export const blockUser = async (block: boolean, id: number) => {
const auth = get(profile)?.jwt
const auth = profile.data?.jwt
if (!auth) throw new Error('Unauthorized')
@@ -22,7 +22,7 @@ export const addSubscription = (
community: Community,
subscribe: boolean = true,
) => {
const p = get(profile)
const p = profile
if (!p.user) return
@@ -38,7 +38,7 @@ export const addSubscription = (
p.user.follows.splice(index, 1)
}
profile.set(p)
profile.data.set(p)
}
export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
@@ -56,4 +56,4 @@ export const addAdmin = async (handle: string, added: boolean, jwt: string) =>
})
export const hasFavorite = (profile: Profile, id: number): boolean =>
profile?.favorites?.map((i) => i.id).includes(id) ?? false
profile.data?.favorites?.map((i) => i.id).includes(id) ?? false