-
Notifications
You must be signed in to change notification settings - Fork 3.5k
Add deferred updates queue functions to OnyxUpdateManager to manually apply updates (e.g. from push notifications)
#42044
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
Add deferred updates queue functions to OnyxUpdateManager to manually apply updates (e.g. from push notifications)
#42044
Conversation
arosiclair
left a comment
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.
Looks pretty good on first glance, but could we rename the deferredUpdatesProxy lib to just DeferredUpdates and then move these enqueue, process and clear functions there? That way we can have a pretty clean API (eg: DeferredUpdates.enqueue())
That was my first idea as well, but we also want to be able to trigger I think it's more robust if the developer just interacts with the I can still rename |
|
Still, i can also extract the |
@arosiclair nevermind, i just changed the structure as you suggested. We now have a |
arosiclair
left a comment
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.
Appreciate the changes! Just looking for a bit better encapsulation on the DeferredUpdates lib
|
|
||
| const GetMissingOnyxUpdatesPromiseValue = {GetMissingOnyxUpdatesPromise: undefined as Promise<Response | Response[] | void> | undefined}; | ||
|
|
||
| export default createProxyForObject(GetMissingOnyxUpdatesPromiseValue); |
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.
As you might guess I'm not a big fan of this proxy object pattern 😄. These feel more or less like global variables and are prone to error in the same way since their values can be changed anywhere, at anytime and in any way.
It feels like we're pretty much creating a lock with this object so it would be nice if we could abstract it like one. However, I'm not sure exactly how it would look.
Cleaning this up is NAB but if you know an easy way to write it I'm curious.
|
@arosiclair i adapted the implementation, but it's still WIP. I'll update you tmrw! |
|
@arosiclair this is now done! I moved and adapted the the deferred updates queue to This module includes your requested functions as well as |
arosiclair
left a comment
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.
Looking good. Can you add some test steps? Also will the unit tests we added before cover these changes?
src/libs/actions/OnyxUpdateManager/utils/DeferredOnyxUpdates.ts
Outdated
Show resolved
Hide resolved
Co-authored-by: Andrew Rosiclair <arosiclair@gmail.com>
Yes, the unit and action tests actually already catched some issues while implementing this and they cover (all of) the functionality that are affected by these changes |
|
@arosiclair updated the PR :) |
arosiclair
left a comment
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.
Great work!
|
@allroundexperts can you review and do the checklist? |
|
Yep. I'll be done in 30-45 minutes. |
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / Safariscreen-recording-2024-05-16-at-111913-pm_nehDWa0J.mp4screen-recording-2024-05-16-at-111647-pm_ei56v13T.mp4MacOS: DesktopScreen.Recording.2024-05-16.at.11.40.45.PM.mov |
|
@arosiclair I think this can not really be tested on mobile. Is that correct? |
Yeah @chrispader's testing steps only seem do-able on web and desktop so I think we can just test those. |
allroundexperts
left a comment
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.
This is testing fine. Messages are not getting lost but I was not able to confirm there order. Sometimes, they appeared out of order. Not sure if that is expected.
|
Merge freeze is on currently. I'll merge when that's done |
|
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
|
🚀 Deployed to staging by https://github.com/arosiclair in version: 1.4.76-0 🚀
|
|
🚀 Deployed to production by https://github.com/Beamanator in version: 1.4.76-7 🚀
|
@arosiclair @quinthar
Details
This PR adds three new functions to the
OnyxUpdateManagerwhich let you manage the updates in the deferred updates queue. It particularly a clean interface to access and control deferred updates.The
DeferredOnyxUpdatesmodule mainly includes the following functions:enqueue()let's you add updates to the queue. By default, this will automatically trigger processing these items withvalidateAndApplyDeferredUpdatesprocess()waits for the currentqueryPromise(when there are missing onyx updates currently fetched from the server) and then triggersvalidateAndApplyDeferredUpdatesenqueueAndProcess()combines the upper two functions by first enqueuing and then immediately processing the updates.clearmanually clears the deferred updates queue. By default, this unpauses theSequentialQueueas well.Fixed Issues
$ #40227
PROPOSAL:
Tests
To ensure the functionality from #39683 is preserverd:
App/src/libs/actions/Report.ts
Lines 769 to 789 in a4d01a8
Offline tests
Not needed.
QA Steps
Same as in Tests.
PR Author Checklist
### Fixed Issuessection aboveTestssectionOffline stepssectionQA stepssectiontoggleReportand notonIconClick)myBool && <MyComponent />.src/languages/*files and using the translation methodSTYLE.md) were followedAvatar, I verified the components usingAvatarare working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG))Avataris modified, I verified thatAvataris working as expected in all cases)Designlabel and/or tagged@Expensify/designso the design team can review the changes.ScrollViewcomponent to make it scrollable when more elements are added to the page.mainbranch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTeststeps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop