-
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
check if reports data is up to date before update last read action id #6095
check if reports data is up to date before update last read action id #6095
Conversation
CLA Assistant Lite bot All contributors have signed the CLA ✍️ ✅ |
I have read the CLA Document and I hereby sign the CLA |
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.
A few minor changes, I'm going to add another reviewer into the mix as well
@parasharrajat (it says your busy so lmk if you'd rather ignore) or @Beamanator did you want to do a secondary review? |
Updated. And waiting for secondary review by one of the other engineers |
@johnmlee101 Thanks for tagging in. Yup, I was busy but now I am available so reviewing it. |
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.
The code looks good. I have not tested it with the reproduction steps but I presume that it is working.
Just tested it on the Web with the exact reproduction steps and it is working well.
# Conflicts: # src/libs/actions/Report.js # src/pages/home/report/ReportActionsView.js
# Conflicts: # src/libs/actions/Report.js
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.
I'm happy that this solution works, but I think we can make it better if we prevent updates during consecutive loads as well
The vast majority of the time the bug would happen during startup, but there's always a chance that on a consecutive fetch something that we don't have locally might come
One of the potential cases is when we suspend the app for a long time then resume the app - see onVisibilityChange
. When we focus the app there's a call that would again fetch reports, but we might false set a last read if the call hasn't completed yet.
While the app is suspended we can't guarantee it has received all updates I guess that's why we're re-fetching reports on focus
I think we should go with something like: if reports are loading don't update the last read message
- in case something new comes - we have new messages
- if nothing new comes - we haven't falsely marked it as unread
So instead of preventing setting last read only during initial report loading, we can prevent it if it happens during report loading in general
src/libs/actions/Report.js
Outdated
function isReportDataUptoDate() { | ||
return isReportDataFresh; | ||
} |
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 not really telling us whether report data is up to date, but whether initial report fetching is over.
The return value will stay true
ever since
Without a server check we can't reliably know whether we're up to date, we can only guess that we're not
To know whether we're synced we should at least check
- we're online
- we're connected to pusher
- we have no pending request regarding reports (or anything)
Then, yes we're probably up to date
IMO the variable should be renamed to isReportDataLoading
or isReportDataLoaded
and should be updated at the start of the load and at then end, similarly to how fetchActionsWithLoadingState
works
If that's the case we might also put in in ONYXKEYS e.g. isReportDataLoading
and then subscribe the ReportActionsView
to that key
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.
I agree. It's a better solution to use a more generic approach like this. I added a new ONYX KEY called IS_LOADING_REPORT_DATA
. I chose that name to keep it the same way the existing loading keys.
This key is set in the fetchAllReports
function and it updates the variable called ´isReportDataLoading´ in the Report.js. It is not necessary to subscribe the view to that key, because I moved the if
statement inside the updateLastReadID
like you suggested
if (!this.props.isDrawerOpen) { | ||
Report.updateLastReadActionID(this.props.reportID); | ||
if (Report.isReportDataUptoDate()) { | ||
Report.updateLastReadActionID(this.props.reportID); | ||
} | ||
} |
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.
It might be better to move this check inside updateLastReadActionID
There are other places that could call updateLastReadActionID
while data is still being fetch
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.
Done
…n checks its value before to update a sequence number
Updated regarding @kidroca suggestions. |
Dropping this link in here so we'll hopefully get a ping when this closes, we're holding on it #3981 |
Waiting for @johnmlee101 review |
Was busy last week, looking now! |
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 good to me! @kidroca did you want a final pass of review?
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.
thanks @johnmlee101 LGTM!
@jolivervidal, Great job getting your first Expensify/App pull request over the finish line! 🎉 I know there's a lot of information in our contributing guidelines, so here are some points to take note of 📝:
So it might take a while before you're paid for your work, but we typically post multiple new jobs every day, so there's plenty of opportunity. I hope you've had a positive experience contributing to this repo! 😊 |
✋ 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 @johnmlee101 in version: 1.1.15-18 🚀
|
🚀 Deployed to production by @roryabraham in version: 1.1.16-10 🚀
|
Details
Verification added for updating the list of unread messages only if the reports data is up to date
Fixed Issues
$ #5405
Tests
QA Steps
The same steps as above
Tested On
Screenshots
Web
Mobile Web
Desktop
iOS
Android