mirror of
https://gitlab.com/futo-org/fcast.git
synced 2025-06-24 21:25:23 +00:00
Added v2 update notification
This commit is contained in:
parent
cc07f95d23
commit
2fa6b6489b
1 changed files with 37 additions and 57 deletions
|
@ -1,4 +1,4 @@
|
|||
import { BrowserWindow, ipcMain, IpcMainEvent, nativeImage, Tray, Menu, dialog } from 'electron';
|
||||
import { BrowserWindow, ipcMain, IpcMainEvent, nativeImage, Tray, Menu, dialog, shell } from 'electron';
|
||||
import { TcpListenerService } from './TcpListenerService';
|
||||
import { PlayMessage, PlaybackErrorMessage, PlaybackUpdateMessage, VolumeUpdateMessage } from './Packets';
|
||||
import { DiscoveryService } from './DiscoveryService';
|
||||
|
@ -27,6 +27,21 @@ export default class Main {
|
|||
static proxyServerAddress: AddressInfo;
|
||||
static proxiedFiles: Map<string, { url: string, headers: { [key: string]: string } }> = new Map();
|
||||
|
||||
private static async updateNotify() {
|
||||
const upateURL = 'https://github.com/futo-org/fcast/releases';
|
||||
const updatePrompt = await dialog.showMessageBox({
|
||||
type: 'info',
|
||||
title: 'Major update available',
|
||||
message: 'Please visit https://fcast.org/ to download the latest update',
|
||||
buttons: ['Download', 'Later'],
|
||||
defaultId: 0
|
||||
});
|
||||
|
||||
if (updatePrompt.response === 0) {
|
||||
shell.openExternal(upateURL);
|
||||
}
|
||||
}
|
||||
|
||||
private static createTray() {
|
||||
const icon = (process.platform === 'win32') ? path.join(__dirname, 'app.ico') : path.join(__dirname, 'app.png');
|
||||
const trayicon = nativeImage.createFromPath(icon)
|
||||
|
@ -39,44 +54,7 @@ export default class Main {
|
|||
{
|
||||
label: 'Check for updates',
|
||||
click: async () => {
|
||||
try {
|
||||
const updater = new Updater(path.join(__dirname, '../'), 'https://releases.grayjay.app/fcastreceiver');
|
||||
if (await updater.update()) {
|
||||
const restartPrompt = await dialog.showMessageBox({
|
||||
type: 'info',
|
||||
title: 'Update completed',
|
||||
message: 'The application has been updated. Restart now to apply the changes.',
|
||||
buttons: ['Restart'],
|
||||
defaultId: 0
|
||||
});
|
||||
|
||||
console.log('Update completed');
|
||||
|
||||
// Restart the app if the user clicks the 'Restart' button
|
||||
if (restartPrompt.response === 0) {
|
||||
Main.application.relaunch();
|
||||
Main.application.exit(0);
|
||||
}
|
||||
} else {
|
||||
await dialog.showMessageBox({
|
||||
type: 'info',
|
||||
title: 'Already up-to-date',
|
||||
message: 'The application is already on the latest version.',
|
||||
buttons: ['OK'],
|
||||
defaultId: 0
|
||||
});
|
||||
}
|
||||
} catch (err) {
|
||||
await dialog.showMessageBox({
|
||||
type: 'error',
|
||||
title: 'Failed to update',
|
||||
message: 'The application failed to update.',
|
||||
buttons: ['OK'],
|
||||
defaultId: 0
|
||||
});
|
||||
|
||||
console.error('Failed to update:', err);
|
||||
}
|
||||
await Main.updateNotify();
|
||||
},
|
||||
},
|
||||
{
|
||||
|
@ -184,6 +162,8 @@ export default class Main {
|
|||
if (Main.shouldOpenMainWindow) {
|
||||
Main.openMainWindow();
|
||||
}
|
||||
|
||||
Main.updateNotify();
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue