const {autoUpdater} = require("electron-updater");
autoUpdater.on('checking-for-update', () => {
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'toast',
message: global.p3x.onenote.lang.updater["checking-for-update"]
})
})
autoUpdater.on('update-available', (info) => {
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'toast',
message: global.p3x.onenote.lang.updater["update-available"]
})
})
autoUpdater.on('update-not-available', (info) => {
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'toast',
message: global.p3x.onenote.lang.updater["update-not-available"]
})
})
autoUpdater.on('error', (error) => {
console.error(error)
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'toast',
error: error,
message: global.p3x.onenote.lang.updater["error"]({
errorMessage: error.message.split('\n')[0]
})
})
})
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 + ')';
*/
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'toast',
message: p3x.onenote.lang.updater["download-progress"]({
progressObj: progressObj,
})
})
})
autoUpdater.on('update-downloaded', (info) => {
global.p3x.onenote.window.onenote.webContents.send('p3x-onenote-action', {
action: 'toast',
message: p3x.onenote.lang.updater["update-downloaded"],
})
});
autoUpdater.checkForUpdatesAndNotify();