mirror of
https://github.com/wavetermdev/waveterm.git
synced 2025-03-02 04:02:13 +01:00
minor v10 cleanup (waveReadyPromise, focusedWaveWindow) (#1456)
This commit is contained in:
parent
c4fce5acc5
commit
f1a590f51b
@ -23,7 +23,10 @@ export type WindowOpts = {
|
|||||||
};
|
};
|
||||||
|
|
||||||
export const waveWindowMap = new Map<string, WaveBrowserWindow>(); // waveWindowId -> WaveBrowserWindow
|
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;
|
let cachedClientId: string = null;
|
||||||
|
|
||||||
@ -62,7 +65,6 @@ function showCloseConfirmDialog(workspace: Workspace): boolean {
|
|||||||
export class WaveBrowserWindow extends BaseWindow {
|
export class WaveBrowserWindow extends BaseWindow {
|
||||||
waveWindowId: string;
|
waveWindowId: string;
|
||||||
workspaceId: string;
|
workspaceId: string;
|
||||||
waveReadyPromise: Promise<void>;
|
|
||||||
allLoadedTabViews: Map<string, WaveTabView>;
|
allLoadedTabViews: Map<string, WaveTabView>;
|
||||||
activeTabView: WaveTabView;
|
activeTabView: WaveTabView;
|
||||||
private canClose: boolean;
|
private canClose: boolean;
|
||||||
@ -211,12 +213,7 @@ export class WaveBrowserWindow extends BaseWindow {
|
|||||||
setWasActive(true);
|
setWasActive(true);
|
||||||
});
|
});
|
||||||
this.on("blur", () => {
|
this.on("blur", () => {
|
||||||
if (this.isDestroyed()) {
|
// nothing for now
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (focusedWaveWindow == this) {
|
|
||||||
focusedWaveWindow = null;
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
this.on("close", (e) => {
|
this.on("close", (e) => {
|
||||||
if (this.canClose) {
|
if (this.canClose) {
|
||||||
@ -470,6 +467,9 @@ export class WaveBrowserWindow extends BaseWindow {
|
|||||||
private async processActionQueue() {
|
private async processActionQueue() {
|
||||||
while (this.actionQueue.length > 0) {
|
while (this.actionQueue.length > 0) {
|
||||||
try {
|
try {
|
||||||
|
if (this.isDestroyed()) {
|
||||||
|
break;
|
||||||
|
}
|
||||||
const entry = this.actionQueue[0];
|
const entry = this.actionQueue[0];
|
||||||
let tabId: string = null;
|
let tabId: string = null;
|
||||||
// have to use "===" here to get the typechecker to work :/
|
// have to use "===" here to get the typechecker to work :/
|
||||||
@ -725,7 +725,6 @@ export async function createNewWaveWindow() {
|
|||||||
const existingWindowData = (await ObjectService.GetObject("window:" + existingWindowId)) as WaveWindow;
|
const existingWindowData = (await ObjectService.GetObject("window:" + existingWindowId)) as WaveWindow;
|
||||||
if (existingWindowData != null) {
|
if (existingWindowData != null) {
|
||||||
const win = await createBrowserWindow(existingWindowData, fullConfig, { unamePlatform });
|
const win = await createBrowserWindow(existingWindowData, fullConfig, { unamePlatform });
|
||||||
await win.waveReadyPromise;
|
|
||||||
win.show();
|
win.show();
|
||||||
recreatedWindow = true;
|
recreatedWindow = true;
|
||||||
}
|
}
|
||||||
@ -736,7 +735,6 @@ export async function createNewWaveWindow() {
|
|||||||
}
|
}
|
||||||
console.log("creating new window");
|
console.log("creating new window");
|
||||||
const newBrowserWindow = await createBrowserWindow(null, fullConfig, { unamePlatform });
|
const newBrowserWindow = await createBrowserWindow(null, fullConfig, { unamePlatform });
|
||||||
await newBrowserWindow.waveReadyPromise;
|
|
||||||
newBrowserWindow.show();
|
newBrowserWindow.show();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -768,7 +766,6 @@ export async function relaunchBrowserWindows() {
|
|||||||
wins.push(win);
|
wins.push(win);
|
||||||
}
|
}
|
||||||
for (const win of wins) {
|
for (const win of wins) {
|
||||||
await win.waveReadyPromise;
|
|
||||||
console.log("show window", win.waveWindowId);
|
console.log("show window", win.waveWindowId);
|
||||||
win.show();
|
win.show();
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,6 @@ function handleWSEvent(evtMsg: WSEventType) {
|
|||||||
}
|
}
|
||||||
const fullConfig = await services.FileService.GetFullConfig();
|
const fullConfig = await services.FileService.GetFullConfig();
|
||||||
const newWin = await createBrowserWindow(windowData, fullConfig, { unamePlatform });
|
const newWin = await createBrowserWindow(windowData, fullConfig, { unamePlatform });
|
||||||
await newWin.waveReadyPromise;
|
|
||||||
newWin.show();
|
newWin.show();
|
||||||
} else if (evtMsg.eventtype == "electron:closewindow") {
|
} else if (evtMsg.eventtype == "electron:closewindow") {
|
||||||
console.log("electron:closewindow", evtMsg.data);
|
console.log("electron:closewindow", evtMsg.data);
|
||||||
@ -378,6 +377,9 @@ function saveImageFileWithNativeDialog(defaultFileName: string, mimeType: string
|
|||||||
defaultFileName = "image";
|
defaultFileName = "image";
|
||||||
}
|
}
|
||||||
const ww = focusedWaveWindow;
|
const ww = focusedWaveWindow;
|
||||||
|
if (ww == null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const mimeToExtension: { [key: string]: string } = {
|
const mimeToExtension: { [key: string]: string } = {
|
||||||
"image/png": "png",
|
"image/png": "png",
|
||||||
"image/jpeg": "jpg",
|
"image/jpeg": "jpg",
|
||||||
|
@ -164,7 +164,9 @@ export class Updater {
|
|||||||
type: "info",
|
type: "info",
|
||||||
message: "There are currently no updates available.",
|
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.
|
// Only update the last check time if this is an automatic check. This ensures the interval remains consistent.
|
||||||
|
Loading…
Reference in New Issue
Block a user