auth: update profile class to contain profileData as well

This commit is contained in:
James Xylight committed 2025-07-12 10:56:38 -07:00
1 parent 36a9631707
commit 185cc5f54d
13 files changed
+238 -265

No files matched your search

@@ -1,11 +1,11 @@
<script lang="ts">
import { preventDefault } from 'svelte/legacy'
import { deleteProfile, profile, setUser } from '$lib/auth.svelte'
import { client } from '$lib/lemmy.svelte'
import { t } from '$lib/i18n/translations'
import { Button, TextInput, toast } from 'mono-svelte'
import { errorMessage } from '$lib/lemmy/error'
import { profile } from '$lib/auth.svelte'
let oldPassword = $state(''),
newPassword = $state(''),
@@ -21,9 +21,9 @@
old_password: oldPassword,
})
if (res?.jwt) {
const { instance, username } = profile.current
deleteProfile(profile.current.id)
await setUser(res.jwt, instance, username!)
const { instance } = profile.current
profile.remove(profile.current.id)
await profile.add(res.jwt, instance)
toast({ content: $t('toast.loginRefresh'), type: 'success' })
} else {
@@ -1,6 +1,5 @@
<script lang="ts">
import { goto } from '$app/navigation'
import { profileData, setUserID } from '$lib/auth.svelte'
import Header from '$lib/components/ui/layout/pages/Header.svelte'
import { client } from '$lib/lemmy.svelte'
import { t } from '$lib/i18n/translations'
@@ -14,6 +13,7 @@
TextInput,
toast,
} from 'mono-svelte'
import { profile } from '$lib/auth.svelte'
let deletion = $state({
modal: false,
@@ -70,11 +70,11 @@
delete_content: deletion.deleteContent,
})
profileData.profiles.splice(
profileData.profiles.findIndex(p => profileData.profile == p.id),
profile.meta.profiles.splice(
profile.meta.profiles.findIndex(p => profile.meta.profile == p.id),
)
setUserID(-1)
profile.meta.profile = -1
toast({
content: $t('toast.deleted'),
})