removed debugging logic

This commit is contained in:
Abhinav-grd 2021-07-16 11:45:22 +05:30
parent 3443909d3d
commit 3c8af97f69
2 changed files with 1 additions and 72 deletions

View file

@ -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({

View file

@ -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');
});
}