feat(web): logout of all tabs (#12407)

This commit is contained in:
Jason Rasmussen 2024-09-07 13:21:05 -04:00 committed by GitHub
parent 0dabb890cf
commit 2554cc96b0
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
9 changed files with 73 additions and 25 deletions

View file

@ -1,7 +1,9 @@
import { browser } from '$app/environment';
import { goto } from '$app/navigation';
import { foldersStore } from '$lib/stores/folders.store';
import { purchaseStore } from '$lib/stores/purchase.store';
import { serverInfo } from '$lib/stores/server-info.store';
import { preferences as preferences$, user as user$ } from '$lib/stores/user.store';
import { preferences as preferences$, resetSavedUser, user as user$ } from '$lib/stores/user.store';
import { getAboutInfo, getMyPreferences, getMyUser, getStorage } from '@immich/sdk';
import { redirect } from '@sveltejs/kit';
import { DateTime } from 'luxon';
@ -87,3 +89,16 @@ export const getAccountAge = (): number => {
return Number(accountAge);
};
export const handleLogout = async (redirectUri: string) => {
try {
if (redirectUri.startsWith('/')) {
await goto(redirectUri);
} else {
window.location.href = redirectUri;
}
} finally {
resetSavedUser();
foldersStore.clearCache();
}
};