mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-04-29 02:46:25 +02:00
33 lines
945 B
TypeScript
33 lines
945 B
TypeScript
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.log('Auto-updater: update check skipped —', err.message?.split('\n')[0]);
|
|
});
|
|
|
|
autoUpdater.checkForUpdates().catch(() => {});
|
|
}
|