diff --git a/crates/qbz-models/src/types.rs b/crates/qbz-models/src/types.rs index c5b3079ff..b426c7408 100644 --- a/crates/qbz-models/src/types.rs +++ b/crates/qbz-models/src/types.rs @@ -631,6 +631,10 @@ pub struct DiscoverAlbum { pub genre: Option, pub dates: Option, pub audio_info: Option, + /// Editorial awards attached to the album. Id 88 = Qobuzissime, + /// id 151 = Qobuz Album of the Week (locale-stable). + #[serde(default)] + pub awards: Option>, } /// Album image from discover endpoint diff --git a/src-tauri/src/api/models.rs b/src-tauri/src/api/models.rs index d0f81f566..82c384abb 100644 --- a/src-tauri/src/api/models.rs +++ b/src-tauri/src/api/models.rs @@ -811,6 +811,10 @@ pub struct DiscoverAlbum { pub genre: Option, pub dates: Option, pub audio_info: Option, + /// Editorial awards attached to the album. Id 88 = Qobuzissime, + /// id 151 = Qobuz Album of the Week (locale-stable). + #[serde(default)] + pub awards: Option>, } /// Album image from discover endpoint diff --git a/src/lib/stores/homeDataCache.ts b/src/lib/stores/homeDataCache.ts index afce22627..c8ac27c3a 100644 --- a/src/lib/stores/homeDataCache.ts +++ b/src/lib/stores/homeDataCache.ts @@ -55,6 +55,7 @@ export interface HomeCacheData { timestamp: number; genreIds: number[]; // snapshot of genre filter at cache time scrollTop: number; + schemaVersion?: number; } export type HomeCacheStatus = 'fresh' | 'stale' | 'empty'; @@ -62,6 +63,13 @@ export type HomeCacheStatus = 'fresh' | 'stale' | 'empty'; const FRESH_TTL_MS = 5 * 60 * 1000; // 5 minutes const MAX_TTL_MS = 60 * 60 * 1000; // 60 minutes const SESSION_KEY = 'qbz-home-cache'; +/** + * Bump whenever the shape of HomeCacheData or AlbumCardData changes, + * so stale sessionStorage entries from older builds are discarded + * instead of being restored with missing fields (which caused the + * ribbon field to show up as undefined on cache-fresh loads). + */ +const CACHE_SCHEMA_VERSION = 2; let cache: HomeCacheData | null = null; @@ -70,7 +78,13 @@ function restoreFromSession(): void { try { const stored = sessionStorage.getItem(SESSION_KEY); if (stored) { - cache = JSON.parse(stored); + const parsed = JSON.parse(stored); + if (parsed?.schemaVersion === CACHE_SCHEMA_VERSION) { + cache = parsed; + } else { + // Older schema — drop it so loadHome() runs fresh. + try { sessionStorage.removeItem(SESSION_KEY); } catch {} + } } } catch { // sessionStorage not available or corrupted @@ -129,7 +143,8 @@ export function setHomeCache(data: Omit