From 4ff5c7294cfbc776157843ec9b88f0b580ef1867 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20B=C3=BCchele?= Date: Wed, 7 Nov 2018 06:22:13 -0800 Subject: [PATCH] don't update when nothing changed Summary: The QPL plugin is sending the current time on the device every second, this was causing state updates every second. QPL: don't update the state, when we did not receive new traces. Client: only dispatch the update event, when the new state is different from the current. Reviewed By: passy Differential Revision: D12956337 fbshipit-source-id: c006540097408ead8fb8c5aac3aaaa220c1a3951 --- src/Client.js | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/src/Client.js b/src/Client.js index 2499ca359..ea0c48eec 100644 --- a/src/Client.js +++ b/src/Client.js @@ -179,12 +179,14 @@ export default class Client extends EventEmitter { params.method, params.params, ); - this.store.dispatch( - setPluginState({ - pluginKey, - state: newPluginState, - }), - ); + if (persistedState !== newPluginState) { + this.store.dispatch( + setPluginState({ + pluginKey, + state: newPluginState, + }), + ); + } } else { const apiCallbacks = this.broadcastCallbacks.get(params.api); if (!apiCallbacks) {