mirror of
https://github.com/DeNNiiInc/dbgate.git
synced 2026-04-19 02:36:00 +00:00
checking for update
This commit is contained in:
48
packages/web/src/utility/appUpdate.ts
Normal file
48
packages/web/src/utility/appUpdate.ts
Normal file
@@ -0,0 +1,48 @@
|
||||
import { appUpdaterActive, appUpdateStatus } from '../stores';
|
||||
import getElectron from './getElectron';
|
||||
import { showSnackbar } from './snackbar';
|
||||
|
||||
export function initializeAppUpdates() {
|
||||
const electron = getElectron();
|
||||
if (!electron) {
|
||||
return;
|
||||
}
|
||||
|
||||
electron.addEventListener('update-available', (e, version) => {
|
||||
showSnackbar({
|
||||
message: `Update available: ${version}`,
|
||||
allowClose: true,
|
||||
buttons: [
|
||||
{
|
||||
label: 'Download',
|
||||
onClick: () => {
|
||||
electron.send('downloadUpdate');
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
electron.addEventListener('app-update-status', (e, text) => {
|
||||
appUpdateStatus.set(text);
|
||||
});
|
||||
|
||||
electron.addEventListener('downloaded-new-version', (e, version) => {
|
||||
showSnackbar({
|
||||
message: `New version ${version} downloaded`,
|
||||
allowClose: true,
|
||||
buttons: [
|
||||
{
|
||||
label: 'Restart',
|
||||
onClick: () => {
|
||||
electron.send('applyUpdate');
|
||||
},
|
||||
},
|
||||
],
|
||||
});
|
||||
});
|
||||
|
||||
electron.addEventListener('setAppUpdaterActive', (e, error) => {
|
||||
appUpdaterActive.set(true);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user