www

Unnamed repository; edit this file 'description' to name the repository.
Log | Files | Refs | Submodules | README | LICENSE

commit 15252623d77c24ac6852dcccc5292ef0d325ae58
parent 4c5920ba9a4a068ffbbaf1be4b20a4b30aa1c139
Author: Dan Stillman <dstillman@zotero.org>
Date:   Fri, 29 May 2015 03:37:29 -0400

Log the actual number of Notifier observers for a type

Diffstat:
Mchrome/content/zotero/xpcom/notifier.js | 32+++++++++++++++++++++++++++-----
1 file changed, 27 insertions(+), 5 deletions(-)

diff --git a/chrome/content/zotero/xpcom/notifier.js b/chrome/content/zotero/xpcom/notifier.js @@ -119,11 +119,20 @@ Zotero.Notifier = new function(){ var queue = _inTransaction && !force; - Zotero.debug("Notifier.trigger('" + event + "', '" + type + "', " + '[' + ids.join() + '], ' + extraData + ')' - + (queue ? " queued" : " called " + "[observers: " + Object.keys(_observers).length + "]")); - if (extraData) { - Zotero.debug("Extra data:"); - Zotero.debug(extraData); + if (Zotero.Debug.enabled) { + Zotero.debug("Notifier.trigger(" + + "'" + event + "', " + + "'" + type + "', " + + "[" + ids.join() + "]" + + (extraData ? ", " + extraData : "") + + ")" + + (queue + ? " queued" + : " called " + "[observers: " + _countObserversForType(type) + "]") + ); + if (extraData) { + Zotero.debug(extraData); + } } // Merge with existing queue @@ -215,6 +224,19 @@ Zotero.Notifier = new function(){ } + function _countObserversForType(type) { + var num = 0; + for (let i in _observers) { + // Skip observers that don't handle notifications for this type (or all types) + if (_observers[i].types && _observers[i].types.indexOf(type) == -1) { + continue; + } + num++; + } + return num; + } + + this.untrigger = function (event, type, ids) { if (!_inTransaction) { throw ("Zotero.Notifier.untrigger() called with no active event queue")