Skip to content

Commit

Permalink
feat: add auto-updater to get notification for new releases
Browse files Browse the repository at this point in the history
  • Loading branch information
erdkse committed Aug 13, 2021
1 parent b842cd7 commit ada84c5
Show file tree
Hide file tree
Showing 4 changed files with 2,252 additions and 2,901 deletions.
22 changes: 22 additions & 0 deletions electron/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,10 @@ import * as path from 'path';
import * as isDev from 'electron-is-dev';
import installExtension, {REACT_DEVELOPER_TOOLS, REDUX_DEVTOOLS} from 'electron-devtools-installer';
import {execSync} from 'child_process';

import {APP_MIN_HEIGHT, APP_MIN_WIDTH} from '../src/constants/constants';

const {autoUpdater} = require('electron-updater'); // Hacky way to fix for `Conflicting definitions for 'node'` error
const ElectronStore = require('electron-store');

const userHomeDir = app.getPath('home');
Expand Down Expand Up @@ -54,6 +56,14 @@ ipcMain.on('run-helm', (event, args: any) => {
}
});

ipcMain.on('app_version', event => {
event.sender.send('app_version', {version: app.getVersion()});
});

// ipcMain.on('restart_app', () => {
// autoUpdater.quitAndInstall();
// });

function createWindow() {
const image = nativeImage.createFromPath(path.join(app.getAppPath(), '/public/icon.ico'));
const win = new BrowserWindow({
Expand Down Expand Up @@ -100,6 +110,18 @@ function createWindow() {
win.webContents.openDevTools();
}

win.once('ready-to-show', () => {
autoUpdater.checkForUpdatesAndNotify();
});

autoUpdater.on('update-available', () => {
win.webContents.send('update_available');
});

autoUpdater.on('update-downloaded', () => {
win.webContents.send('update_downloaded');
});

return win;
}

Expand Down
Loading

0 comments on commit ada84c5

Please sign in to comment.