Skip to content

Commit

Permalink
Part 2 of precedent commit
Browse files Browse the repository at this point in the history
  • Loading branch information
LeMocha committed Jul 7, 2024
1 parent 6a7a9c9 commit 9a69800
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
28 changes: 25 additions & 3 deletions src/assets/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

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

let dev = process.env.NODE_ENV === 'dev';
Expand Down Expand Up @@ -53,6 +54,22 @@ 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 @@ -65,9 +82,14 @@ class Splash {
});

ipcRenderer.on('updateAvailable', () => {
this.setStatus(`Mise à jour disponible !`);
this.toggleProgress();
ipcRenderer.send('start-update');
if (os.platform() === 'darwin') { // if the OS is MacOS
this.setStatus(`Mise à jour disponible !`);
this.showMacOSUpdateDialog();
} else {
this.setStatus(`Mise à jour disponible !`);
this.toggleProgress();
ipcRenderer.send('start-update');
}
})

ipcRenderer.on('download-progress', (event, progress) => {
Expand Down
2 changes: 1 addition & 1 deletion src/assets/js/panels/home.js
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ class Home {
fetch(`${pkg.cdn_url}/files_to_delete.json`)
.then(response => response.json())
.then(filesToDelete => {
const appDataPath = path.join(dataDirectory, '.almyriacraft-s7');
const appDataPath = `${dataDirectory}/${process.platform == 'darwin' ? self.config.dataDirectory : `.${self.config.dataDirectory}`}`;;

for (const file of filesToDelete) {
const filePath = path.join(appDataPath, file);
Expand Down
4 changes: 2 additions & 2 deletions src/assets/js/panels/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ class Settings {
let confirmation = confirm("Êtes-vous sûr de vouloir réinitialiser le dossier du jeu ?");
if(!confirmation) return;

const directoryPath = path.join(dataDirectory, '.almyriacraft-s7');
const directoryPath = `${dataDirectory}/${process.platform == 'darwin' ? this.config.dataDirectory : `.${this.config.dataDirectory}`}`;

// Sélectionner la classe modal et l'afficher
let modal = document.getElementById('alert-modal-deletion');
Expand All @@ -223,7 +223,7 @@ class Settings {
modal.style.display = 'block';

setTimeout(() => {
const directoryPath = path.join(dataDirectory, '.almyriacraft-s7');
const directoryPath = `${dataDirectory}/${process.platform == 'darwin' ? this.config.dataDirectory : `.${this.config.dataDirectory}`}`;;

if (fs.existsSync(directoryPath)) {
fs.rmdirSync(directoryPath, { recursive: true });
Expand Down

0 comments on commit 9a69800

Please sign in to comment.