Fix issues with js eventmanager. refs #2046

Fix plugin methods not being available when enabled until refresh. refs #2125
This commit is contained in:
Chase Sterling 2012-12-21 13:26:58 -05:00
parent 8f34e2abdb
commit e6267d9411
3 changed files with 38 additions and 34 deletions

View File

@ -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
@ -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);
}

View File

@ -91,13 +91,15 @@ Deluge.EventsManager = Ext.extend(Ext.util.Observable, {
},
onGetEventsSuccess: function(events) {
if (!events) return;
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);
if (this.running) this.getEvents();
}
this.getEvents();
},
// private

View File

@ -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();
},