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:
parent
ac9b02c2d8
commit
bb330d9718
1 changed files with 7 additions and 0 deletions
|
@ -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'));
|
||||
});
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue