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 { TcpListenerService } from './TcpListenerService';
|
||||||
import { PlayMessage, PlaybackErrorMessage, PlaybackUpdateMessage, VolumeUpdateMessage } from './Packets';
|
import { PlayMessage, PlaybackErrorMessage, PlaybackUpdateMessage, VolumeUpdateMessage } from './Packets';
|
||||||
import { DiscoveryService } from './DiscoveryService';
|
import { DiscoveryService } from './DiscoveryService';
|
||||||
|
@ -27,6 +27,21 @@ export default class Main {
|
||||||
static proxyServerAddress: AddressInfo;
|
static proxyServerAddress: AddressInfo;
|
||||||
static proxiedFiles: Map<string, { url: string, headers: { [key: string]: string } }> = new Map();
|
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() {
|
private static createTray() {
|
||||||
const icon = (process.platform === 'win32') ? path.join(__dirname, 'app.ico') : path.join(__dirname, 'app.png');
|
const icon = (process.platform === 'win32') ? path.join(__dirname, 'app.ico') : path.join(__dirname, 'app.png');
|
||||||
const trayicon = nativeImage.createFromPath(icon)
|
const trayicon = nativeImage.createFromPath(icon)
|
||||||
|
@ -39,44 +54,7 @@ export default class Main {
|
||||||
{
|
{
|
||||||
label: 'Check for updates',
|
label: 'Check for updates',
|
||||||
click: async () => {
|
click: async () => {
|
||||||
try {
|
await Main.updateNotify();
|
||||||
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);
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
|
@ -184,6 +162,8 @@ export default class Main {
|
||||||
if (Main.shouldOpenMainWindow) {
|
if (Main.shouldOpenMainWindow) {
|
||||||
Main.openMainWindow();
|
Main.openMainWindow();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Main.updateNotify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue