mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-27 18:22:41 -08:00
refactor(main): extract mpv IPC command deps into factory
This commit is contained in:
47
src/main.ts
47
src/main.ts
@@ -1473,30 +1473,31 @@ function handleOverlayModalClosed(modal: OverlayHostedModal): void {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function handleMpvCommandFromIpc(command: (string | number)[]): void {
|
function handleMpvCommandFromIpc(command: (string | number)[]): void {
|
||||||
handleMpvCommandFromIpcService(
|
handleMpvCommandFromIpcService(command, createMpvCommandRuntimeServiceDeps());
|
||||||
command,
|
}
|
||||||
{
|
|
||||||
specialCommands: SPECIAL_COMMANDS,
|
function createMpvCommandRuntimeServiceDeps() {
|
||||||
triggerSubsyncFromConfig: () => triggerSubsyncFromConfig(),
|
return {
|
||||||
openRuntimeOptionsPalette: () => openRuntimeOptionsPalette(),
|
specialCommands: SPECIAL_COMMANDS,
|
||||||
runtimeOptionsCycle: (id, direction) => {
|
triggerSubsyncFromConfig: () => triggerSubsyncFromConfig(),
|
||||||
if (!appState.runtimeOptionsManager) {
|
openRuntimeOptionsPalette: () => openRuntimeOptionsPalette(),
|
||||||
return { ok: false, error: "Runtime options manager unavailable" };
|
runtimeOptionsCycle: (id, direction) => {
|
||||||
}
|
if (!appState.runtimeOptionsManager) {
|
||||||
return applyRuntimeOptionResultRuntimeService(
|
return { ok: false, error: "Runtime options manager unavailable" };
|
||||||
appState.runtimeOptionsManager.cycleOption(id, direction),
|
}
|
||||||
(text) => showMpvOsd(text),
|
return applyRuntimeOptionResultRuntimeService(
|
||||||
);
|
appState.runtimeOptionsManager.cycleOption(id, direction),
|
||||||
},
|
(text) => showMpvOsd(text),
|
||||||
showMpvOsd: (text) => showMpvOsd(text),
|
);
|
||||||
mpvReplaySubtitle: () => replayCurrentSubtitleRuntimeService(appState.mpvClient),
|
|
||||||
mpvPlayNextSubtitle: () => playNextSubtitleRuntimeService(appState.mpvClient),
|
|
||||||
mpvSendCommand: (rawCommand) =>
|
|
||||||
sendMpvCommandRuntimeService(appState.mpvClient, rawCommand),
|
|
||||||
isMpvConnected: () => Boolean(appState.mpvClient && appState.mpvClient.connected),
|
|
||||||
hasRuntimeOptionsManager: () => appState.runtimeOptionsManager !== null,
|
|
||||||
},
|
},
|
||||||
);
|
showMpvOsd: (text) => showMpvOsd(text),
|
||||||
|
mpvReplaySubtitle: () => replayCurrentSubtitleRuntimeService(appState.mpvClient),
|
||||||
|
mpvPlayNextSubtitle: () => playNextSubtitleRuntimeService(appState.mpvClient),
|
||||||
|
mpvSendCommand: (rawCommand) =>
|
||||||
|
sendMpvCommandRuntimeService(appState.mpvClient, rawCommand),
|
||||||
|
isMpvConnected: () => Boolean(appState.mpvClient && appState.mpvClient.connected),
|
||||||
|
hasRuntimeOptionsManager: () => appState.runtimeOptionsManager !== null,
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
async function runSubsyncManualFromIpc(
|
async function runSubsyncManualFromIpc(
|
||||||
|
|||||||
Reference in New Issue
Block a user