fix(site): repair onboarding audio cleanup, redirect, and manifest fetches
- loadDialogueManifest: cache the resolved manifest at module level and dedupe concurrent fetches so each screen no longer re-downloads it - useGameStore: completeIntroState now also advances intro.currentStep to "playing" so callers do not need a separate setIntroStep call - SiteNamingScreen and SiteTransitionOverlay: replace ref-based guards with an isCancelled flag captured per effect. The previous guards persisted across StrictMode remounts, leaving mount 2 unable to re-run the effect after mount 1's chain was cancelled, which broke the fade animations, the second narrator dialogue and the redirect. Both screens now also call stopCurrentDialogue on unmount so audio cannot bleed across routes, and the transition gets a safety timeout in case the dialogue audio fails to fire its "ended" event - SiteTransitionOverlay: keep the <Subtitles /> mount inside the overlay so it renders inside the z-index 1000 stacking context (above the black screen); the one in SiteLayout sits behind it - IntroDialogueOverlay: route through playDialogueById instead of AudioManager.playSoundWithCallback so the narrator subtitles play in sync, and add the same isCancelled cleanup pattern - IntroRevealOverlay: rely on completeIntro alone now that it advances intro.currentStep, and skip the fade when reduced motion is requested - SiteMobileBlocker: correct logo path from public/... to /...
This commit is contained in:
@@ -12,6 +12,9 @@ import type { SubtitleCue } from "@/utils/subtitles/parseSrt";
|
||||
const DIALOGUE_MANIFEST_PATH = "/sounds/dialogue/dialogues.json";
|
||||
const DEFAULT_SUBTITLE_LANGUAGE: SubtitleLanguage = "fr";
|
||||
|
||||
let manifestCache: DialogueManifest | null = null;
|
||||
let manifestPromise: Promise<DialogueManifest | null> | null = null;
|
||||
|
||||
export interface DialogueSubtitleCue {
|
||||
voice: DialogueVoice;
|
||||
cue: SubtitleCue;
|
||||
@@ -28,13 +31,21 @@ export interface DialogueSubtitleCues {
|
||||
}
|
||||
|
||||
export async function loadDialogueManifest(): Promise<DialogueManifest | null> {
|
||||
const response = await fetch(DIALOGUE_MANIFEST_PATH);
|
||||
if (manifestCache) return manifestCache;
|
||||
if (manifestPromise) return manifestPromise;
|
||||
|
||||
if (!response.ok) {
|
||||
return null;
|
||||
}
|
||||
manifestPromise = (async () => {
|
||||
const response = await fetch(DIALOGUE_MANIFEST_PATH);
|
||||
if (!response.ok) {
|
||||
manifestPromise = null;
|
||||
return null;
|
||||
}
|
||||
const manifest = parseDialogueManifest(await response.json());
|
||||
manifestCache = manifest;
|
||||
return manifest;
|
||||
})();
|
||||
|
||||
return parseDialogueManifest(await response.json());
|
||||
return manifestPromise;
|
||||
}
|
||||
|
||||
function getDialogueVoice(
|
||||
|
||||
Reference in New Issue
Block a user