mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-30 07:21:32 -07:00
fix(overlay): Linux X11/XWayland stacking, stale pause state, multi-copy selector (#101)
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
type ReloadableWebContents = {
|
||||
isDestroyed?: () => boolean;
|
||||
isLoading?: () => boolean;
|
||||
once?: (event: 'did-finish-load', listener: () => void) => void;
|
||||
reload: () => void;
|
||||
};
|
||||
|
||||
@@ -8,6 +10,19 @@ type ReloadableOverlayWindow = {
|
||||
webContents?: ReloadableWebContents;
|
||||
};
|
||||
|
||||
function reloadWebContentsForYomitanContentScripts(
|
||||
webContents: ReloadableWebContents,
|
||||
logWarn?: (message: string, error: unknown) => void,
|
||||
): boolean {
|
||||
try {
|
||||
webContents.reload();
|
||||
return true;
|
||||
} catch (error) {
|
||||
logWarn?.('Failed to reload overlay window after Yomitan extension load.', error);
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
export function reloadOverlayWindowsForYomitanContentScripts(
|
||||
windows: ReloadableOverlayWindow[],
|
||||
logWarn?: (message: string, error: unknown) => void,
|
||||
@@ -23,12 +38,20 @@ export function reloadOverlayWindowsForYomitanContentScripts(
|
||||
if (!webContents || webContents.isDestroyed?.()) {
|
||||
continue;
|
||||
}
|
||||
if (webContents.isLoading?.()) {
|
||||
webContents.once?.('did-finish-load', () => {
|
||||
if (window.isDestroyed() || webContents.isDestroyed?.()) {
|
||||
return;
|
||||
}
|
||||
if (reloadWebContentsForYomitanContentScripts(webContents, logWarn)) {
|
||||
reloadCount += 1;
|
||||
}
|
||||
});
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
webContents.reload();
|
||||
if (reloadWebContentsForYomitanContentScripts(webContents, logWarn)) {
|
||||
reloadCount += 1;
|
||||
} catch (error) {
|
||||
logWarn?.('Failed to reload overlay window after Yomitan extension load.', error);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user