()
| 867 | } |
| 868 | |
| 869 | export async function relaunchBrowserWindows() { |
| 870 | console.log("relaunchBrowserWindows"); |
| 871 | setGlobalIsRelaunching(true); |
| 872 | const windows = getAllWaveWindows(); |
| 873 | if (windows.length > 0) { |
| 874 | for (const window of windows) { |
| 875 | console.log("relaunch -- closing window", window.waveWindowId); |
| 876 | window.close(); |
| 877 | } |
| 878 | await delay(1200); |
| 879 | } |
| 880 | setGlobalIsRelaunching(false); |
| 881 | |
| 882 | const clientData = await ClientService.GetClientData(); |
| 883 | const fullConfig = await RpcApi.GetFullConfigCommand(ElectronWshClient); |
| 884 | const windowIds = clientData.windowids ?? []; |
| 885 | const wins: WaveBrowserWindow[] = []; |
| 886 | const isFirstRelaunch = !hasCompletedFirstRelaunch; |
| 887 | const primaryWindowId = windowIds.length > 0 ? windowIds[0] : null; |
| 888 | for (const windowId of windowIds.slice().reverse()) { |
| 889 | const windowData: WaveWindow = await WindowService.GetWindow(windowId); |
| 890 | if (windowData == null) { |
| 891 | console.log("relaunch -- window data not found, closing window", windowId); |
| 892 | await WindowService.CloseWindow(windowId, true); |
| 893 | continue; |
| 894 | } |
| 895 | const isPrimaryStartupWindow = isFirstRelaunch && windowId === primaryWindowId; |
| 896 | console.log( |
| 897 | "relaunch -- creating window", |
| 898 | windowId, |
| 899 | windowData, |
| 900 | isPrimaryStartupWindow ? "(primary startup)" : "" |
| 901 | ); |
| 902 | const win = await createBrowserWindow(windowData, fullConfig, { |
| 903 | unamePlatform, |
| 904 | isPrimaryStartupWindow, |
| 905 | foregroundWindow: windowId === primaryWindowId, |
| 906 | }); |
| 907 | wins.push(win); |
| 908 | if (windowId === primaryWindowId) { |
| 909 | quakeWindow = win; |
| 910 | console.log("designated quake window", win.waveWindowId); |
| 911 | } |
| 912 | } |
| 913 | hasCompletedFirstRelaunch = true; |
| 914 | for (const win of wins) { |
| 915 | console.log("show window", win.waveWindowId); |
| 916 | win.show(); |
| 917 | } |
| 918 | } |
| 919 | |
| 920 | function getDisplayForQuakeToggle() { |
| 921 | // We cannot reliably query the OS-wide active window in Electron. |
no test coverage detected