From 5582e49be9e896296c06445d36608444c19c8dd0 Mon Sep 17 00:00:00 2001 From: Xyphyn Date: Thu, 3 Aug 2023 10:51:42 -0700 Subject: [PATCH] misc: fix toasts --- src/lib/auth.ts | 12 +++++++++--- src/lib/components/ui/toasts/Toast.svelte | 16 +++++++++++++++- src/lib/components/ui/toasts/toasts.ts | 6 +++++- 3 files changed, 29 insertions(+), 5 deletions(-) diff --git a/src/lib/auth.ts b/src/lib/auth.ts index 7442a980..175125e6 100644 --- a/src/lib/auth.ts +++ b/src/lib/auth.ts @@ -44,11 +44,17 @@ export const profileData = writable( getFromStorage('profileData') ?? { profiles: [], profile: -1 } ) +// stupid hack to get dev server working +// why does this always happen to me + +let initialInstance = get(profileData).defaultInstance + profileData.subscribe(async (pd) => { setFromStorage('profileData', pd) - if (pd.profile == -1) { - instance.set(get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL) + if (pd.profile == -1 && initialInstance != pd.defaultInstance) { + initialInstance = get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL + instance?.set(get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL) } }) @@ -56,7 +62,7 @@ export const profile = writable(getProfile()) profile.subscribe(async (p) => { if (p?.id == -1) { - instance.set(get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL) + instance?.set(get(profileData).defaultInstance ?? DEFAULT_INSTANCE_URL) } if (!p || !p.jwt) { profileData.update((pd) => ({ ...pd, profile: -1 })) diff --git a/src/lib/components/ui/toasts/Toast.svelte b/src/lib/components/ui/toasts/Toast.svelte index d7929bd3..2f7ce0e0 100644 --- a/src/lib/components/ui/toasts/Toast.svelte +++ b/src/lib/components/ui/toasts/Toast.svelte @@ -1,4 +1,5 @@