From 1894dce37f80598288aa3b5a4d5950e5a2f7a2c2 Mon Sep 17 00:00:00 2001 From: Daniel Silva Date: Tue, 9 Apr 2024 16:44:15 +0200 Subject: [PATCH] adding check if the current client is the active one before doing getMissingOnyxMessages requests --- src/libs/actions/OnyxUpdateManager.ts | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/src/libs/actions/OnyxUpdateManager.ts b/src/libs/actions/OnyxUpdateManager.ts index 9c6f30cc5e9e..cc51cbd22deb 100644 --- a/src/libs/actions/OnyxUpdateManager.ts +++ b/src/libs/actions/OnyxUpdateManager.ts @@ -1,4 +1,5 @@ import Onyx from 'react-native-onyx'; +import * as ActiveClientManager from '@libs/ActiveClientManager'; import Log from '@libs/Log'; import * as SequentialQueue from '@libs/Network/SequentialQueue'; import CONST from '@src/CONST'; @@ -35,6 +36,12 @@ export default () => { if (!value) { return; } + // This key is shared across clients, thus every client/tab will have a copy and try to execute this method. + // It is very important to only process the missing onyx updates from leader client otherwise requests we'll execute + // several duplicated requests that are not controlled by the SequentialQueue. + if (!ActiveClientManager.isClientTheLeader()) { + return; + } // Since we used the same key that used to store another object, let's confirm that the current object is // following the new format before we proceed. If it isn't, then let's clear the object in Onyx.