mirror of
https://github.com/kilyabin/psysonic.git
synced 2026-07-21 22:15:40 +00:00
fix(store): reset conflicting hot cache + preload state on rehydration
Users who had both hotCacheEnabled and preloadMode !== 'off' before mutual exclusion was enforced will have both reset to off on next start. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -522,6 +522,11 @@ export const useAuthStore = create<AuthState>()(
|
|||||||
},
|
},
|
||||||
onRehydrateStorage: () => (state, error) => {
|
onRehydrateStorage: () => (state, error) => {
|
||||||
if (error || !state) return;
|
if (error || !state) return;
|
||||||
|
// If both hot cache and preload were enabled before mutual exclusion was enforced, reset both.
|
||||||
|
const conflictingLegacyState =
|
||||||
|
state.hotCacheEnabled && state.preloadMode !== 'off'
|
||||||
|
? { hotCacheEnabled: false, preloadMode: 'off' as const }
|
||||||
|
: {};
|
||||||
useAuthStore.setState({
|
useAuthStore.setState({
|
||||||
mixMinRatingSong: clampMixFilterMinStars(state.mixMinRatingSong as number),
|
mixMinRatingSong: clampMixFilterMinStars(state.mixMinRatingSong as number),
|
||||||
mixMinRatingAlbum: clampMixFilterMinStars(state.mixMinRatingAlbum as number),
|
mixMinRatingAlbum: clampMixFilterMinStars(state.mixMinRatingAlbum as number),
|
||||||
@@ -529,6 +534,7 @@ export const useAuthStore = create<AuthState>()(
|
|||||||
skipStarManualSkipCountsByKey: sanitizeSkipStarCounts(
|
skipStarManualSkipCountsByKey: sanitizeSkipStarCounts(
|
||||||
(state as { skipStarManualSkipCountsByKey?: unknown }).skipStarManualSkipCountsByKey,
|
(state as { skipStarManualSkipCountsByKey?: unknown }).skipStarManualSkipCountsByKey,
|
||||||
),
|
),
|
||||||
|
...conflictingLegacyState,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user