feat(phase4.7): implement history-aware favorites tab navigation

- Extended navigationStore with FavoritesTab state tracking
- Added setFavoritesTab() to push tab changes to history
- Modified navigateTo() to support favorites sub-navigation
- Wired handleTabChange() to call setFavoritesTab()
- Synced activeTab with navigation store via currentTab prop
- Back button now returns to correct Favorites tab

cp
This commit is contained in:
vicrodh committed 2026-01-18 15:52:31 -06:00
1 parent 902705f47f
commit ffb16656e7
3 files changed
+67 -3

No files matched your search

+14 -1
View File
@@ -8,6 +8,7 @@
import FavoritesEditModal from '../FavoritesEditModal.svelte';
import { type DownloadStatus } from '$lib/stores/downloadState';
import { setPlaybackContext } from '$lib/stores/playbackContextStore';
import { setFavoritesTab } from '$lib/stores/navigationStore';
import type { FavoritesPreferences } from '$lib/types';
interface FavoriteAlbum {
@@ -76,6 +77,7 @@
onTrackRemoveDownload?: (trackId: number) => void;
getTrackDownloadStatus?: (trackId: number) => { status: DownloadStatus; progress: number };
onPlaylistSelect?: (playlistId: number) => void;
currentTab?: TabType; // For syncing with navigation store
}
interface DisplayTrack {
@@ -120,12 +122,20 @@
onTrackDownload,
onTrackRemoveDownload,
getTrackDownloadStatus,
onPlaylistSelect
onPlaylistSelect,
currentTab
}: Props = $props();
type TabType = 'tracks' | 'albums' | 'artists' | 'playlists';
let activeTab = $state<TabType>('tracks');
// Sync activeTab with navigation store when parent passes currentTab
$effect(() => {
if (currentTab && currentTab !== activeTab) {
activeTab = currentTab;
}
});
const tabLabels: Record<TabType, string> = {
tracks: 'Tracks',
albums: 'Albums',
@@ -427,6 +437,9 @@
}
function handleTabChange(tab: TabType) {
// Push to navigation history for back button support
setFavoritesTab(tab);
activeTab = tab;
showAlbumGroupMenu = false;
showTrackGroupMenu = false;