-
Notifications
You must be signed in to change notification settings - Fork 3k
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
Add deferred updates queue functions to OnyxUpdateManager
to manually apply updates (e.g. from push notifications)
#42044
Conversation
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 |
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 |
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 :) |
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. |
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
OnyxUpdateManager
which let you manage the updates in the deferred updates queue. It particularly a clean interface to access and control deferred updates.The
DeferredOnyxUpdates
module mainly includes the following functions:enqueue()
let's you add updates to the queue. By default, this will automatically trigger processing these items withvalidateAndApplyDeferredUpdates
process()
waits for the currentqueryPromise
(when there are missing onyx updates currently fetched from the server) and then triggersvalidateAndApplyDeferredUpdates
enqueueAndProcess()
combines the upper two functions by first enqueuing and then immediately processing the updates.clear
manually clears the deferred updates queue. By default, this unpauses theSequentialQueue
as 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 Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodSTYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)StyleUtils.getBackgroundAndBorderStyle(theme.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label and/or tagged@Expensify/design
so the design team can review the changes.ScrollView
component to make it scrollable when more elements are added to the page.main
branch was merged into this PR after a review, I tested again and verified the outcome was still expected according to theTest
steps.Screenshots/Videos
Android: Native
Android: mWeb Chrome
iOS: Native
iOS: mWeb Safari
MacOS: Chrome / Safari
MacOS: Desktop