Skip to content

Commit

Permalink
Merge pull request #354 from ubports/fix-snap-detection
Browse files Browse the repository at this point in the history
Fix snap detection and improve update instructions
  • Loading branch information
Flohack74 authored Jul 4, 2018
2 parents b69dfe2 + feee7d7 commit 3f311b0
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 7 deletions.
4 changes: 3 additions & 1 deletion src/html/modals/error.pug
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
p If your problem is not yet known, klick the button below to report a new bug.
pre#error-body.
\n
p#not-latest-stable(hidden='hidden') You are not using the latest stable version of the UBports Installer. You can #[a(onclick="openurl.open('https://github.com/ubports/ubports-installer/releases/latest')") download the latest stable release on GitHub].
p#not-latest-stable(hidden='hidden') You are not using the latest stable version of the UBports Installer.
#generic-update-instructions-error.p(hidden='hidden') You can #[a(onclick="openurl.open('https://github.com/ubports/ubports-installer/issues')") download the latest version from GitHub].
#snap-update-instructions-error.p(hidden='hidden') Run #[code snap refresh ubports-installer --stable] in your terminal to install the latest version.
.modal-footer
button.btn.btn-default(type='button', hidden='hidden', data-dismiss='modal', onclick="location.reload()") Try again
button.btn.btn-default(type='button', hidden='hidden', data-dismiss='modal') Ignore
Expand Down
5 changes: 3 additions & 2 deletions src/html/modals/new-update.pug
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,8 @@
h4.modal-title Update available!
.modal-body
p You are not running the latest stable version. Using the latest stable release is recommended for most users. You can still use this version, but there might be bugs and issues that do not affect the stable release.
p Click the button below to download the latest version or dismiss to continue using this version.
#generic-update-instructions.p(hidden='hidden') Click the button below to download the latest version.
#snap-update-instructions.p(hidden='hidden') Run #[code snap refresh ubports-installer --stable] in your terminal to install the latest version.
.modal-footer
button.btn.btn-default(type='button', data-dismiss='modal') Dismiss
button#btn-update.btn.btn-primary(type='button', onclick="openurl.open('https://github.com/ubports/ubports-installer/releases/latest')") Download
button#btn-update-installer.btn.btn-primary(type='button', onclick="openurl.open('https://github.com/ubports/ubports-installer/releases/latest')") Download
15 changes: 13 additions & 2 deletions src/html/scripts/main.pug
Original file line number Diff line number Diff line change
@@ -1,8 +1,14 @@
script.
// CATCH ANY ERRORS!
var onErr = (err) => {
if(utils.getUpdateAvailable() && !utils.isSnap())
if(utils.getUpdateAvailable()) {
$("#not-latest-stable").show();
if (utils.isSnap()) {
$("#snap-update-instructions-error").show();
} else {
$("#generic-update-instructions-error").show();
}
}
$("#error-body").text(err);
$("#errorModal").modal("show");
modals.hide("password");
Expand All @@ -13,7 +19,6 @@ script.
openurl.open("https://github.com/ubports/ubports-installer/issues/new?title="+title+"&body="+body);
});
})

window.onerror = (err, url, line) => {
onErr(err+" (MainRenderer:"+line+")");
}
Expand Down Expand Up @@ -47,6 +52,12 @@ script.
$('#windows-drivers-modal').modal('show');
if (utils.getUpdateAvailable()) {
utils.log.warn("This is not the latest stable release!")
if (utils.isSnap()) {
$("#snap-update-instructions").show();
$("#btn-update-installer").hide();
} else {
$("#generic-update-instructions").show();
}
$('#new-update-modal').modal('show');
} else {
utils.log.info("Running latest stable version.");
Expand Down
4 changes: 2 additions & 2 deletions src/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -342,11 +342,11 @@ const getFallbackPlatformTools = () => {
}

var isSnap = () => {
return process.env.SNAP_NAME != null
return process.env.SNAP_NAME
}

var needRoot = () => {
if (os.platform() === "win32") return false;
if ((os.platform() === "win32") || isSnap()) return false;
return !process.env.SUDO_UID
}

Expand Down

0 comments on commit 3f311b0

Please sign in to comment.