From 037fbcaaa725d9d76865030aa2a4a4ec68aa2d87 Mon Sep 17 00:00:00 2001 From: Damien Churchill Date: Wed, 16 Sep 2009 09:39:30 +0000 Subject: [PATCH] store remote events and register them when the events are started --- deluge/ui/web/js/Deluge.Events.js | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/deluge/ui/web/js/Deluge.Events.js b/deluge/ui/web/js/Deluge.Events.js index 8edbf2518..0e26ff48a 100644 --- a/deluge/ui/web/js/Deluge.Events.js +++ b/deluge/ui/web/js/Deluge.Events.js @@ -41,13 +41,18 @@ Copyright: (function() { Events = Ext.extend(Ext.util.Observable, { constructor: function() { + this.toRegister = []; Events.superclass.constructor.call(this); }, addListener: function(eventName, fn, scope, o) { this.addEvents(eventName); if (/[A-Z]/.test(eventName.substring(0, 1))) { - Deluge.Client.web.register_event_listener(eventName); + if (!Deluge.Client) { + this.toRegister.push(eventName); + } else { + Deluge.Client.web.register_event_listener(eventName); + } } Events.superclass.addListener.call(this, eventName, fn, scope, o); }, @@ -60,6 +65,9 @@ Copyright: }, start: function() { + Ext.each(this.toRegister, function(eventName) { + Deluge.Client.web.register_event_listener(eventName); + }); this.poll = this.poll.bind(this); this.running = setInterval(this.poll, 2000); this.poll();