Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Lead to latest appropriate release in update checker window #258

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 8 additions & 12 deletions src/main/UpdateChecker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ export default class UpdateChecker {
private alertDetail = "Checking for update information. Please try again.";
private alertOptions: string[] | null = null;
private alertCancelId: number | null = null;
private latestVersion = "";
private alertDownloadUrl: string | null = null;

async check() {
Expand Down Expand Up @@ -56,7 +57,7 @@ export default class UpdateChecker {
// Get version info
let currentVersion = app.getVersion();
let latestVersionInfo = releaseData[0];
let latestVersion = latestVersionInfo["tag_name"].slice(1);
this.latestVersion = latestVersionInfo["tag_name"].slice(1);
let latestDate = new Date(latestVersionInfo["published_at"]);
let latestDateText = latestDate.toLocaleDateString();
let translated = process.arch !== "arm64" && app.runningUnderARM64Translation;
Expand All @@ -69,21 +70,21 @@ export default class UpdateChecker {
this.alertDownloadUrl = null;

// Set appropriate prompt
if (currentVersion !== latestVersion && translated) {
if (currentVersion !== this.latestVersion && translated) {
this.alertMessage = "Download latest native version?";
this.alertDetail =
"Version " +
latestVersion +
this.latestVersion +
" is available (released " +
latestDateText +
"). You're currently running the x86 build of version " +
currentVersion +
" on an arm64 platform. Would you like to download the latest native version?";
} else if (currentVersion !== latestVersion) {
} else if (currentVersion !== this.latestVersion) {
this.alertMessage = "Download latest version?";
this.alertDetail =
"Version " +
latestVersion +
this.latestVersion +
" is available (released " +
latestDateText +
"). You're currently running version " +
Expand Down Expand Up @@ -157,14 +158,9 @@ export default class UpdateChecker {
let responseString = this.alertOptions[result.response];
if (responseString === "Download") {
if (this.alertDownloadUrl === null) {
if (isBeta()) {
await shell.openExternal("https://github.com/" + REPOSITORY + "/releases");
} else {
await shell.openExternal("https://github.com/" + REPOSITORY + "/releases/latest");
}
} else {
await shell.openExternal(this.alertDownloadUrl);
this.alertDownloadUrl = `https://github.com/${REPOSITORY}/releases/v${this.latestVersion}`;
}
await shell.openExternal(this.alertDownloadUrl);
} else if (responseString === "View Changelog") {
await shell.openExternal("https://github.com/" + REPOSITORY + "/releases");
}
Expand Down