Skip to content

Commit

Permalink
Use existing 'ViewChanged' listener.
Browse files Browse the repository at this point in the history
Fixes #1307
  • Loading branch information
arantius committed Apr 20, 2011
1 parent 109b93c commit 7f7848a
Showing 1 changed file with 6 additions and 11 deletions.
17 changes: 6 additions & 11 deletions content/addons4-overlay.js
Expand Up @@ -5,6 +5,7 @@
Components.utils.import("resource://gre/modules/AddonManager.jsm");
Components.utils.import("resource://greasemonkey/addons4.js");

var needSortOrderFixed = false;
var sortersContainer;
var sortExecuteOrderButton;
var stringBundle;
Expand Down Expand Up @@ -41,17 +42,7 @@ var observer = {
break;
}

// Apply the correct sort when the view has reloaded
function scriptViewUpdated() {
gViewController.currentViewObj.node
.removeEventListener('ViewChanged', scriptViewUpdated, false);

applySort();
}

// Reload the view and add a listener to notify when the load is complete
gViewController.currentViewObj.node
.addEventListener('ViewChanged', scriptViewUpdated, false);
needSortOrderFixed = true;
gViewController.loadViewInternal('addons://list/user-script', null);
}
};
Expand Down Expand Up @@ -165,6 +156,10 @@ function onViewChanged(aEvent) {
if ('addons://list/user-script' == gViewController.currentViewId) {
document.documentElement.className += ' greasemonkey';
emptyWarning.collapsed = !!GM_getConfig().scripts.length;
if (needSortOrderFixed) {
applySort();
needSortOrderFixed = true;
}
} else {
document.documentElement.className = document.documentElement.className
.replace(/ greasemonkey/g, '');
Expand Down

0 comments on commit 7f7848a

Please sign in to comment.