Permalink
Browse files

Keep the AOM view up to date when updating script file changes.

Fixes #1215
  • Loading branch information...
1 parent 5a75f38 commit 0ca46387f89955f083d4bc65bd70622568f79bbb @arantius arantius committed Jul 11, 2011
Showing with 15 additions and 5 deletions.
  1. +4 −1 content/addons4-overlay.js
  2. +1 −3 content/script.js
  3. +10 −1 content/scriptdownloader.js
@@ -52,9 +52,12 @@ var observer = {
item.setAttribute('active', data);
break;
case 'modified':
+ // Bust the addon cache, and get references to the old and new version.
+ var oldAddon = ScriptAddonFactoryByScript({'id': data});
ScriptAddonReplaceScript(script);
+ addon = ScriptAddonFactoryByScript(script);
- var oldAddon = ScriptAddonFactoryByScript({'id': data});
+ // Use the addon references to update the view to match the new state.
var item = createItem(addon);
var oldItem = gListView.getListItemForID(oldAddon.id);
oldItem.parentNode.replaceChild(item, oldItem);
View
@@ -413,9 +413,7 @@ Script.prototype.updateFromNewScript = function(newScript, safeWin, chromeWin) {
// Redownload dependencies.
var scriptDownloader = new GM_ScriptDownloader(null, null, null);
- scriptDownloader.script = this;
- scriptDownloader.updateScript = true;
- scriptDownloader.fetchDependencies();
+ scriptDownloader.startUpdateScript(this);
}
};
@@ -15,6 +15,8 @@ GM_ScriptDownloader = function(win, uri, bundle, contentWin) {
this.dependenciesLoaded_ = false;
this.installOnCompletion_ = false;
this.tempFiles_ = [];
+
+ this._oldScriptId = null;
this.updateScript = false;
};
@@ -23,6 +25,13 @@ GM_ScriptDownloader.prototype.startInstall = function() {
this.startDownload();
};
+GM_ScriptDownloader.prototype.startUpdateScript = function(script) {
+ this.script = script;
+ this._oldScriptId = script.id;
+ this.updateScript = true;
+ this.fetchDependencies();
+};
+
GM_ScriptDownloader.prototype.startViewScript = function(uri) {
this.installing_ = false;
this.startDownload();
@@ -256,7 +265,7 @@ GM_ScriptDownloader.prototype.finishInstall = function() {
}
// Save new values to config.xml
- GM_getConfig()._save();
+ GM_getConfig()._changed(this.script, "modified", this._oldScriptId, true);
} else if (this.installOnCompletion_) {
this.installScript();
}

0 comments on commit 0ca4638

Please sign in to comment.