-
Notifications
You must be signed in to change notification settings - Fork 2.9k
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
Updated logic to handle unread messages case #25935
Updated logic to handle unread messages case #25935
Conversation
# Conflicts: # src/pages/home/report/ReportActionsList.js
# Conflicts: # src/pages/home/report/ReportActionsList.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.
Some issues with marker not being displayed when revisiting the chat after marking it as unread. DM'ed Eduardo
# Conflicts: # src/pages/home/report/ReportActionsList.js
@allroundexperts Please copy/paste the Reviewer Checklist from here into a new comment on this PR and complete it. If you have the K2 extension, you can simply click: [this button] |
@allroundexperts could you please take a look. |
# Conflicts: # src/pages/home/report/ReportActionsList.js
@MonilBhavsar conflicts solved |
On it! |
src/libs/actions/Report.js
Outdated
@@ -842,6 +842,8 @@ function readNewestAction(reportID) { | |||
* | |||
* @param {String} reportID | |||
* @param {String} reportActionCreated | |||
* | |||
* @returns {String} lastReadTime |
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 weird. I'm not sure if we're returning unrelated parameters from an action elsewhere. A better way would be to just use onyx to get lastReadTime
from the report.
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 was for emitting the even, but I will move the emitting into the function, so it won't need to return it
@@ -251,7 +252,8 @@ export default [ | |||
shouldShow: (type, reportAction, isArchivedRoom, betas, anchor, isChronosReport, reportID, isPinnedChat, isUnreadChat) => | |||
type === CONTEXT_MENU_TYPES.REPORT_ACTION || (type === CONTEXT_MENU_TYPES.REPORT && !isUnreadChat), | |||
onPress: (closePopover, {reportAction, reportID}) => { | |||
Report.markCommentAsUnread(reportID, reportAction.created); | |||
const lastReadTime = Report.markCommentAsUnread(reportID, reportAction.created); | |||
DeviceEventEmitter.emit(`unreadAction_${reportID}`, lastReadTime); |
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.
Can't we inside from inside the action? I think that would be better since we won't be requiring the action to return stuff.
cacheUnreadMarkers.delete(report.reportID); | ||
lastReadRef.current = newLastReadTime; | ||
setCurrentUnreadMarker(null); | ||
setMessageManuallyMarkedUnread(new Date().getTime()); |
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 haven't seen this event driven pattern used in our app before. Would you mind explaining why this is needed?
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.
Was added here point 3.
I just moved the code around because of conflicts. Basically setting a new number produces a rerender, but when is clean, setting 0, and we try to set 0 again, because it is 0 already no rerender event is fired
# Conflicts: # src/pages/home/report/ReportActionsList.js
@allroundexperts Conflicts solved + comments |
I just took a look at it, and the bug wasn't coming from our code, was coming from Screen.Recording.2023-11-15.at.21.07.08.mp4 |
Have you pushed the merge commit? @gedu |
@shubham1206agra @MonilBhavsar pushed the merge |
Checking again, because @MonilBhavsar can reproduce it, and I just could reproduce it again |
@gedu Can you check the repro on |
It is not reproducible on main for me |
Thanks! It works fine for me now. @shubham1206agra could you also please confirm, thanks |
@MonilBhavsar Working fine now |
Wohoo, thanks for confirming! |
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! 🚀
Thanks all!
Dismissed old PR reviewer checklist. |
✋ This PR was not deployed to staging yet because QA is ongoing. It will be automatically deployed to staging after the next production release. |
This PR might have caused this regression, generating an adhoc build to check. |
🧪🧪 Use the links below to test this adhoc build on Android, iOS, Desktop, and Web. Happy testing! 🧪🧪 |
Potential regressions: |
🚀 Deployed to production by https://github.com/luacmartins in version: 1.4.1-13 🚀
|
Is #31617 a regression of this PR? |
From what I tested it potentially is, but I didn't actually revert this PR to check, just tested the Adhoc build. |
// of the relevant reportActionID for displaying the green line. | ||
// We need to persist it across reports because there are at least 3 ReportScreen components created so the | ||
// internal states are resetted or recreated. | ||
const cacheUnreadMarkers = new Map(); |
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.
@gedu @MonilBhavsar Hey I'm working on a bug related to unread markers and I'm having trouble wrapping my head around this cache. What problem/scenario does it fix specifically? Like is there a scenario where when we switch away from a report and then navigate back, we want the unread marker to persist?
Details
Fixed Issues
$ #23171
PROPOSAL: -
Tests
Offline tests
QA Steps
PR Author Checklist
### Fixed Issues
section aboveTests
sectionOffline steps
sectionQA steps
sectiontoggleReport
and notonIconClick
)myBool && <MyComponent />
.src/languages/*
files and using the translation methodWaiting for Copy
label for a copy review on the original GH to get the correct copy.STYLE.md
) were followedAvatar
, I verified the components usingAvatar
are working as expected)/** comment above it */
this
are necessary to be bound (i.e. avoidthis.submit = this.submit.bind(this);
ifthis.submit
is never passed to a component event handler likeonClick
)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)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
Web
markingUnread_multiple_messages_chrome.mp4
markingUnread_multiple_messages_safari.mp4
Mobile Web - Chrome
markingUnread_multiple_messages_androidWeb.mp4
Mobile Web - Safari
markingUnread_multiple_messages_iPhoneWeb.mp4
Desktop
markingUnread_multiple_messages_desktop.mp4
iOS
markingUnread_multiple_messages_iPhone.mp4
Android
markingUnread_multiple_messages_android.mp4