This commit is contained in:
1 parent
e85e4d74ea
commit
2e4ed76121
378 files changed
+22404
-20686
No files matched your search
@@ -10,35 +10,35 @@
|
||||
*/
|
||||
|
||||
export interface SoundtrackOption {
|
||||
id: number
|
||||
code: string
|
||||
name: string
|
||||
author: string
|
||||
length: number
|
||||
id: number;
|
||||
code: string;
|
||||
name: string;
|
||||
author: string;
|
||||
length: number;
|
||||
}
|
||||
|
||||
let cachedOptions: SoundtrackOption[] | null = null
|
||||
let inflight: Promise<SoundtrackOption[]> | null = null
|
||||
let cachedOptions: SoundtrackOption[] | null = null;
|
||||
let inflight: Promise<SoundtrackOption[]> | null = null;
|
||||
|
||||
export async function loadSongPickerOptions(): Promise<SoundtrackOption[]> {
|
||||
if (cachedOptions) return cachedOptions
|
||||
if (inflight) return inflight
|
||||
if (cachedOptions) return cachedOptions;
|
||||
if (inflight) return inflight;
|
||||
inflight = (async () => {
|
||||
const res = await fetch('/api/admin/sounds', { cache: 'no-store' })
|
||||
if (!res.ok) throw new Error('Failed to load soundtracks')
|
||||
const json = (await res.json()) as { ok: boolean; items?: SoundtrackOption[] }
|
||||
cachedOptions = json.items ?? []
|
||||
inflight = null
|
||||
return cachedOptions
|
||||
})()
|
||||
return inflight
|
||||
const res = await fetch("/api/admin/sounds", { cache: "no-store" });
|
||||
if (!res.ok) throw new Error("Failed to load soundtracks");
|
||||
const json = (await res.json()) as { ok: boolean; items?: SoundtrackOption[] };
|
||||
cachedOptions = json.items ?? [];
|
||||
inflight = null;
|
||||
return cachedOptions;
|
||||
})();
|
||||
return inflight;
|
||||
}
|
||||
|
||||
export function getCachedSongPickerOptions(): SoundtrackOption[] | null {
|
||||
return cachedOptions
|
||||
return cachedOptions;
|
||||
}
|
||||
|
||||
/** Clear the cache so new uploads show up on next open. */
|
||||
export function invalidateSongPickerCache(): void {
|
||||
cachedOptions = null
|
||||
cachedOptions = null;
|
||||
}
|
||||
Reference in new issue
Block a user