Skip to content
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
19 changes: 8 additions & 11 deletions emain/emain-window.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,10 @@ export type WindowOpts = {
};

export const waveWindowMap = new Map<string, WaveBrowserWindow>(); // waveWindowId -> WaveBrowserWindow
export let focusedWaveWindow = null; // on blur we do not set this to null (but on destroy we do)

// on blur we do not set this to null (but on destroy we do), so this tracks the *last* focused window
// e.g. it persists when the app itself is not focused
export let focusedWaveWindow: WaveBrowserWindow = null;

let cachedClientId: string = null;

Expand Down Expand Up @@ -58,7 +61,6 @@ type WindowActionQueueEntry =
export class WaveBrowserWindow extends BaseWindow {
waveWindowId: string;
workspaceId: string;
waveReadyPromise: Promise<void>;
allLoadedTabViews: Map<string, WaveTabView>;
activeTabView: WaveTabView;
private canClose: boolean;
Expand Down Expand Up @@ -207,12 +209,7 @@ export class WaveBrowserWindow extends BaseWindow {
setWasActive(true);
});
this.on("blur", () => {
if (this.isDestroyed()) {
return;
}
if (focusedWaveWindow == this) {
focusedWaveWindow = null;
}
// nothing for now
});
this.on("close", (e) => {
if (this.canClose) {
Expand Down Expand Up @@ -471,6 +468,9 @@ export class WaveBrowserWindow extends BaseWindow {
private async processActionQueue() {
while (this.actionQueue.length > 0) {
try {
if (this.isDestroyed()) {
break;
}
const entry = this.actionQueue[0];
let tabId: string = null;
// have to use "===" here to get the typechecker to work :/
Expand Down Expand Up @@ -711,7 +711,6 @@ export async function createNewWaveWindow() {
const existingWindowData = (await ObjectService.GetObject("window:" + existingWindowId)) as WaveWindow;
if (existingWindowData != null) {
const win = await createBrowserWindow(existingWindowData, fullConfig, { unamePlatform });
await win.waveReadyPromise;
win.show();
recreatedWindow = true;
}
Expand All @@ -722,7 +721,6 @@ export async function createNewWaveWindow() {
}
console.log("creating new window");
const newBrowserWindow = await createBrowserWindow(null, fullConfig, { unamePlatform });
await newBrowserWindow.waveReadyPromise;
newBrowserWindow.show();
}

Expand Down Expand Up @@ -754,7 +752,6 @@ export async function relaunchBrowserWindows() {
wins.push(win);
}
for (const win of wins) {
await win.waveReadyPromise;
console.log("show window", win.waveWindowId);
win.show();
}
Expand Down
4 changes: 3 additions & 1 deletion emain/emain.ts
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,6 @@ function handleWSEvent(evtMsg: WSEventType) {
}
const fullConfig = await services.FileService.GetFullConfig();
const newWin = await createBrowserWindow(windowData, fullConfig, { unamePlatform });
await newWin.waveReadyPromise;
newWin.show();
} else if (evtMsg.eventtype == "electron:closewindow") {
console.log("electron:closewindow", evtMsg.data);
Expand Down Expand Up @@ -378,6 +377,9 @@ function saveImageFileWithNativeDialog(defaultFileName: string, mimeType: string
defaultFileName = "image";
}
const ww = focusedWaveWindow;
if (ww == null) {
return;
}
const mimeToExtension: { [key: string]: string } = {
"image/png": "png",
"image/jpeg": "jpg",
Expand Down
4 changes: 3 additions & 1 deletion emain/updater.ts
Original file line number Diff line number Diff line change
Expand Up @@ -164,7 +164,9 @@ export class Updater {
type: "info",
message: "There are currently no updates available.",
};
dialog.showMessageBox(focusedWaveWindow, dialogOpts);
if (focusedWaveWindow) {
dialog.showMessageBox(focusedWaveWindow, dialogOpts);
}
}

// Only update the last check time if this is an automatic check. This ensures the interval remains consistent.
Expand Down