Skip to content

Commit

Permalink
fix: get around extension update issues in tauri
Browse files Browse the repository at this point in the history
  • Loading branch information
abose committed Dec 4, 2023
1 parent 39580f2 commit 0c07519
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 3 deletions.
24 changes: 21 additions & 3 deletions src/extensibility/ExtensionManagerView.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
*/

/*unittests: ExtensionManager*/
/*global Phoenix*/

define(function (require, exports, module) {

Expand Down Expand Up @@ -500,6 +501,7 @@ define(function (require, exports, module) {
*/
ExtensionManagerView.prototype._installUsingDialog = function (id, _isUpdate) {
var entry = this.model.extensions[id];
const self = this;
if (entry && entry.registryInfo) {
const compatInfo = ExtensionManager.getCompatibilityInfo(entry.registryInfo, brackets.metadata.apiVersion),
url = ExtensionManager.getExtensionURL(id, compatInfo.compatibleVersion),
Expand All @@ -510,10 +512,26 @@ define(function (require, exports, module) {
// TODO: this should set .done on the returned promise
if (_isUpdate) {
// save to metric id as it is from public extension store.
Metrics.countEvent(Metrics.EVENT_TYPE.EXTENSIONS, "install", id);
InstallExtensionDialog.updateUsingDialog(url).done(ExtensionManager.updateFromDownload);
} else {
Metrics.countEvent(Metrics.EVENT_TYPE.EXTENSIONS, "update", id);
InstallExtensionDialog.updateUsingDialog(url).done((installResult)=>{
if(Phoenix.browser.isTauri) {
// in tauri, due to browser cache for asset urls, updates to extensions will still load old
// extension through the http cache. So we show a restart app for the update to take effect
// message.
entry.installInfo.metadata = entry.registryInfo.metadata;
self.model._getEntry(id).updateAvailable = false;
// this is a hack as we will drop this extnsion manager and move to new one. so this will do.
self.model.trigger("change", id);
Dialogs.showModalDialog(
DefaultDialogs.DIALOG_ID_INFO,
Strings.EXTENSION_UPDATE_RESTART_TITLE,
Strings.EXTENSION_UPDATE_RESTART_MESSAGE
);
}
ExtensionManager.updateFromDownload(installResult);
});
} else {
Metrics.countEvent(Metrics.EVENT_TYPE.EXTENSIONS, "install", id);
InstallExtensionDialog.installUsingDialog(url);
}
}
Expand Down
2 changes: 2 additions & 0 deletions src/nls/root/strings.js
Original file line number Diff line number Diff line change
Expand Up @@ -607,6 +607,8 @@ define({
// For NOT_FOUND_ERR, see generic strings above
"EXTENSION_MANAGER_TITLE": "Extension Manager",
"EXTENSION_MANAGER_ERROR_LOAD": "Unable to access the extension registry. Please try again later.",
"EXTENSION_UPDATE_RESTART_TITLE": "Restart To Update",
"EXTENSION_UPDATE_RESTART_MESSAGE": "To load updated extensions, please close all running instances of {APP_NAME} and restart the application.",
"INSTALL_EXTENSION_DRAG": "Drag .zip here or",
"INSTALL_EXTENSION_DROP": "Drop .zip to install",
"INSTALL_EXTENSION_DROP_ERROR": "Install/Update aborted due to the following errors:",
Expand Down

0 comments on commit 0c07519

Please sign in to comment.