mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-22 06:25:41 +00:00
17a5c92174
Adds a new Device Sync page for transferring music from Navidrome to USB drives or SD cards. Sidebar entry is hidden by default. - Four new Tauri commands: sync_track_to_device, compute_sync_paths, list_device_dir_files, delete_device_file - Filename template engine with cross-platform path sanitization - 4-concurrent-worker download, live progress via device:sync:progress event - Persistent source list (albums/playlists/artists) with checkbox deletion - Expandable artist tree in browser panel (per-album selection) - i18n: DE + EN complete; other locales have stub keys Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
61 lines
1.8 KiB
TypeScript
61 lines
1.8 KiB
TypeScript
import { create } from 'zustand';
|
|
import { persist } from 'zustand/middleware';
|
|
|
|
export interface SidebarItemConfig {
|
|
id: string;
|
|
visible: boolean;
|
|
}
|
|
|
|
// All configurable nav items in their default order.
|
|
// Fixed items (nowPlaying, settings, offline) are not listed here.
|
|
export const DEFAULT_SIDEBAR_ITEMS: SidebarItemConfig[] = [
|
|
{ id: 'mainstage', visible: true },
|
|
{ id: 'newReleases', visible: true },
|
|
{ id: 'allAlbums', visible: true },
|
|
{ id: 'randomPicker', visible: true },
|
|
{ id: 'artists', visible: true },
|
|
{ id: 'genres', visible: true },
|
|
{ id: 'favorites', visible: true },
|
|
{ id: 'playlists', visible: true },
|
|
{ id: 'mostPlayed', visible: true },
|
|
{ id: 'radio', visible: true },
|
|
{ id: 'folderBrowser', visible: false },
|
|
{ id: 'deviceSync', visible: false },
|
|
{ id: 'statistics', visible: true },
|
|
{ id: 'help', visible: true },
|
|
];
|
|
|
|
interface SidebarStore {
|
|
items: SidebarItemConfig[];
|
|
setItems: (items: SidebarItemConfig[]) => void;
|
|
toggleItem: (id: string) => void;
|
|
reset: () => void;
|
|
}
|
|
|
|
export const useSidebarStore = create<SidebarStore>()(
|
|
persist(
|
|
(set) => ({
|
|
items: DEFAULT_SIDEBAR_ITEMS,
|
|
|
|
setItems: (items) => set({ items }),
|
|
|
|
toggleItem: (id) => set((s) => ({
|
|
items: s.items.map(item => item.id === id ? { ...item, visible: !item.visible } : item),
|
|
})),
|
|
|
|
reset: () => set({ items: DEFAULT_SIDEBAR_ITEMS }),
|
|
}),
|
|
{
|
|
name: 'psysonic_sidebar',
|
|
onRehydrateStorage: () => (state) => {
|
|
if (!state) return;
|
|
const known = new Set(state.items.map(i => i.id));
|
|
const missing = DEFAULT_SIDEBAR_ITEMS.filter(i => !known.has(i.id));
|
|
if (missing.length > 0) {
|
|
state.items = [...state.items, ...missing];
|
|
}
|
|
},
|
|
}
|
|
)
|
|
);
|