Skip to content
This repository has been archived by the owner on Apr 29, 2021. It is now read-only.

Commit

Permalink
[#232] added restart dialog to inform user that the update is ready t…
Browse files Browse the repository at this point in the history
…o install
  • Loading branch information
hermwong committed Feb 27, 2015
1 parent 67bb77d commit 917a5a6
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 40 deletions.
13 changes: 9 additions & 4 deletions www/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
global.debugMode = true;
global.missing = new Array();
global.manifest = null;
global.newAppPath = null;

global.jQuery(document).ready(function() {

Expand Down Expand Up @@ -228,8 +229,12 @@
});

global.jQuery("#updateNow").click(function() {
//gui.Shell.openExternal("https://github.com/phonegap/phonegap-app-desktop/releases");
updateApp();
var text = global.jQuery("#updateNow").text();
if (text == "Restart") {
restartApp();
} else {
updateApp();
}
global.jQuery("#updateOverlay").hide();
});

Expand All @@ -255,8 +260,8 @@
<div id="overlay-bg" class="topcoat-overlay-bg-grey"></div>

<aside id="updateOverlay" class="update-overlay">
<div class="overlay-form-item-heading">Update Available</div>
<div class="overlay-form-item settings-ip-label">A new version of the PhoneGap Desktop App is available.</div>
<div class="overlay-form-item-heading" id="updateOverlayTitle"></div>
<div class="overlay-form-item settings-ip-label" id="updateOverlayPrompt"></div>
<div class="overlay-form-item">
<button id="updateLater" class="cancel-button">Cancel</button>
<button id="updateNow" class="action-button">Update</button>
Expand Down
30 changes: 1 addition & 29 deletions www/js/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,36 +44,8 @@ if(gui.App.argv.length) {
upd.checkNewVersion(function(error, newVersionExists, manifest) {
if (!error && newVersionExists) {
console.log("new version found");
console.log(manifest);

global.manifest = manifest;

global.jQuery("#updateOverlay").show();
/*
// only auto-update for OSX
if (process.platform == 'darwin') {
// if new version found, download new package to a temp dir
upd.download(function(error, filename) {
if (!error) {
console.log("downloading new version");
// unpack new package in temp dir
upd.unpack(filename, function(error, newAppPath) {
if (!error) {
console.log("unpack & run the new version");
console.log("appPath: " + upd.getAppPath());
console.log("execPath: " + upd.getAppExec());
// run the new version & quit the old app
upd.runInstaller(newAppPath, [upd.getAppPath(), upd.getAppExec()],{});
gui.App.quit();
}
}, manifest);
}
}, manifest);
}*/
displayUpdateAvailablePrompt();
} else {
if (!newVersionExists) {
console.log("latest version");
Expand Down
33 changes: 26 additions & 7 deletions www/js/updater.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,24 @@
function displayUpdateAvailablePrompt() {
global.jQuery("#updateOverlayTitle").text("Update Available");
global.jQuery("#updateOverlayPrompt").text("A new version of the PhoneGap Desktop App is available.");
global.jQuery("#updateNow").text("Update");
global.jQuery("#updateOverlay").show();
}

function displayInstallUpdatePrompt() {
global.jQuery("#updateOverlayTitle").text("Update Downloaded");
global.jQuery("#updateOverlayPrompt").text("Install the downloaded update and restart PhoneGap Desktop.");
global.jQuery("#updateNow").text("Restart");
global.jQuery("#updateOverlay").show();
}

function restartApp () {
// run the new version & quit the old app
var newAppPath = global.newAppPath;
upd.runInstaller(newAppPath, [upd.getAppPath(), upd.getAppExec()],{});
gui.App.quit();
}

function updateApp() {

var manifest = global.manifest;
Expand All @@ -14,17 +35,15 @@ function updateApp() {
console.log("unpack & run the new version");

console.log("appPath: " + upd.getAppPath());
console.log("execPath: " + upd.getAppExec());

// run the new version & quit the old app
upd.runInstaller(newAppPath, [upd.getAppPath(), upd.getAppExec()],{});
gui.App.quit();
console.log("execPath: " + upd.getAppExec());

global.newAppPath = newAppPath;
displayInstallUpdatePrompt();
}
}, manifest);
}
}, manifest);
} else {
gui.Shell.openExternal("https://github.com/phonegap/phonegap-app-desktop/releases");
}

}
}

0 comments on commit 917a5a6

Please sign in to comment.