Skip to content

Commit

Permalink
[AMR-92] fix: window is null typeerror
Browse files Browse the repository at this point in the history
  • Loading branch information
N0chteil committed Aug 29, 2023
1 parent 26c499a commit a822ce2
Showing 1 changed file with 21 additions and 11 deletions.
32 changes: 21 additions & 11 deletions src/managers/browser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,16 @@ export class Browser {

if (process.platform === "darwin") {
this.window.on("hide", () => {
const isVisible = process.platform === "darwin" ? this.window.isVisibleOnAllWorkspaces() : this.window.isVisible();

if (!this.window.isMinimized() || (!isVisible && !this.window.isFocusable())) app.dock.hide();
const isVisible =
process.platform === "darwin"
? this.window.isVisibleOnAllWorkspaces()
: this.window.isVisible();

if (
!this.window.isMinimized() ||
(!isVisible && !this.window.isFocusable())
)
app.dock.hide();
});
this.window.on("show", app.dock.show);
}
Expand All @@ -80,46 +87,49 @@ export class Browser {

break;
case "hide":
this.window.hide();
this.window?.hide();

break;
case "close":
this.window.close();
this.window?.close();

break;
case "minimize":
this.window.minimize();
this.window?.minimize();

break;
case "maximize":
this.window.maximize();
this.window?.maximize();

break;
case "restore":
this.window.restore();
this.window?.restore();

break;
case "reload":
if (!app.isPackaged) await this.copyBrowserFiles();
this.window.reload();
this.window?.reload();

break;
}
}

saveWindowState() {
if (!this.window) return;
setConfig("windowState", this.window.getBounds());
}

send(channel: string, ...args: any[]) {
if (!this.window) return;

setTimeout(
() => this.window.webContents.send(channel, ...args),
this.isReady ? 200 : 2500
);
}

checkAwaits() {
if (Browser.awaitsSend.length > 0 && this.window.isVisible()) {
if (Browser.awaitsSend.length > 0 && this.window?.isVisible()) {
Browser.awaitsSend.forEach((data) => {
this.send(data.channel, ...data.args);
});
Expand All @@ -129,7 +139,7 @@ export class Browser {
async copyBrowserFiles() {
if (app.isPackaged) return;

return new Promise(function(resolve) {
return new Promise(function (resolve) {
const execute = exec(
"npm run copy && cd src/browser/renderer/ && tsc",
(error, _stdout, stderr) => {
Expand Down

0 comments on commit a822ce2

Please sign in to comment.