fix(startup): signal autoplay gate from subtitle resolve; dedupe dict sy

- Add onResolvedSubtitle callback to resolveCurrentSubtitleForRenderer so the startup overlay-ready gate fires after the initial subtitle resolves
- Guard scheduleCharacterDictionarySync behind a last-path check so duplicate MPV media-path events don't re-trigger sync for the same video
This commit is contained in:
2026-06-05 22:04:20 -07:00
parent 0f8370a3a9
commit ef914a321f
7 changed files with 73 additions and 7 deletions
+11 -4
View File
@@ -10,13 +10,20 @@ export async function resolveCurrentSubtitleForRenderer(deps: {
currentSubtitleData: SubtitleData | null;
withCurrentSubtitleTiming: (payload: SubtitleData) => SubtitleData;
tokenizeSubtitle?: (text: string) => Promise<SubtitleData | null>;
onResolvedSubtitle?: (payload: SubtitleData) => void;
}): Promise<SubtitleData> {
const resolve = (payload: SubtitleData): SubtitleData => {
const timedPayload = deps.withCurrentSubtitleTiming(payload);
deps.onResolvedSubtitle?.(timedPayload);
return timedPayload;
};
if (deps.currentSubtitleData?.text === deps.currentSubText) {
return deps.withCurrentSubtitleTiming(deps.currentSubtitleData);
return resolve(deps.currentSubtitleData);
}
if (!deps.currentSubText.trim()) {
return deps.withCurrentSubtitleTiming({
return resolve({
text: deps.currentSubText,
tokens: null,
});
@@ -24,10 +31,10 @@ export async function resolveCurrentSubtitleForRenderer(deps: {
const tokenized = await deps.tokenizeSubtitle?.(deps.currentSubText);
if (tokenized) {
return deps.withCurrentSubtitleTiming(tokenized);
return resolve(tokenized);
}
return deps.withCurrentSubtitleTiming({
return resolve({
text: deps.currentSubText,
tokens: null,
});