mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-05-25 12:55:18 -07:00
fix: reset WS subtitle state and parsed cues on media path change
- Clear activeParsedSubtitleCues, activeParsedSubtitleSource, lastObservedTimePos - Broadcast reset payload to subtitleWsService and annotationSubtitleWsService - Extend wiring test to cover new reset fields and WS broadcasts
This commit is contained in:
+13
-1
@@ -4247,11 +4247,23 @@ const {
|
||||
const normalizedPath = path.trim();
|
||||
const previousPath = appState.currentMediaPath?.trim() || null;
|
||||
if ((normalizedPath || null) !== previousPath) {
|
||||
const resetSubtitlePayload = { text: '', tokens: null };
|
||||
const frequencyDictionary = getResolvedConfig().subtitleStyle.frequencyDictionary;
|
||||
const frequencyOptions = {
|
||||
enabled: frequencyDictionary.enabled,
|
||||
topX: frequencyDictionary.topX,
|
||||
mode: frequencyDictionary.mode,
|
||||
};
|
||||
autoplaySubtitlePrimedMediaPath = null;
|
||||
lastObservedTimePos = 0;
|
||||
appState.currentSubText = '';
|
||||
appState.currentSubAssText = '';
|
||||
appState.currentSubtitleData = null;
|
||||
broadcastToOverlayWindows('subtitle:set', { text: '', tokens: null });
|
||||
appState.activeParsedSubtitleCues = [];
|
||||
appState.activeParsedSubtitleSource = null;
|
||||
broadcastToOverlayWindows('subtitle:set', resetSubtitlePayload);
|
||||
subtitleWsService.broadcast(resetSubtitlePayload, frequencyOptions);
|
||||
annotationSubtitleWsService.broadcast(resetSubtitlePayload, frequencyOptions);
|
||||
}
|
||||
autoplayReadyGate.invalidatePendingAutoplayReadyFallbacks();
|
||||
currentMediaTokenizationGate.updateCurrentMediaPath(path);
|
||||
|
||||
@@ -31,7 +31,12 @@ test('media path changes clear rendered subtitle state', () => {
|
||||
assert.match(actionBlock, /appState\.currentSubText = '';/);
|
||||
assert.match(actionBlock, /appState\.currentSubAssText = '';/);
|
||||
assert.match(actionBlock, /appState\.currentSubtitleData = null;/);
|
||||
assert.match(actionBlock, /appState\.activeParsedSubtitleCues = \[\];/);
|
||||
assert.match(actionBlock, /appState\.activeParsedSubtitleSource = null;/);
|
||||
assert.match(actionBlock, /lastObservedTimePos = 0;/);
|
||||
assert.match(actionBlock, /broadcastToOverlayWindows\('subtitle:set',/);
|
||||
assert.match(actionBlock, /subtitleWsService\.broadcast\(/);
|
||||
assert.match(actionBlock, /annotationSubtitleWsService\.broadcast\(/);
|
||||
assert.ok(
|
||||
actionBlock.indexOf('appState.currentSubtitleData = null;') <
|
||||
actionBlock.indexOf("broadcastToOverlayWindows('subtitle:set'"),
|
||||
|
||||
Reference in New Issue
Block a user