mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-22 16:46:10 -08:00
* fix(plugin): keep loading OSD off on warm playlist advance - Track overlay_content_ready_seen when the app sends subminer-overlay-loading-ready - Skip restarting the "Overlay loading" spinner for an overlay that already reported ready, so it no longer times out into "Overlay did not become ready" (#315) - Reset the flag on stop, restart, start failure and shutdown - Add start-gate tests for warm and not-yet-ready playlist advances * fix(plugin): only report overlay ready once content has loaded Hide paths dismissed the loading OSD with subminer-overlay-loading-ready, which the plugin now remembers to skip the spinner on later playlist files. A hide before the overlay had content would wrongly mark it ready. The app now sends ready only when the overlay window content is ready, and a new stop-only subminer-overlay-loading-dismissed message otherwise. * fix(plugin): resync overlay readiness on dismissal and mpv connect A dismissal now clears the plugin's readiness flag, since the app sends it only while its overlay window has no content (e.g. a replaced window). On mpv (re)connect the app resends subminer-overlay-loading-ready when the overlay already has content, so a ready signal lost while mpv was away, or sent before this mpv's plugin existed, still reaches the plugin. * refactor(main): pass overlay readiness handler directly
61 lines
2.3 KiB
TypeScript
61 lines
2.3 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import type { BrowserWindow } from 'electron';
|
|
|
|
import { OVERLAY_WINDOW_CONTENT_READY_FLAG } from '../../core/services/overlay-window-flags';
|
|
import type { MpvIpcClient } from '../../core/services';
|
|
import type { ResolvedConfig } from '../../types';
|
|
import { createOverlayNotificationsRuntime } from './overlay-notifications-runtime';
|
|
|
|
function createRuntimeHarness(contentReady: boolean) {
|
|
const sent: unknown[][] = [];
|
|
const overlayWindow = {
|
|
isDestroyed: () => false,
|
|
[OVERLAY_WINDOW_CONTENT_READY_FLAG]: contentReady,
|
|
} as unknown as BrowserWindow;
|
|
const mpvClient = {
|
|
send: ({ command }: { command: unknown[] }) => {
|
|
sent.push(command);
|
|
},
|
|
} as unknown as MpvIpcClient;
|
|
const runtime = createOverlayNotificationsRuntime({
|
|
getResolvedConfig: () => ({}) as ResolvedConfig,
|
|
getMainOverlayWindow: () => overlayWindow,
|
|
getVisibleOverlayVisible: () => false,
|
|
broadcastToOverlayWindows: () => {},
|
|
showMpvOsd: () => {},
|
|
getMpvClient: () => mpvClient,
|
|
getAnkiIntegration: () => null,
|
|
getRuntimeOptionsManager: () => null,
|
|
});
|
|
const scriptMessages = () =>
|
|
sent.filter((command) => command[0] === 'script-message').map((command) => command[1]);
|
|
return { runtime, scriptMessages };
|
|
}
|
|
|
|
test('dismissing the loading OSD before overlay content is ready only stops the plugin spinner', () => {
|
|
const { runtime, scriptMessages } = createRuntimeHarness(false);
|
|
|
|
runtime.dismissOverlayLoadingStatusNotification();
|
|
|
|
assert.deepEqual(scriptMessages(), ['subminer-overlay-loading-dismissed']);
|
|
});
|
|
|
|
test('dismissing the loading OSD once overlay content is ready reports readiness to the plugin', () => {
|
|
const { runtime, scriptMessages } = createRuntimeHarness(true);
|
|
|
|
runtime.dismissOverlayLoadingStatusNotification();
|
|
|
|
assert.deepEqual(scriptMessages(), ['subminer-overlay-loading-ready']);
|
|
});
|
|
|
|
test('reporting overlay readiness after an mpv connect resends ready only for loaded content', () => {
|
|
const ready = createRuntimeHarness(true);
|
|
ready.runtime.reportOverlayContentReadyToPlugin();
|
|
assert.deepEqual(ready.scriptMessages(), ['subminer-overlay-loading-ready']);
|
|
|
|
const loading = createRuntimeHarness(false);
|
|
loading.runtime.reportOverlayContentReadyToPlugin();
|
|
assert.deepEqual(loading.scriptMessages(), []);
|
|
});
|