fix improperly ported metadata logic

This commit is contained in:
Boof2015
2026-07-05 02:10:25 -04:00
parent 34ffda7190
commit 3a25966dde
29 changed files with 1349 additions and 110 deletions
+15 -1
View File
@@ -9,6 +9,7 @@ import type { ArtistGroupingMode } from '@/library/artistGrouping';
* subscribes here to recompute the artist list when the grouping mode changes.
*/
const ARTIST_GROUPING_KEY = 'artist_grouping_mode';
const INCLUDE_SINGLES_KEY = 'album_include_singles';
const SCOPE_MODE_KEY = 'scope_mode';
const SCOPE_STAGE_VISIBLE_KEY = 'scope_stage_visible';
@@ -29,17 +30,21 @@ function parseBoolean(value: string | null): boolean {
interface SettingsStore {
artistGroupingMode: ArtistGroupingMode;
/** Show 1-track albums in the Albums view (desktop parity default: hidden). */
includeSingles: boolean;
scopeMode: ScopeMode;
scopeStageVisible: boolean;
loaded: boolean;
load: () => Promise<void>;
setArtistGroupingMode: (mode: ArtistGroupingMode) => Promise<void>;
setIncludeSingles: (include: boolean) => Promise<void>;
setScopeMode: (mode: ScopeMode) => Promise<void>;
setScopeStageVisible: (visible: boolean) => Promise<void>;
}
export const useSettingsStore = create<SettingsStore>((set, get) => ({
artistGroupingMode: 'astra',
includeSingles: false,
scopeMode: 'spectrum',
scopeStageVisible: false,
loaded: false,
@@ -47,13 +52,15 @@ export const useSettingsStore = create<SettingsStore>((set, get) => ({
load: async () => {
if (get().loaded) return;
const db = await openLibraryDb();
const [grouping, scope, scopeStageVisible] = await Promise.all([
const [grouping, includeSingles, scope, scopeStageVisible] = await Promise.all([
getSetting(db, ARTIST_GROUPING_KEY),
getSetting(db, INCLUDE_SINGLES_KEY),
getSetting(db, SCOPE_MODE_KEY),
getSetting(db, SCOPE_STAGE_VISIBLE_KEY),
]);
set({
artistGroupingMode: parseGroupingMode(grouping),
includeSingles: parseBoolean(includeSingles),
scopeMode: parseScopeMode(scope),
scopeStageVisible: parseBoolean(scopeStageVisible),
loaded: true,
@@ -67,6 +74,13 @@ export const useSettingsStore = create<SettingsStore>((set, get) => ({
await setSetting(db, ARTIST_GROUPING_KEY, mode);
},
setIncludeSingles: async (include) => {
if (get().includeSingles === include) return;
set({ includeSingles: include });
const db = await openLibraryDb();
await setSetting(db, INCLUDE_SINGLES_KEY, include ? 'true' : 'false');
},
setScopeMode: async (mode) => {
if (get().scopeMode === mode) return;
set({ scopeMode: mode });