Skip to content

Commit

Permalink
fix errors recreating electron window
Browse files Browse the repository at this point in the history
  • Loading branch information
imolorhe committed Nov 17, 2023
1 parent ac731b4 commit 3f0984b
Show file tree
Hide file tree
Showing 7 changed files with 153 additions and 119 deletions.
2 changes: 1 addition & 1 deletion packages/altair-app/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@
"babel-preset-react": "6.24.1",
"chai": "4.2.0",
"chai-as-promised": "7.1.1",
"electron": "^26.2.2",
"electron": "^27.1.0",
"eslint": "8.18.0",
"eslint-config-altair": "^5.2.10",
"eslint-config-prettier": "8.5.0",
Expand Down
2 changes: 1 addition & 1 deletion packages/altair-electron-interop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
"altair-graphql-core": "^5.2.10"
},
"devDependencies": {
"electron": "^26.2.2",
"electron": "^27.1.0",
"typescript": "4.9.5"
},
"license": "MIT",
Expand Down
2 changes: 1 addition & 1 deletion packages/altair-electron/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
"altair-graphql-core": "^5.2.10",
"devtron": "^1.4.0",
"dotenv": "^8.1.0",
"electron": "^26.2.2",
"electron": "^27.1.0",
"electron-builder": "^23.6.0",
"electron-builder-notarize": "^1.2.0",
"electron-chromedriver": "^14.0.0",
Expand Down
30 changes: 18 additions & 12 deletions packages/altair-electron/src/app/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,52 +4,58 @@ import { BrowserWindow, MenuItem } from 'electron';
import url from 'url';
import path from 'path';
import { getStaticDirectory } from '../utils';
import { WindowManager } from './window';

export class ActionManager {
constructor(private windowInstance: BrowserWindow) {}
constructor(private windowManager: WindowManager) {}

createTab() {
this.windowInstance.webContents.send('create-tab', true);
this.windowManager.getInstance()?.webContents.send('create-tab', true);
}

closeTab() {
this.windowInstance.webContents.send('close-tab', true);
this.windowManager.getInstance()?.webContents.send('close-tab', true);
}

nextTab() {
this.windowInstance.webContents.send('next-tab', true);
this.windowManager.getInstance()?.webContents.send('next-tab', true);
}

previousTab() {
this.windowInstance.webContents.send('previous-tab', true);
this.windowManager.getInstance()?.webContents.send('previous-tab', true);
}

reopenClosedTab() {
this.windowInstance.webContents.send('reopen-closed-tab', true);
this.windowManager
.getInstance()
?.webContents.send('reopen-closed-tab', true);
}

sendRequest() {
this.windowInstance.webContents.send('send-request', true);
this.windowManager.getInstance()?.webContents.send('send-request', true);
}

reloadDocs() {
this.windowInstance.webContents.send('reload-docs', true);
this.windowManager.getInstance()?.webContents.send('reload-docs', true);
}

showDocs() {
this.windowInstance.webContents.send('show-docs', true);
this.windowManager.getInstance()?.webContents.send('show-docs', true);
}

showSettings() {
this.windowInstance.webContents.send('show-settings', true);
this.windowManager.getInstance()?.webContents.send('show-settings', true);
}

importAppData() {
importBackupData(this.windowInstance);
const windowInstance = this.windowManager.getInstance();
if (windowInstance) {
importBackupData(windowInstance);
}
}

exportAppData() {
this.windowInstance.webContents.send('export-app-data', true);
this.windowManager.getInstance()?.webContents.send('export-app-data', true);
}

checkForUpdates(menuItem: MenuItem) {
Expand Down
6 changes: 3 additions & 3 deletions packages/altair-electron/src/app/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,11 +38,11 @@ export class ElectronApp {
this.manageEvents();
}

manageEvents() {
async manageEvents() {
// This method will be called when Electron has finished
// initialization and is ready to create browser windows.
// Some APIs can only be used after this event occurs.
app.on('ready', async () => {
app.whenReady().then(async () => {
const settings = store.get('settings');
log(settings);
if (settings) {
Expand Down Expand Up @@ -80,7 +80,7 @@ export class ElectronApp {
log(proxy, proxyConfig);
}
try {
this.windowManager.createWindow();
await this.windowManager.createWindow();
} catch (err) {
log('Error creating window', err);
dialog.showErrorBox(
Expand Down
Loading

0 comments on commit 3f0984b

Please sign in to comment.