Skip to content

Commit

Permalink
Merge pull request #39943 from Expensify/dsilva_addCheckIfClientIsAct…
Browse files Browse the repository at this point in the history
…iveOnOnyxUpdatesManager

[No QA] Adding check if the current client is the active one on OnyxUpdates
  • Loading branch information
luacmartins authored Apr 9, 2024
2 parents a277936 + 1894dce commit eda9aec
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/libs/actions/OnyxUpdateManager.ts
Original file line number Diff line number Diff line change
@@ -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';
Expand Down Expand Up @@ -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.
Expand Down

0 comments on commit eda9aec

Please sign in to comment.