diff --git a/src/appUpdater.ts b/src/appUpdater.ts index 589c5ec32..5cdfc3a12 100644 --- a/src/appUpdater.ts +++ b/src/appUpdater.ts @@ -1,35 +1,14 @@ -import { BrowserWindow, dialog } from "electron" +import { dialog } from "electron" import { autoUpdater } from "electron-updater" import log from "electron-log" -import { createDefaultWindow, setUpVersionInfoWindow } from "./util"; class AppUpdater { - win:BrowserWindow; constructor() { log.transports.file.level = "debug" autoUpdater.logger = log; } - initUpdater(){ - this.initWin(); - setUpVersionInfoWindow(this.win); - } - - initWin(){ - this.win=createDefaultWindow(); - this.win.on('closed', () => { - this.win=null; - }); - } - - destroyUpdateWindow(){ - this.win=null; - } - async checkForUpdate(){ - if(!this.win){ - this.initUpdater(); - } await autoUpdater.checkForUpdatesAndNotify() autoUpdater.on('update-downloaded', () => { dialog.showMessageBox({ diff --git a/src/util.ts b/src/util.ts deleted file mode 100644 index 3529f0d21..000000000 --- a/src/util.ts +++ /dev/null @@ -1,50 +0,0 @@ -import { app, BrowserWindow } from "electron"; -import log from "electron-log"; -import { autoUpdater } from "electron-updater"; -import * as isDev from 'electron-is-dev'; -import * as path from 'path'; - - -export function sendStatusToWindow(win:BrowserWindow, text:string) { - log.info(text); - win.webContents.send('message', text); - } - -export function createDefaultWindow() { - const win = new BrowserWindow({webPreferences:{nodeIntegration:true}}); - win.webContents.openDevTools(); - if (isDev) { - win.loadFile(`../build/version.html`); - } else { - win.loadURL( - `file://${path.join(process.resourcesPath, 'version.html')}#v${app.getVersion()}}` - ); - } - return win; -} - -export function setUpVersionInfoWindow(win:BrowserWindow){ - - - autoUpdater.on('checking-for-update', () => { - sendStatusToWindow(win,'Checking for update...'); - }) - autoUpdater.on('update-available', (info) => { - sendStatusToWindow(win,'Update available.'); - }) - autoUpdater.on('update-not-available', (info) => { - sendStatusToWindow(win,'Update not available.'); - }) - autoUpdater.on('error', (err) => { - sendStatusToWindow(win,'Error in auto-updater. ' + err); - }) - autoUpdater.on('download-progress', (progressObj) => { - let log_message = "Download speed: " + progressObj.bytesPerSecond; - log_message = log_message + ' - Downloaded ' + progressObj.percent + '%'; - log_message = log_message + ' (' + progressObj.transferred + "/" + progressObj.total + ')'; - sendStatusToWindow(win,log_message); - }) - autoUpdater.on('update-downloaded', (info) => { - sendStatusToWindow(win,'Update downloaded'); - }); -} \ No newline at end of file