-
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
[CP Staging] Fix regression marking as read report that is not focused #35292
[CP Staging] Fix regression marking as read report that is not focused #35292
Conversation
@abdulrahuman5196 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] |
@abdulrahuman5196 @hayata-suenaga As this is linked to 2 deploy blockers let's fix it ASAP. |
@@ -413,10 +414,15 @@ function ReportActionsList({ | |||
}, [calculateUnreadMarker, report.lastReadTime, messageManuallyMarkedUnread]); | |||
|
|||
const onVisibilityChange = useCallback(() => { | |||
if (report.reportID !== Navigation.getTopmostReportId()) { |
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.
@FitseTLT @abdulrahuman5196 Sorry for chiming in but I think it's better to move this check to before this line, to avoid redundant orphaned listeners that are of no use, especially if the user has a ton of chat.
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.
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.
Moreover, we don't render more than 5 report screens on the stack so no serious performance loss with the
current approach.
@FitseTLT it's not serious performance loss but I also don't see why we should keep those stale listeners, while removing listeners if not in use doesn't have any drawback and is definitely better (although not hugely better, but a lot of small optimizations will make the app smoother in aggregate)
With the current requirement we are running our effect based on visibilty
which means if we unregister the listener on losing focus our effect will
not run, for instance, when the RHp is open. Moreover, we don't render more
than 5 report screens on the stack so no serious performance loss with the
current approach.
…On Mon, 29 Jan 2024, 08:40 abdulrahuman5196, ***@***.***> wrote:
***@***.**** commented on this pull request.
------------------------------
In src/pages/home/report/ReportActionsList.js
<#35292 (comment)>:
> @@ -413,10 +414,15 @@ function ReportActionsList({
}, [calculateUnreadMarker, report.lastReadTime, messageManuallyMarkedUnread]);
const onVisibilityChange = useCallback(() => {
+ if (report.reportID !== Navigation.getTopmostReportId()) {
@FitseTLT <https://github.com/FitseTLT> I think its fine to add the check
at both places(the current one and the focus check suggested) which provide
more rigid check and avoid stale listeners. Any reason we don't want the
focus check? @FitseTLT <https://github.com/FitseTLT>
—
Reply to this email directly, view it on GitHub
<#35292 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AJG4AZLNTU3CAGN4YQP4EW3YQ4Y5PAVCNFSM6AAAAABCOM5YSSVHI2DSMVQWIX3LMV43YUDVNRWFEZLROVSXG5CSMV3GSZLXHMYTQNBXHA3DKNJUGM>
.
You are receiving this because you were mentioned.Message ID:
***@***.***>
|
@FitseTLT This should be expected IMO. The unread should update only when its in view. |
@FitseTLT @abdulrahuman5196 This is a last deploy blocker, what are the next steps? |
@abdulrahuman5196 Unregistering a visibility change listener on focus event change is not at all the right thing to do. If we decide to unregister stale listeners it should be when the top most report id changes and in terms of performance it will be a trade-off between do we want early return on visibility change listener (given that there will only be at most 5 report screen in the stack) or do we want to register unregister everytime a top-most report changes. |
@FitseTLT I partially agree to your callouts. So focus check is also required here IMO. Also fine it can be achieved in different way without re-register. Correct me if wrong @mountiny |
FYI: @FitseTLT I have edited my above comment - #35292 (comment) |
I think it's good practice to unsubscribe listeners when they are not in use, we already did the same in the ReportActionsList. Register unregister listeners are lightweight operation, keeping 5 of them running at the same time is not 😄. |
@abdulrahuman5196 I don't think running the effect on visibility event but early return when the screen is not focus is a consistent approach, these are two different events. The ideal approach is to totally change our approach of running the effect on visibility change to focus event change but it will definitely have it's own complications but we can give it a try. |
Given there is not clear consensus about best approach and the staging regression is done, I will proceed with revert of the original PR and we can make these decisions on the original PR so we are sure we are implementing the best code possible. |
Details
Fixed Issues
$ #33680
$ #35251
PROPOSAL:
Tests
Login with User B and open a chat with User A and change to another tab on web
Now Send a message as User A to User B
Wait until the message arrives at User B and now as User B switch back to the tab you were chatting in (1)
Check that the LHN is not bold
Verify that unread marker indicates on the new message you sent in (2)
[User B Desktop] Open any report other than report with User A.
[User A web] Send a message to User B.
[User B Desktop] Without opening chat with User A, focus the window on the desktop app.
Verify that it is bold in LHN for the chat with User A
Open the chat and check unread marker is displayed properly
Switch to other chat and come back to it and check that now the marker is cleared
Offline tests
same
QA Steps
same
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)StyleUtils.getBackgroundAndBorderStyle(themeColors.componentBG)
)Avatar
is modified, I verified thatAvatar
is working as expected in all cases)Design
label 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
upl.mp4
iOS: Native
ios.mp4
iOS: mWeb Safari
ios.web.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4