mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-10-27 11:35:23 -07:00
fix(plugins): skip modal teardown for stale plugin panel closes
handleModalClosed now reports whether teardown should continue. A late close notice for a replaced panel returns before the generic modal-close flow, so it no longer hides the modal window showing the newer panel.
This commit is contained in:
3 files changed
+26
-9
No files matched your search
+8
-3
@@ -6040,12 +6040,17 @@ const { registerIpcRuntimeHandlers } = composeIpcRuntimeHandlers({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
onOverlayModalClosed: (modal, senderWindow, instanceId) => {
|
onOverlayModalClosed: (modal, senderWindow, instanceId) => {
|
||||||
|
// A late close for a replaced plugin panel must not hide the panel now showing.
|
||||||
|
if (
|
||||||
|
modal === 'plugin-panel' &&
|
||||||
|
instanceId !== undefined &&
|
||||||
|
!pluginPanelRuntime.handleModalClosed(instanceId)
|
||||||
|
) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
if (modal === 'media-timing-review') {
|
if (modal === 'media-timing-review') {
|
||||||
void mediaTimingReviewRuntime.dispose();
|
void mediaTimingReviewRuntime.dispose();
|
||||||
}
|
}
|
||||||
if (modal === 'plugin-panel' && instanceId !== undefined) {
|
|
||||||
pluginPanelRuntime.handleModalClosed(instanceId);
|
|
||||||
}
|
|
||||||
if (modal === 'subtitle-sidebar' && senderWindow === overlayManager.getMainWindow()) {
|
if (modal === 'subtitle-sidebar' && senderWindow === overlayManager.getMainWindow()) {
|
||||||
subtitleSidebarRequestedOpen = false;
|
subtitleSidebarRequestedOpen = false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ test('closing from the overlay aborts the handle and ignores later updates', asy
|
|||||||
await new Promise((resolve) => setImmediate(resolve));
|
await new Promise((resolve) => setImmediate(resolve));
|
||||||
const sentBefore = h.sent.length;
|
const sentBefore = h.sent.length;
|
||||||
|
|
||||||
h.runtime.handleModalClosed(1);
|
assert.equal(h.runtime.handleModalClosed(1), true);
|
||||||
panel.update({ markdown: 'too late' });
|
panel.update({ markdown: 'too late' });
|
||||||
|
|
||||||
assert.equal(panel.signal.aborted, true);
|
assert.equal(panel.signal.aborted, true);
|
||||||
@@ -58,11 +58,17 @@ test('a late close acknowledgement for a replaced panel leaves the new panel ope
|
|||||||
first.close();
|
first.close();
|
||||||
const second = h.runtime.open({ title: 'Two', markdown: '' });
|
const second = h.runtime.open({ title: 'Two', markdown: '' });
|
||||||
|
|
||||||
h.runtime.handleModalClosed(1);
|
assert.equal(h.runtime.handleModalClosed(1), false, 'skip teardown of the newer panel');
|
||||||
|
|
||||||
assert.equal(second.signal.aborted, false);
|
assert.equal(second.signal.aborted, false);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('a close notice after the plugin closed its panel still tears the modal down', () => {
|
||||||
|
const h = createHarness(Promise.resolve(true));
|
||||||
|
h.runtime.open({ title: 'One', markdown: '' }).close();
|
||||||
|
|
||||||
|
assert.equal(h.runtime.handleModalClosed(1), true);
|
||||||
|
});
|
||||||
|
|
||||||
test('opening a new panel aborts the previous one', () => {
|
test('opening a new panel aborts the previous one', () => {
|
||||||
const h = createHarness(Promise.resolve(true));
|
const h = createHarness(Promise.resolve(true));
|
||||||
const first = h.runtime.open({ title: 'One', markdown: '' });
|
const first = h.runtime.open({ title: 'One', markdown: '' });
|
||||||
|
|||||||
@@ -103,9 +103,15 @@ export function createPluginPanelRuntime(deps: {
|
|||||||
};
|
};
|
||||||
},
|
},
|
||||||
|
|
||||||
/** The overlay closed `panelId`; a late notice for an already replaced panel is ignored. */
|
/**
|
||||||
handleModalClosed(panelId: number): void {
|
* The overlay closed `panelId`. Returns false for a late notice about a panel that a newer one
|
||||||
if (active?.panelId === panelId) finish(active);
|
* already replaced, so the caller skips the modal teardown that would hide the newer panel.
|
||||||
|
*/
|
||||||
|
handleModalClosed(panelId: number): boolean {
|
||||||
|
if (!active) return true;
|
||||||
|
if (active.panelId !== panelId) return false;
|
||||||
|
finish(active);
|
||||||
|
return true;
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Reference in new issue
Block a user