-
Notifications
You must be signed in to change notification settings - Fork 3.9k
Android: fix GetMissingOnyxUpdates in the background #40022
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
994ea52
37b4241
9e0ef4b
dc7ceb2
9f56daf
7367ef3
89b0c3f
f62e13b
ef8286f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -132,29 +132,23 @@ function saveUpdateInformation(updateParams: OnyxUpdatesFromServer) { | |
| * This function will receive the previousUpdateID from any request/pusher update that has it, compare to our current app state | ||
| * and return if an update is needed | ||
| * @param previousUpdateID The previousUpdateID contained in the response object | ||
| * @param clientLastUpdateID an optional override for the lastUpdateIDAppliedToClient | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What's the purpose of this change?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I explained in the description above. In the background, |
||
| */ | ||
| function doesClientNeedToBeUpdated(previousUpdateID = 0): boolean { | ||
| function doesClientNeedToBeUpdated(previousUpdateID = 0, clientLastUpdateID = 0): boolean { | ||
| // If no previousUpdateID is sent, this is not a WRITE request so we don't need to update our current state | ||
| if (!previousUpdateID) { | ||
| return false; | ||
| } | ||
|
|
||
| // If we don't have any value in lastUpdateIDAppliedToClient, this is the first time we're receiving anything, so we need to do a last reconnectApp | ||
| if (!lastUpdateIDAppliedToClient) { | ||
| const lastUpdateIDFromClient = clientLastUpdateID || lastUpdateIDAppliedToClient; | ||
|
|
||
| // If we don't have any value in lastUpdateIDFromClient, this is the first time we're receiving anything, so we need to do a last reconnectApp | ||
| if (!lastUpdateIDFromClient) { | ||
| return true; | ||
| } | ||
|
|
||
| return lastUpdateIDAppliedToClient < previousUpdateID; | ||
| } | ||
|
|
||
| function applyOnyxUpdatesReliably(updates: OnyxUpdatesFromServer) { | ||
| const previousUpdateID = Number(updates.previousUpdateID) || 0; | ||
| if (!doesClientNeedToBeUpdated(previousUpdateID)) { | ||
| apply(updates); | ||
| return; | ||
| } | ||
| saveUpdateInformation(updates); | ||
| return lastUpdateIDFromClient < previousUpdateID; | ||
| } | ||
|
|
||
| // eslint-disable-next-line import/prefer-default-export | ||
| export {saveUpdateInformation, doesClientNeedToBeUpdated, apply, applyOnyxUpdatesReliably}; | ||
| export {saveUpdateInformation, doesClientNeedToBeUpdated, apply}; | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -44,8 +44,8 @@ import type ReportAction from '@src/types/onyx/ReportAction'; | |
| import type {OriginalMessage} from '@src/types/onyx/ReportAction'; | ||
| import {isEmptyObject} from '@src/types/utils/EmptyObject'; | ||
| import type {EmptyObject} from '@src/types/utils/EmptyObject'; | ||
| import applyOnyxUpdatesReliably from './applyOnyxUpdatesReliably'; | ||
| import * as Link from './Link'; | ||
| import * as OnyxUpdates from './OnyxUpdates'; | ||
| import * as Report from './Report'; | ||
| import * as Session from './Session'; | ||
|
|
||
|
|
@@ -597,7 +597,7 @@ function subscribeToUserEvents() { | |
| updates: pushJSON.updates ?? [], | ||
| previousUpdateID: Number(pushJSON.previousUpdateID || 0), | ||
| }; | ||
| OnyxUpdates.applyOnyxUpdatesReliably(updates); | ||
| applyOnyxUpdatesReliably(updates); | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I'm just curious: why'd we move this into its own file?
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Also explained in the description 😄 |
||
| }); | ||
|
|
||
| // Handles Onyx updates coming from Pusher through the mega multipleEvents. | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
*hasn't 🤷