summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorChase Sterling <chase.sterling@gmail.com>2012-12-20 22:34:45 -0500
committerChase Sterling <chase.sterling@gmail.com>2012-12-21 12:51:40 -0500
commite865180e832af97513ef9ce991bad28d8b5254fa (patch)
tree851fdb034e50cfd1cb558da5364d1dfca33815bc
parent782b39c90dbbe54da66d6d4647e4fd2fec45bb1a (diff)
downloaddeluge-e865180e832af97513ef9ce991bad28d8b5254fa.zip
deluge-e865180e832af97513ef9ce991bad28d8b5254fa.tar.gz
deluge-e865180e832af97513ef9ce991bad28d8b5254fa.tar.bz2
Fix issues with js eventmanager. refs #2046
Fix plugin methods not being available when enabled until refresh. refs #2125
-rw-r--r--deluge/ui/web/js/deluge-all/Client.js11
-rw-r--r--deluge/ui/web/js/deluge-all/EventsManager.js16
-rw-r--r--deluge/ui/web/js/deluge-all/Plugin.js1
3 files changed, 16 insertions, 12 deletions
diff --git a/deluge/ui/web/js/deluge-all/Client.js b/deluge/ui/web/js/deluge-all/Client.js
index 4483f34..812d17f 100644
--- a/deluge/ui/web/js/deluge-all/Client.js
+++ b/deluge/ui/web/js/deluge-all/Client.js
@@ -69,9 +69,6 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
},
reloadMethods: function() {
- Ext.each(this._components, function(component) {
- delete this[component];
- }, this);
this._execute('system.listMethods', {
success: this._setMethods,
scope: this
@@ -180,7 +177,7 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
var fn = function() {
var options = self._parseArgs(arguments);
return self._execute(method, options);
- }
+ };
component[parts[1]] = fn;
components[parts[0]] = component;
});
@@ -188,7 +185,11 @@ Ext.ux.util.RpcClient = Ext.extend(Ext.util.Observable, {
for (var name in components) {
self[name] = components[name];
}
-
+ Ext.each(this._components, function(component) {
+ if (!component in components) {
+ delete this[component];
+ }
+ }, this);
this._components = Ext.keys(components);
this.fireEvent('connected', this);
}
diff --git a/deluge/ui/web/js/deluge-all/EventsManager.js b/deluge/ui/web/js/deluge-all/EventsManager.js
index 0981d43..f259eb0 100644
--- a/deluge/ui/web/js/deluge-all/EventsManager.js
+++ b/deluge/ui/web/js/deluge-all/EventsManager.js
@@ -91,13 +91,15 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
},
onGetEventsSuccess: function(events) {
- if (!events) return;
- Ext.each(events, function(event) {
- var name = event[0], args = event[1];
- args.splice(0, 0, name);
- this.fireEvent.apply(this, args);
- }, this);
- if (this.running) this.getEvents();
+ if (!this.running) return;
+ if (events) {
+ Ext.each(events, function(event) {
+ var name = event[0], args = event[1];
+ args.splice(0, 0, name);
+ this.fireEvent.apply(this, args);
+ }, this);
+ }
+ this.getEvents();
},
// private
diff --git a/deluge/ui/web/js/deluge-all/Plugin.js b/deluge/ui/web/js/deluge-all/Plugin.js
index 40468e3..d151a35 100644
--- a/deluge/ui/web/js/deluge-all/Plugin.js
+++ b/deluge/ui/web/js/deluge-all/Plugin.js
@@ -76,6 +76,7 @@ Deluge.Plugin = Ext.extend(Ext.util.Observable, {
* then executes the plugins setup method, onEnabled.
*/
enable: function() {
+ deluge.client.reloadMethods();
this.fireEvent("enable", this);
if (this.onEnable) this.onEnable();
},