Skip to content

Commit

Permalink
Merge pull request Expensify#39979 from Expensify/hayata-fix-issue-wi…
Browse files Browse the repository at this point in the history
…th-reliable-update

Check if the OpenApp has finished or not before updating Onyx data
  • Loading branch information
danieldoglas authored Apr 10, 2024
2 parents aed0bf0 + ac9b108 commit 4e13dad
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/libs/actions/OnyxUpdateManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,24 @@ Onyx.connect({
callback: (value) => (lastUpdateIDAppliedToClient = value),
});

let isLoadingApp = false;
Onyx.connect({
key: ONYXKEYS.IS_LOADING_APP,
callback: (value) => {
isLoadingApp = value ?? false;
},
});

export default () => {
console.debug('[OnyxUpdateManager] Listening for updates from the server');
Onyx.connect({
key: ONYXKEYS.ONYX_UPDATES_FROM_SERVER,
callback: (value) => {
if (!value) {
// When the OpenApp command hasn't finished yet, we should not process any updates.
if (!value || isLoadingApp) {
if (isLoadingApp) {
console.debug(`[OnyxUpdateManager] Ignoring Onyx updates while OpenApp hans't finished yet.`);
}
return;
}
// This key is shared across clients, thus every client/tab will have a copy and try to execute this method.
Expand Down

0 comments on commit 4e13dad

Please sign in to comment.