Skip to content

Commit

Permalink
chore: update dialogs and workflows + update in mac test
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Feb 20, 2024
1 parent 4077c7d commit 1ded50f
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 8 deletions.
26 changes: 21 additions & 5 deletions src/extensionsIntegrated/appUpdater/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ define(function (require, exports, module) {
semver = require("thirdparty/semver.browser"),
TaskManager = require("features/TaskManager"),
PreferencesManager = require("preferences/PreferencesManager");
let updaterWindow, updateTask, updatePendingRestart;
let updaterWindow, updateTask, updatePendingRestart, updateFailed;

const TAURI_UPDATER_WINDOW_LABEL = "updater",
KEY_LAST_UPDATE_CHECK_TIME = "PH_LAST_UPDATE_CHECK_TIME",
Expand All @@ -50,7 +50,9 @@ define(function (require, exports, module) {
onSelect: function () {
if(updatePendingRestart){
Dialogs.showInfoDialog(Strings.UPDATE_READY_RESTART_TITLE, Strings.UPDATE_READY_RESTART_MESSAGE);
} else {
} else if(updateFailed){
Dialogs.showInfoDialog(Strings.UPDATE_FAILED_TITLE, Strings.UPDATE_FAILED_MESSAGE);
}else {
Dialogs.showInfoDialog(Strings.UPDATING_APP, Strings.UPDATING_APP_DIALOG_MESSAGE);
}
}
Expand Down Expand Up @@ -161,6 +163,10 @@ define(function (require, exports, module) {
return;
}
const updateDetails = await getUpdateDetails();
if(updateFailed) {
(!isAutoUpdate) && Dialogs.showInfoDialog(Strings.UPDATE_FAILED_TITLE, Strings.UPDATE_FAILED_MESSAGE);
return;
}
if(updatePendingRestart || updateDetails.updatePendingRestart){
(!isAutoUpdate) && Dialogs.showInfoDialog(Strings.UPDATE_READY_RESTART_TITLE, Strings.UPDATE_READY_RESTART_MESSAGE);
return;
Expand Down Expand Up @@ -207,6 +213,7 @@ define(function (require, exports, module) {
_sendUpdateCommand(UPDATE_COMMANDS.GET_STATUS);
}

let updateInstalledDialogShown = false, updateFailedDialogShown = false;
AppInit.appReady(function () {
if(!Phoenix.browser.isTauri || Phoenix.isTestWindow) {
// app updates are only for desktop builds
Expand All @@ -217,17 +224,26 @@ define(function (require, exports, module) {
console.log("received Event updater-event", receivedEvent);
const {eventName, data} = receivedEvent.payload;
if(eventName === UPDATE_EVENT.STATUS) {
if(data === UPDATE_STATUS.FAILED_UNKNOWN_OS){
if(data === UPDATE_STATUS.FAILED_UNKNOWN_OS && !updateFailedDialogShown){
updateFailedDialogShown = true;
Metrics.countEvent(Metrics.EVENT_TYPE.UPDATES, 'fail', "Unknown"+Phoenix.platform);
updateFailed = true;
updateTask.setFailed();
} else if(data === UPDATE_STATUS.FAILED){
updateTask.setMessage(Strings.UPDATE_FAILED_TITLE);
} else if(data === UPDATE_STATUS.FAILED && !updateFailedDialogShown){
updateFailedDialogShown = true;
Metrics.countEvent(Metrics.EVENT_TYPE.UPDATES, 'fail', Phoenix.platform);
updateFailed = true;
updateTask.setFailed();
updateTask.setMessage(Strings.UPDATE_FAILED_TITLE);
Dialogs.showInfoDialog(Strings.UPDATE_FAILED_TITLE, Strings.UPDATE_FAILED_MESSAGE);
} else if(data === UPDATE_STATUS.INSTALLED){
} else if(data === UPDATE_STATUS.INSTALLED && !updateInstalledDialogShown){
updateInstalledDialogShown = true;
Metrics.countEvent(Metrics.EVENT_TYPE.UPDATES, 'done', Phoenix.platform);
updatePendingRestart = true;
updateTask.setSucceded();
updateTask.setTitle(Strings.UPDATE_DONE);
updateTask.setMessage(Strings.UPDATE_RESTART);
Dialogs.showInfoDialog(Strings.UPDATE_READY_RESTART_TITLE, Strings.UPDATE_READY_RESTART_MESSAGE);
}
showOrHideUpdateIcon();
Expand Down
4 changes: 3 additions & 1 deletion src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,13 +567,15 @@ define({
"UPDATE_NOT_AVAILABLE_TITLE": "No Updates Available",
"UPDATE_AVAILABLE_TITLE": "Update Available",
"UPDATE_READY_RESTART_TITLE": "Update Ready: Restart Required",
"UPDATE_READY_RESTART_MESSAGE": "{APP_NAME} update is installed. Close all {APP_NAME} windows and restart the app to launch the updated version.",
"UPDATE_READY_RESTART_MESSAGE": "Close all {APP_NAME} windows and restart the app to launch the updated version.",
"UPDATE_FAILED_TITLE": "Update Failed",
"UPDATE_FAILED_MESSAGE": "Please close all {APP_NAME} windows and reopen the application to attempt the update again.",
"UPDATE_UP_TO_DATE": "{APP_NAME} is up to date.",
"UPDATE_MESSAGE": "Hey, there's a new build of {APP_NAME} available. Here are some of the new features:",
"GET_IT_NOW": "Get it now!",
"UPDATE_LATER": "Remind Me Later",
"UPDATE_DONE": "{APP_NAME} Updated",
"UPDATE_RESTART": "Restart to apply updates",
"UPDATING_APP": "Updating {APP_NAME}",
"UPDATING_APP_MESSAGE": "This may take a while",
"UPDATING_APP_DIALOG_MESSAGE": "Update in progress. You can continue using {APP_NAME} while we upgrade.",
Expand Down
5 changes: 3 additions & 2 deletions src/tauri-updater.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
window.__TAURI__.event.listen("updateCommands", (receivedEvent)=> {
console.log("Updater received Event updateCommands", receivedEvent);
const {command, data} = receivedEvent.payload;
if(command === UPDATE_COMMANDS.STATUS){
if(command === UPDATE_COMMANDS.GET_STATUS){
sendUpdateEvent(UPDATE_EVENT.STATUS, status);
}
});
Expand All @@ -43,7 +43,8 @@
}

async function updateLinux() {

status = UPDATE_STATUS.FAILED;
sendUpdateEvent(UPDATE_EVENT.STATUS, UPDATE_STATUS.FAILED);
}

async function updateWindows() {
Expand Down

0 comments on commit 1ded50f

Please sign in to comment.