store remote events and register them when the events are started
This commit is contained in:
parent
f831cdce9a
commit
037fbcaaa7
|
@ -41,14 +41,19 @@ Copyright:
|
||||||
(function() {
|
(function() {
|
||||||
Events = Ext.extend(Ext.util.Observable, {
|
Events = Ext.extend(Ext.util.Observable, {
|
||||||
constructor: function() {
|
constructor: function() {
|
||||||
|
this.toRegister = [];
|
||||||
Events.superclass.constructor.call(this);
|
Events.superclass.constructor.call(this);
|
||||||
},
|
},
|
||||||
|
|
||||||
addListener: function(eventName, fn, scope, o) {
|
addListener: function(eventName, fn, scope, o) {
|
||||||
this.addEvents(eventName);
|
this.addEvents(eventName);
|
||||||
if (/[A-Z]/.test(eventName.substring(0, 1))) {
|
if (/[A-Z]/.test(eventName.substring(0, 1))) {
|
||||||
|
if (!Deluge.Client) {
|
||||||
|
this.toRegister.push(eventName);
|
||||||
|
} else {
|
||||||
Deluge.Client.web.register_event_listener(eventName);
|
Deluge.Client.web.register_event_listener(eventName);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
Events.superclass.addListener.call(this, eventName, fn, scope, o);
|
Events.superclass.addListener.call(this, eventName, fn, scope, o);
|
||||||
},
|
},
|
||||||
|
|
||||||
|
@ -60,6 +65,9 @@ Copyright:
|
||||||
},
|
},
|
||||||
|
|
||||||
start: function() {
|
start: function() {
|
||||||
|
Ext.each(this.toRegister, function(eventName) {
|
||||||
|
Deluge.Client.web.register_event_listener(eventName);
|
||||||
|
});
|
||||||
this.poll = this.poll.bind(this);
|
this.poll = this.poll.bind(this);
|
||||||
this.running = setInterval(this.poll, 2000);
|
this.running = setInterval(this.poll, 2000);
|
||||||
this.poll();
|
this.poll();
|
||||||
|
|
Loading…
Reference in New Issue