mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-03-01 18:22:41 -08:00
refactor: extract overlay visibility and ipc helper services
This commit is contained in:
26
src/core/services/overlay-send-service.ts
Normal file
26
src/core/services/overlay-send-service.ts
Normal file
@@ -0,0 +1,26 @@
|
||||
import { BrowserWindow } from "electron";
|
||||
|
||||
export function sendToVisibleOverlayService(options: {
|
||||
mainWindow: BrowserWindow | null;
|
||||
visibleOverlayVisible: boolean;
|
||||
setVisibleOverlayVisible: (visible: boolean) => void;
|
||||
channel: string;
|
||||
payload?: unknown;
|
||||
restoreOnModalClose?: string;
|
||||
addRestoreFlag: (modal: string) => void;
|
||||
}): boolean {
|
||||
if (!options.mainWindow || options.mainWindow.isDestroyed()) return false;
|
||||
const wasVisible = options.visibleOverlayVisible;
|
||||
if (!options.visibleOverlayVisible) {
|
||||
options.setVisibleOverlayVisible(true);
|
||||
}
|
||||
if (!wasVisible && options.restoreOnModalClose) {
|
||||
options.addRestoreFlag(options.restoreOnModalClose);
|
||||
}
|
||||
if (options.payload === undefined) {
|
||||
options.mainWindow.webContents.send(options.channel);
|
||||
} else {
|
||||
options.mainWindow.webContents.send(options.channel, options.payload);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
Reference in New Issue
Block a user