1
0
Fork 0
mirror of https://gitlab.com/futo-org/fcast.git synced 2025-06-24 21:25:23 +00:00

Electron: Cache network interfaces for faster main window loading

This commit is contained in:
Michael Hollister 2025-05-01 12:18:59 -05:00
parent ac9b02c2d8
commit bb330d9718

View file

@ -24,6 +24,8 @@ export class Main {
static discoveryService: DiscoveryService;
static tray: Tray;
private static cachedInterfaces = null;
private static toggleMainWindow() {
if (Main.mainWindow) {
Main.mainWindow.close();
@ -286,6 +288,7 @@ export class Main {
// eslint-disable-next-line @typescript-eslint/no-explicit-any
ipcMain.on('network-changed', (event: IpcMainEvent, value: any) => {
Main.cachedInterfaces = value;
Main.mainWindow?.webContents?.send("device-info", { name: os.hostname(), interfaces: value });
});
@ -350,6 +353,10 @@ export class Main {
Main.mainWindow.show();
Main.mainWindow.on('ready-to-show', () => {
if (Main.cachedInterfaces) {
Main.mainWindow?.webContents?.send("device-info", { name: os.hostname(), interfaces: Main.cachedInterfaces });
}
networkWorker.loadFile(path.join(__dirname, 'main/worker.html'));
});
}