Skip to content

Commit

Permalink
adding check if the current client is the active one before doing get…
Browse files Browse the repository at this point in the history
…MissingOnyxMessages requests
  • Loading branch information
danieldoglas committed Apr 9, 2024
1 parent 792c697 commit 1894dce
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 1894dce

Please sign in to comment.