feat(web/m7-364): clear persisted queue + reset queue on logout
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
import { api, type User, type LoginResponse } from '$lib/api/client';
|
||||
import { queryClient } from '$lib/query/client';
|
||||
import { clearPersistedQueue } from '$lib/player/persisted';
|
||||
import { playQueue, closeQueueDrawer } from '$lib/player/store.svelte';
|
||||
|
||||
let _user = $state<User | null>(null);
|
||||
|
||||
@@ -23,6 +25,7 @@ export async function login(username: string, password: string): Promise<void> {
|
||||
}
|
||||
|
||||
export async function logout(opts: { silent?: boolean } = {}): Promise<void> {
|
||||
const userId = _user?.id;
|
||||
if (!opts.silent) {
|
||||
try {
|
||||
await api.post('/api/auth/logout', {});
|
||||
@@ -32,4 +35,9 @@ export async function logout(opts: { silent?: boolean } = {}): Promise<void> {
|
||||
}
|
||||
_user = null;
|
||||
queryClient.clear();
|
||||
// M7 #364: clear queue persistence + reset in-memory queue + close drawer
|
||||
// so a subsequent login doesn't inherit the previous user's playback state.
|
||||
if (userId) clearPersistedQueue(userId);
|
||||
playQueue([]);
|
||||
closeQueueDrawer();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user