fix: suppress overlay subtitle immediately when character dictionary modal opens (#84)

This commit is contained in:
2026-05-25 02:30:33 -07:00
committed by GitHub
parent 9fe13601fb
commit 7e6f9672cf
15 changed files with 307 additions and 49 deletions
+6 -3
View File
@@ -10,7 +10,7 @@ import {
test('showMpvOsdRuntime sends show-text when connected', () => {
const commands: (string | number)[][] = [];
showMpvOsdRuntime(
const shown = showMpvOsdRuntime(
{
connected: true,
send: ({ command }) => {
@@ -19,12 +19,13 @@ test('showMpvOsdRuntime sends show-text when connected', () => {
},
'hello',
);
assert.equal(shown, true);
assert.deepEqual(commands, [['show-text', 'hello', '3000']]);
});
test('showMpvOsdRuntime enables property expansion for placeholder-based messages', () => {
const commands: (string | number)[][] = [];
showMpvOsdRuntime(
const shown = showMpvOsdRuntime(
{
connected: true,
send: ({ command }) => {
@@ -33,6 +34,7 @@ test('showMpvOsdRuntime enables property expansion for placeholder-based message
},
'Subtitle delay: ${sub-delay}',
);
assert.equal(shown, true);
assert.deepEqual(commands, [
['expand-properties', 'show-text', 'Subtitle delay: ${sub-delay}', '3000'],
]);
@@ -40,7 +42,7 @@ test('showMpvOsdRuntime enables property expansion for placeholder-based message
test('showMpvOsdRuntime logs fallback when disconnected', () => {
const logs: string[] = [];
showMpvOsdRuntime(
const shown = showMpvOsdRuntime(
{
connected: false,
send: () => {},
@@ -50,6 +52,7 @@ test('showMpvOsdRuntime logs fallback when disconnected', () => {
logs.push(line);
},
);
assert.equal(shown, false);
assert.deepEqual(logs, ['OSD (MPV not connected): hello']);
});
+3 -2
View File
@@ -51,15 +51,16 @@ export function showMpvOsdRuntime(
mpvClient: MpvRuntimeClientLike | null,
text: string,
fallbackLog: (text: string) => void = (line) => logger.info(line),
): void {
): boolean {
if (mpvClient && mpvClient.connected) {
const command = text.includes('${')
? ['expand-properties', 'show-text', text, '3000']
: ['show-text', text, '3000'];
mpvClient.send({ command });
return;
return true;
}
fallbackLog(`OSD (MPV not connected): ${text}`);
return false;
}
export function replayCurrentSubtitleRuntime(mpvClient: MpvRuntimeClientLike | null): void {