1+ import Log from '@libs/Log' ;
12import * as SequentialQueue from '@libs/Network/SequentialQueue' ;
23import CONST from '@src/CONST' ;
34import type { OnyxUpdatesFromServer } from '@src/types/onyx' ;
45import { handleMissingOnyxUpdates } from './OnyxUpdateManager' ;
5- import * as OnyxUpdates from './OnyxUpdates' ;
6+ import { doesClientNeedToBeUpdated , apply as onyxApply , saveUpdateInformation } from './OnyxUpdates' ;
67
78type ApplyOnyxUpdatesReliablyOptions = {
89 clientLastUpdateID ?: number ;
@@ -20,6 +21,7 @@ type ApplyOnyxUpdatesReliablyOptions = {
2021 */
2122export default function applyOnyxUpdatesReliably ( updates : OnyxUpdatesFromServer , { shouldRunSync = false , clientLastUpdateID} : ApplyOnyxUpdatesReliablyOptions = { } ) {
2223 const fetchMissingUpdates = ( ) => {
24+ Log . info ( '[applyOnyxUpdatesReliably] Fetching missing updates' ) ;
2325 // If we got here, that means we are missing some updates on our local storage. To
2426 // guarantee that we're not fetching more updates before our local data is up to date,
2527 // let's stop the sequential queue from running until we're done catching up.
@@ -28,7 +30,7 @@ export default function applyOnyxUpdatesReliably(updates: OnyxUpdatesFromServer,
2830 if ( shouldRunSync ) {
2931 handleMissingOnyxUpdates ( updates , clientLastUpdateID ) ;
3032 } else {
31- OnyxUpdates . saveUpdateInformation ( updates ) ;
33+ saveUpdateInformation ( updates ) ;
3234 }
3335 } ;
3436
@@ -40,8 +42,8 @@ export default function applyOnyxUpdatesReliably(updates: OnyxUpdatesFromServer,
4042 }
4143
4244 const previousUpdateID = Number ( updates . previousUpdateID ) ?? CONST . DEFAULT_NUMBER_ID ;
43- if ( ! OnyxUpdates . doesClientNeedToBeUpdated ( { previousUpdateID, clientLastUpdateID} ) ) {
44- OnyxUpdates . apply ( updates ) ;
45+ if ( ! doesClientNeedToBeUpdated ( { previousUpdateID, clientLastUpdateID} ) ) {
46+ onyxApply ( updates ) ;
4547 return ;
4648 }
4749
0 commit comments