Skip to content

Commit

Permalink
add update notification for non-windows systems
Browse files Browse the repository at this point in the history
  • Loading branch information
jordanamr committed Dec 26, 2022
1 parent 3d3f91b commit b5f3745
Show file tree
Hide file tree
Showing 4 changed files with 20 additions and 2 deletions.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@
{
"name": "@reforged/maker-appimage",
"platforms": [
"linux"
"disabled"
],
"config": {
"options": {
Expand Down
1 change: 1 addition & 0 deletions src/app/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ export type CarouselItem = {
};

export type Manifest = {
launcherVersion: string;
gameVersion: string;
carousel: Array<CarouselItem>;
};
18 changes: 17 additions & 1 deletion src/main/cdnService.ts
Original file line number Diff line number Diff line change
@@ -1,14 +1,30 @@
import { Manifest } from "../app/types";
import { Constants } from "./constants";
import { app, dialog } from "electron";
import { app, dialog, shell } from "electron";
import got from "got";
import { mainWindow } from "../";

export namespace CdnService {
export let manifest: Manifest;

export async function loadManifest() {
try {
manifest = await got.get(`${Constants.CDN_URL}/manifest.json`).json();

// Automatic updates are only available on Windows
if (process.platform !== "win32" && manifest.launcherVersion !== Constants.CURRENT_LAUNCHER_VERSION) {
const response = await dialog.showMessageBox(mainWindow, {
type: "warning",
buttons: ["Ignorer", "Télécharger"],
message:
"Une nouvelle version du launcher est disponible.\nVotre système ne supportant pas les mises à jour automatique, nous vous invitons à la télécharger manuellement.\nVotre launcher peut ne pas fonctionner correctement tant que vous n'avez pas fait cette mise à jour.",
});

if (response && response.response === 1) {
shell.openExternal("https://github.com/ArenaReturns/Launcher/releases/latest");
app.quit();
}
}
} catch (err) {
console.error(err);
dialog.showErrorBox(
Expand Down
1 change: 1 addition & 0 deletions src/main/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import { app } from "electron";
import path from "path";

export class Constants {
public static readonly CURRENT_LAUNCHER_VERSION = "1.0.5";
public static readonly CDN_URL = "https://launcher.arena-returns.com";
public static readonly GAME_PATH = path.join(app.getPath("appData"), "Arena Returns Client");
}

0 comments on commit b5f3745

Please sign in to comment.