mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-10-27 11:35:23 -07:00
fix(overlay): poll cheap playback state in the open subtitle sidebar (#290)
This commit is contained in:
1 parent
7108e086ba
commit
a6d96e9966
14 files changed
+286
-108
No files matched your search
@@ -86,7 +86,9 @@ function createControllerConfigFixture() {
|
||||
function createSubtitleSidebarSnapshotFixture(): SubtitleSidebarSnapshot {
|
||||
return {
|
||||
sourceKey: 'test-subtitles',
|
||||
cuesRevision: 1,
|
||||
cues: [],
|
||||
currentTimeSec: null,
|
||||
currentSubtitle: { text: '', startTime: null, endTime: null },
|
||||
config: {
|
||||
enabled: false,
|
||||
|
||||
@@ -12,6 +12,7 @@ import type {
|
||||
RuntimeOptionId,
|
||||
RuntimeOptionValue,
|
||||
SubtitleMiningContext,
|
||||
SubtitleSidebarPlaybackState,
|
||||
SubtitleSidebarSnapshot,
|
||||
SubtitlePosition,
|
||||
SubsyncManualRunRequest,
|
||||
@@ -79,6 +80,7 @@ export interface IpcServiceDeps {
|
||||
getCurrentSubtitleRaw: () => string;
|
||||
getCurrentSubtitleAss: () => string;
|
||||
getSubtitleSidebarSnapshot?: () => Promise<SubtitleSidebarSnapshot>;
|
||||
getSubtitleSidebarPlaybackState?: () => SubtitleSidebarPlaybackState;
|
||||
getSubtitleSidebarOpen?: () => boolean;
|
||||
getPlaybackPaused: () => boolean | null | Promise<boolean | null>;
|
||||
getSubtitlePosition: () => unknown;
|
||||
@@ -369,6 +371,7 @@ export interface IpcDepsRuntimeOptions {
|
||||
getCurrentSubtitleRaw: () => string;
|
||||
getCurrentSubtitleAss: () => string;
|
||||
getSubtitleSidebarSnapshot?: () => Promise<SubtitleSidebarSnapshot>;
|
||||
getSubtitleSidebarPlaybackState?: () => SubtitleSidebarPlaybackState;
|
||||
getSubtitleSidebarOpen?: () => boolean;
|
||||
getPlaybackPaused: () => boolean | null | Promise<boolean | null>;
|
||||
getSubtitlePosition: () => unknown;
|
||||
@@ -455,6 +458,7 @@ export function createIpcDepsRuntime(options: IpcDepsRuntimeOptions): IpcService
|
||||
getCurrentSubtitleRaw: options.getCurrentSubtitleRaw,
|
||||
getCurrentSubtitleAss: options.getCurrentSubtitleAss,
|
||||
getSubtitleSidebarSnapshot: options.getSubtitleSidebarSnapshot,
|
||||
getSubtitleSidebarPlaybackState: options.getSubtitleSidebarPlaybackState,
|
||||
getSubtitleSidebarOpen: options.getSubtitleSidebarOpen ?? (() => false),
|
||||
getPlaybackPaused: options.getPlaybackPaused,
|
||||
getSubtitlePosition: options.getSubtitlePosition,
|
||||
@@ -742,6 +746,13 @@ export function registerIpcHandlers(deps: IpcServiceDeps, ipc: IpcMainRegistrar
|
||||
return await deps.getSubtitleSidebarSnapshot();
|
||||
});
|
||||
|
||||
ipc.handle(IPC_CHANNELS.request.getSubtitleSidebarPlaybackState, () => {
|
||||
if (!deps.getSubtitleSidebarPlaybackState) {
|
||||
throw new Error('Subtitle sidebar playback state is unavailable.');
|
||||
}
|
||||
return deps.getSubtitleSidebarPlaybackState();
|
||||
});
|
||||
|
||||
ipc.handle(IPC_CHANNELS.request.getSubtitleSidebarOpen, () => {
|
||||
return deps.getSubtitleSidebarOpen?.() ?? false;
|
||||
});
|
||||
|
||||
Reference in new issue
Block a user