From: Mike Taylor Date: Tue, 7 Oct 2014 16:28:14 +0000 (+0100) Subject: Fix MKWS-272 ("Do not make unnecessary SP/PP2 requests") X-Git-Tag: 1.0.0~288 X-Git-Url: http://lists.indexdata.com/cgi-bin?a=commitdiff_plain;h=d72c801b0af2cc7911de2b266f6341eb9ae28948;p=mkws-moved-to-github.git Fix MKWS-272 ("Do not make unnecessary SP/PP2 requests") Only set PZ2 callback for operations that we actually use. We determine this by checking whether relevant events have been subscribed to. (Actually, due to the way event queueing is implemented, we also get a positive for events that have been published, even if not subscribed to. But (A) that's going to be very rare, and (B) even if were to happen, it would fail safe by setting up unneeded callbacks rather than failing to set up needed ones.) --- diff --git a/src/mkws-team.js b/src/mkws-team.js index 070f21d..b46142f 100644 --- a/src/mkws-team.js +++ b/src/mkws-team.js @@ -164,11 +164,26 @@ mkws.makeTeam = function($, teamName) { }; params.oninit = onInit; - params.onbytarget = onBytarget; - params.onstat = onStat; - params.onterm = (config.facets.length ? onTerm : undefined); - params.onshow = onShow; - params.onrecord = onRecord; + if (m_queues.targets) { + params.onbytarget = onBytarget; + log("setting bytarget callback"); + } + if (m_queues.stat) { + params.onstat = onStat; + log("setting stat callback"); + } + if (m_queues.termlists) { + log("setting term callback"); + params.onterm = (config.facets.length ? onTerm : undefined); + } + if (m_queues.records) { + log("setting show callback"); + params.onshow = onShow; + } + if (m_queues.record) { + log("setting record callback"); + params.onrecord = onRecord; + } m_paz = new pz2(params); log("ccreated main pz2 object");