feat(session): extend frontend service and add restoreView helpers

Update PersistedSession interface with last_view fields. Add lastView,
viewContextId, viewContextType params to saveSessionState(). Add
restoreView(), setRestoredPlaylistId(), setRestoredLocalAlbumId() to
navigationStore for session restore without triggering data fetches.
This commit is contained in:
vicrodh committed 2026-02-20 19:58:54 -06:00
1 parent cda07f97c5
commit 07d5d95cea
2 files changed
+40 -1

No files matched your search

+10 -1
View File
@@ -31,6 +31,9 @@ export interface PersistedSession {
repeat_mode: string; // "off" | "all" | "one"
was_playing: boolean;
saved_at: number;
last_view: string;
view_context_id: string | null;
view_context_type: string | null;
}
/**
@@ -43,7 +46,10 @@ export async function saveSessionState(
volume: number,
shuffleEnabled: boolean,
repeatMode: string,
wasPlaying: boolean
wasPlaying: boolean,
lastView?: string,
viewContextId?: string | null,
viewContextType?: string | null
): Promise<void> {
try {
await invoke('v2_save_session_state', {
@@ -54,6 +60,9 @@ export async function saveSessionState(
shuffleEnabled,
repeatMode,
wasPlaying,
lastView: lastView ?? 'home',
viewContextId: viewContextId ?? null,
viewContextType: viewContextType ?? null,
});
console.log('[Session] State saved successfully');
} catch (err) {
+30
View File
@@ -237,6 +237,36 @@ export function navigateToFavorites(tab?: FavoritesTab): void {
navigateTo(favoritesViewForTab(targetTab));
}
// ============ Session Restore ============
/**
* Restore a view as initial state (Home always in history root).
* Used during session restore to set the view without triggering data fetches.
*/
export function restoreView(view: ViewType): void {
activeView = view;
viewHistory = ['home'];
if (view !== 'home') {
viewHistory.push(view);
}
forwardHistory = [];
notifyListeners();
}
/**
* Set playlist ID without triggering navigation (for session restore).
*/
export function setRestoredPlaylistId(playlistId: number): void {
selectedPlaylistId = playlistId;
}
/**
* Set local album ID without triggering navigation (for session restore).
*/
export function setRestoredLocalAlbumId(albumId: string): void {
selectedLocalAlbumId = albumId;
}
// ============ Scroll Position ============
/**