mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-27 01:36:30 +02:00
refactor(desktop): extract auto-updater into modules/auto-updater.ts
This commit is contained in:
parent
35da1cf1b4
commit
d868464de7
2 changed files with 35 additions and 35 deletions
33
surfsense_desktop/src/modules/auto-updater.ts
Normal file
33
surfsense_desktop/src/modules/auto-updater.ts
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import { app, dialog } from 'electron';
|
||||
import { autoUpdater } from 'electron-updater';
|
||||
|
||||
export function setupAutoUpdater(): void {
|
||||
if (!app.isPackaged) return;
|
||||
|
||||
autoUpdater.autoDownload = true;
|
||||
|
||||
autoUpdater.on('update-available', (info) => {
|
||||
console.log(`Update available: ${info.version}`);
|
||||
});
|
||||
|
||||
autoUpdater.on('update-downloaded', (info) => {
|
||||
console.log(`Update downloaded: ${info.version}`);
|
||||
dialog.showMessageBox({
|
||||
type: 'info',
|
||||
buttons: ['Restart', 'Later'],
|
||||
defaultId: 0,
|
||||
title: 'Update Ready',
|
||||
message: `Version ${info.version} has been downloaded. Restart to apply the update.`,
|
||||
}).then(({ response }) => {
|
||||
if (response === 0) {
|
||||
autoUpdater.quitAndInstall();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
||||
autoUpdater.on('error', (err) => {
|
||||
console.error('Auto-updater error:', err);
|
||||
});
|
||||
|
||||
autoUpdater.checkForUpdates();
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue