version update alert
This commit is contained in:
parent
a2cb4629ae
commit
c22369fff4
|
@ -769,5 +769,23 @@
|
|||
"example": "1.2.3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateAvailableDesc": {
|
||||
"message": "Version $VERSION_NUM$ is ready to install. You must restart Bitwarden to complete the installation. Do you want to restart and update now?",
|
||||
"placeholders": {
|
||||
"version_num": {
|
||||
"content": "$1",
|
||||
"example": "1.2.3"
|
||||
}
|
||||
}
|
||||
},
|
||||
"updateAvailable": {
|
||||
"message": "Update Available"
|
||||
},
|
||||
"update": {
|
||||
"message": "Update"
|
||||
},
|
||||
"later": {
|
||||
"message": "Later"
|
||||
}
|
||||
}
|
||||
|
|
|
@ -26,7 +26,7 @@ const i18nService = new I18nService('en', './locales/');
|
|||
const storageService = new DesktopStorageService();
|
||||
const messagingService = new DesktopMainMessagingService(windowMain, messagingMain);
|
||||
|
||||
const updaterMain = new UpdaterMain();
|
||||
const updaterMain = new UpdaterMain(windowMain, i18nService);
|
||||
const menuMain = new MenuMain(windowMain, updaterMain, i18nService, messagingService);
|
||||
const powerMonitorMain = new PowerMonitorMain(storageService, messagingService);
|
||||
|
||||
|
|
|
@ -1,12 +1,35 @@
|
|||
import { dialog } from 'electron';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
|
||||
import { WindowMain } from './window.main';
|
||||
|
||||
import { I18nService } from 'jslib/abstractions/i18n.service';
|
||||
|
||||
const UpdaterCheckInitalDelay = 5 * 1000; // 5 seconds
|
||||
const UpdaterCheckInterval = 12 * 60 * 60 * 1000; // 12 hours
|
||||
|
||||
export class UpdaterMain {
|
||||
constructor(private windowMain: WindowMain, private i18nService: I18nService) { }
|
||||
|
||||
async init() {
|
||||
global.setTimeout(async () => await this.checkForUpdate(), UpdaterCheckInitalDelay);
|
||||
global.setInterval(async () => await this.checkForUpdate(), UpdaterCheckInterval);
|
||||
|
||||
autoUpdater.on('update-downloaded', (info) => {
|
||||
const result = dialog.showMessageBox(this.windowMain.win, {
|
||||
type: 'info',
|
||||
title: this.i18nService.t('updateAvailable'),
|
||||
message: this.i18nService.t('updateAvailable'),
|
||||
detail: this.i18nService.t('updateAvailableDesc', info.version),
|
||||
buttons: [this.i18nService.t('update'), this.i18nService.t('later')],
|
||||
cancelId: 1,
|
||||
defaultId: 0,
|
||||
noLink: true,
|
||||
});
|
||||
if (result === 0) {
|
||||
autoUpdater.quitAndInstall();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
async checkForUpdate() {
|
||||
|
|
Loading…
Reference in New Issue