From d72c801b0af2cc7911de2b266f6341eb9ae28948 Mon Sep 17 00:00:00 2001 From: Mike Taylor Date: Tue, 7 Oct 2014 17:28:14 +0100 Subject: [PATCH] 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.) --- src/mkws-team.js | 25 ++++++++++++++++++++----- 1 file changed, 20 insertions(+), 5 deletions(-) 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"); -- 1.7.10.4