mirror of
https://github.com/Psychotoxical/psysonic.git
synced 2026-07-21 23:05:46 +00:00
86704473ed
Improve normalization consistency by separating cache refresh for non-playing tracks, hardening track-id cache lookups, and keeping UI gain state aligned with actual playback. Also reduce startup stalls by preferring non-seekable streaming when format hints are missing and by tuning ALSA/analysis paths to avoid underrun-prone churn.
30 lines
994 B
TypeScript
30 lines
994 B
TypeScript
export type AnalysisStorageChangedReason =
|
|
| 'offline-delete'
|
|
| 'hotcache-delete'
|
|
| 'hotcache-purge';
|
|
|
|
export type AnalysisStorageChangedDetail = {
|
|
trackId?: string | null;
|
|
reason: AnalysisStorageChangedReason;
|
|
};
|
|
|
|
const EVENT_NAME = 'psysonic:analysis-storage-changed';
|
|
|
|
export function emitAnalysisStorageChanged(detail: AnalysisStorageChangedDetail): void {
|
|
if (typeof window === 'undefined') return;
|
|
window.dispatchEvent(new CustomEvent<AnalysisStorageChangedDetail>(EVENT_NAME, { detail }));
|
|
}
|
|
|
|
export function onAnalysisStorageChanged(
|
|
listener: (detail: AnalysisStorageChangedDetail) => void,
|
|
): () => void {
|
|
if (typeof window === 'undefined') return () => {};
|
|
const wrapped = (evt: Event) => {
|
|
const ce = evt as CustomEvent<AnalysisStorageChangedDetail>;
|
|
if (!ce?.detail) return;
|
|
listener(ce.detail);
|
|
};
|
|
window.addEventListener(EVENT_NAME, wrapped as EventListener);
|
|
return () => window.removeEventListener(EVENT_NAME, wrapped as EventListener);
|
|
}
|