Skip to content

Commit

Permalink
Fixed MacOS update alerts
Browse files Browse the repository at this point in the history
  • Loading branch information
LeMocha committed Jul 7, 2024
1 parent 28f9e84 commit 6869c06
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 19 deletions.
18 changes: 17 additions & 1 deletion src/app.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* @license CC-BY-NC 4.0 - https://creativecommons.org/licenses/by-nc/4.0/
*/

const { app, ipcMain } = require('electron');
const { app, ipcMain, shell, dialog } = require('electron');
const { Microsoft } = require('minecraft-java-core');
const { autoUpdater } = require('electron-updater')

Expand Down Expand Up @@ -60,6 +60,22 @@ ipcMain.handle('relaunch-app', () => {
app.exit();
});

ipcMain.handle('show-mac-update-dialog', async (event) => {
const options = {
type: 'info',
buttons: ['Télécharger la mise à jour', 'Fermer'],
message: 'Une nouvelle mise à jour est disponible. Veuillez télécharger la dernière mise à jour.'
};

const response = await dialog.showMessageBox(options);
if (response.response === 0) {
shell.openExternal('https://github.com/Almyria/launcher/releases');
app.quit();
} else {
app.quit();
}
});

app.on('window-all-closed', () => {
if (process.platform !== 'darwin') app.quit();
});
Expand Down
20 changes: 2 additions & 18 deletions src/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
*/

'use strict';
const { ipcRenderer, dialog, shell, app } = require('electron');
const { ipcRenderer } = require('electron');
const os = require('os');
import { config } from './utils.js';

Expand Down Expand Up @@ -54,22 +54,6 @@ class Splash {
this.checkUpdate();
}

showMacOSUpdateDialog() {
const options = {
type: 'info',
buttons: ['Télécharger la mise à jour', 'Fermer'],
message: 'Une nouvelle mise à jour est disponible. Veuillez télécharger la dernière mise à jour.'
};

dialog.showMessageBox(options).then(response => {
if (response.response === 0) {
shell.openExternal('https://github.com/Almyria/launcher/releases');
} else {
app.quit();
}
});
}

async checkUpdate() {
if (dev) return this.startLauncher();
this.setStatus(`Recherche de mise à jour...`);
Expand All @@ -84,7 +68,7 @@ class Splash {
ipcRenderer.on('updateAvailable', () => {
if (os.platform() === 'darwin') { // if the OS is MacOS
this.setStatus(`Mise à jour disponible !`);
this.showMacOSUpdateDialog();
ipcRenderer.invoke('show-mac-update-dialog');
} else {
this.setStatus(`Mise à jour disponible !`);
this.toggleProgress();
Expand Down

0 comments on commit 6869c06

Please sign in to comment.