Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix relaunch all windows #1179

Merged
merged 2 commits into from
Oct 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 21 additions & 2 deletions emain/emain-viewmgr.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,13 @@ import { debounce } from "throttle-debounce";
import { ClientService, FileService, ObjectService, WindowService } from "../frontend/app/store/services";
import * as keyutil from "../frontend/util/keyutil";
import { configureAuthKeyRequestInjection } from "./authkey";
import { getGlobalIsQuitting, getGlobalIsStarting, setWasActive, setWasInFg } from "./emain-activity";
import {
getGlobalIsQuitting,
getGlobalIsRelaunching,
getGlobalIsStarting,
setWasActive,
setWasInFg,
} from "./emain-activity";
import {
delay,
ensureBoundsAreVisible,
Expand Down Expand Up @@ -157,6 +163,7 @@ export function destroyWindow(waveWindow: WaveBrowserWindow) {
if (waveWindow == null) {
return;
}
console.log("destroy win", waveWindow.waveWindowId);
for (const tabView of waveWindow.allTabViews.values()) {
destroyTab(tabView);
}
Expand All @@ -167,6 +174,7 @@ export function destroyTab(tabView: WaveTabView) {
if (tabView == null) {
return;
}
console.log("destroy tab", tabView.waveTabId);
tabView.webContents.close();
wcIdToWaveTabMap.delete(tabView.webContents.id);
removeWaveTabView(tabView.waveWindowId, tabView.waveTabId);
Expand Down Expand Up @@ -326,6 +334,7 @@ function createBaseWaveBrowserWindow(
fullConfig: FullConfigType,
opts: WindowOpts
): WaveBrowserWindow {
console.log("create win", waveWindow.oid);
let winWidth = waveWindow?.winsize?.width;
let winHeight = waveWindow?.winsize?.height;
let winPosX = waveWindow.pos.x;
Expand Down Expand Up @@ -429,6 +438,9 @@ function createBaseWaveBrowserWindow(
}
});
win.on("focus", () => {
if (getGlobalIsRelaunching()) {
return;
}
focusedWaveWindow = win;
console.log("focus win", win.waveWindowId);
ClientService.FocusWindow(win.waveWindowId);
Expand All @@ -439,7 +451,8 @@ function createBaseWaveBrowserWindow(
}
});
win.on("close", (e) => {
if (getGlobalIsQuitting() || updater?.status == "installing") {
console.log("win 'close' handler fired", win.waveWindowId);
if (getGlobalIsQuitting() || updater?.status == "installing" || getGlobalIsRelaunching()) {
return;
}
const numWindows = waveWindowMap.size;
Expand All @@ -457,14 +470,20 @@ function createBaseWaveBrowserWindow(
}
});
win.on("closed", () => {
console.log("win 'closed' handler fired", win.waveWindowId);
if (getGlobalIsQuitting() || updater?.status == "installing") {
return;
}
if (getGlobalIsRelaunching()) {
destroyWindow(win);
return;
}
const numWindows = waveWindowMap.size;
if (numWindows == 0) {
return;
}
if (!win.alreadyClosed) {
console.log("win removing window from backend DB", win.waveWindowId);
WindowService.CloseWindow(waveWindow.oid, true);
}
destroyWindow(win);
Expand Down
2 changes: 1 addition & 1 deletion emain/emain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -659,7 +659,7 @@ async function relaunchBrowserWindows(): Promise<void> {
setGlobalIsRelaunching(true);
const windows = getAllWaveWindows();
for (const window of windows) {
window.removeAllListeners();
console.log("relaunch -- closing window", window.waveWindowId);
window.close();
}
setGlobalIsRelaunching(false);
Expand Down
Loading