mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-02-27 18:22:41 -08:00
fix(overlay): honor mpv subtitle binding config and tidy modal close
This commit is contained in:
@@ -135,6 +135,20 @@ test('dispatchMpvProtocolMessage enforces sub-visibility hidden when overlay sup
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('dispatchMpvProtocolMessage skips sub-visibility suppression when overlay binding is disabled', async () => {
|
||||||
|
const { deps, state } = createDeps({
|
||||||
|
shouldBindVisibleOverlayToMpvSubVisibility: () => false,
|
||||||
|
isVisibleOverlayVisible: () => true,
|
||||||
|
});
|
||||||
|
|
||||||
|
await dispatchMpvProtocolMessage(
|
||||||
|
{ event: 'property-change', name: 'sub-visibility', data: 'yes' },
|
||||||
|
deps,
|
||||||
|
);
|
||||||
|
|
||||||
|
assert.equal(state.commands.length, 0);
|
||||||
|
});
|
||||||
|
|
||||||
test('dispatchMpvProtocolMessage sets secondary subtitle track based on track list response', async () => {
|
test('dispatchMpvProtocolMessage sets secondary subtitle track based on track list response', async () => {
|
||||||
const { deps, state } = createDeps();
|
const { deps, state } = createDeps();
|
||||||
|
|
||||||
|
|||||||
@@ -220,7 +220,8 @@ export async function dispatchMpvProtocolMessage(
|
|||||||
} else if (msg.name === 'sub-visibility') {
|
} else if (msg.name === 'sub-visibility') {
|
||||||
if (
|
if (
|
||||||
deps.isVisibleOverlayVisible() &&
|
deps.isVisibleOverlayVisible() &&
|
||||||
asBoolean(msg.data, false)
|
asBoolean(msg.data, false) &&
|
||||||
|
(deps.shouldBindVisibleOverlayToMpvSubVisibility?.() ?? true)
|
||||||
) {
|
) {
|
||||||
deps.sendCommand({ command: ['set_property', 'sub-visibility', 'no'] });
|
deps.sendCommand({ command: ['set_property', 'sub-visibility', 'no'] });
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -758,7 +758,10 @@ const restoreOverlayMpvSubtitles = createRestoreOverlayMpvSubtitlesHandler({
|
|||||||
});
|
});
|
||||||
|
|
||||||
function shouldSuppressMpvSubtitlesForOverlay(): boolean {
|
function shouldSuppressMpvSubtitlesForOverlay(): boolean {
|
||||||
return overlayManager.getVisibleOverlayVisible();
|
return (
|
||||||
|
overlayManager.getVisibleOverlayVisible() &&
|
||||||
|
configDerivedRuntime.shouldBindVisibleOverlayToMpvSubVisibility()
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
function syncOverlayMpvSubtitleSuppression(): void {
|
function syncOverlayMpvSubtitleSuppression(): void {
|
||||||
|
|||||||
@@ -232,15 +232,13 @@ export function createOverlayModalRuntimeService(
|
|||||||
const handleOverlayModalClosed = (modal: OverlayHostedModal): void => {
|
const handleOverlayModalClosed = (modal: OverlayHostedModal): void => {
|
||||||
if (!restoreVisibleOverlayOnModalClose.has(modal)) return;
|
if (!restoreVisibleOverlayOnModalClose.has(modal)) return;
|
||||||
restoreVisibleOverlayOnModalClose.delete(modal);
|
restoreVisibleOverlayOnModalClose.delete(modal);
|
||||||
|
const modalWindow = deps.getModalWindow();
|
||||||
if (restoreVisibleOverlayOnModalClose.size === 0) {
|
if (restoreVisibleOverlayOnModalClose.size === 0) {
|
||||||
clearPendingModalWindowReveal();
|
clearPendingModalWindowReveal();
|
||||||
notifyModalStateChange(false);
|
notifyModalStateChange(false);
|
||||||
}
|
if (modalWindow && !modalWindow.isDestroyed()) {
|
||||||
|
modalWindow.hide();
|
||||||
const modalWindow = deps.getModalWindow();
|
}
|
||||||
if (!modalWindow || modalWindow.isDestroyed()) return;
|
|
||||||
if (restoreVisibleOverlayOnModalClose.size === 0) {
|
|
||||||
modalWindow.hide();
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user