-
Notifications
You must be signed in to change notification settings - Fork 2.8k
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
[HOLD - Functionality][NewFeature-Rework] Automatic scrolling to the top of report's new unread message marker #42217
Conversation
…read message marker
@mollfpr This has been ready for review for the past 2 weeks. Note: just synced w/ main to resolve conflicts. |
Sorry for the delay 🙏 I'll finish the review today. |
When testing this, we have to make sure these issues are not reproducible:
in order to avoid any other regressions which could lead to PR revert again 🤞 |
Posted here to get other c+ take over. |
@ikevin127 you have conflicts.. |
@ishpaul777 Solved, ready for 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.
Only minor comments testing is ongoing..
@@ -2,7 +2,14 @@ import type {FlatListRefType} from '@pages/home/ReportScreenContext'; | |||
|
|||
type ReportScrollManagerData = { | |||
ref: FlatListRefType; |
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.
lets add a comment for ref also ?
@@ -514,6 +514,45 @@ function ReportActionsList({ | |||
calculateUnreadMarker(); | |||
}, [calculateUnreadMarker, report.lastReadTime, messageManuallyMarkedUnread]); | |||
|
|||
function onItemLayout(index: number) { | |||
return () => DeviceEventEmitter.emit('renderedItemIndex', index); |
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.
lets use a constant for renderedItemIndex
Reviewer Checklist
Screenshots/VideosAndroid: NativeAndroid: mWeb ChromeiOS: NativeiOS: mWeb SafariMacOS: Chrome / SafariScreen.Recording.2024-06-08.at.2.21.53.AM-1.movMacOS: Desktop |
There's a bug on main ios which prevents me testing for this issue. New line marker hides immediately when opening a unread chat. Steps:
Screen.Recording.2024-06-08.at.10.01.28.PM-1.mov |
@ishpaul777 You're saying this bug is on main or only on this PR ? If it is on main (not related to this PR), there's another thing you can do on any platform to test this. For example on iOS: Native:
Note: Not sure if this will work regardless of the main bug mentioned, but it should since you are marking as unread from the client-side instead of BE doing it. I will to confirm whether this bug is on main or caused by the PR. |
This comment was marked as outdated.
This comment was marked as outdated.
I verified that this is also reproducable on main, so might not be related to this PR |
nvm, the bug i mentioned is only for new messages the alternative steps works. |
Our logic depends on whether the Message is rendered in the Flatlist, but it fails in case unread message is not in first batch of rendering then user scroll to top only when the message is rendered, i wont say this is bug but still a weird behavior from user perspective Wdyt? @ikevin127 Screen.Recording.2024-06-09.at.12.57.21.AM.mov |
@ishpaul777 Good catch! It's true that if you open a report for the first time (after app is opened), there's a certain batch that's going to be rendered (128-168) messages depending on the platform / screen size ( But in the real world there could be a case where say a user is invited to a report and they actually login into the app at a later point where people already sent 200+ messages, case in which this functionality won't work in scrolling to the unread message marker since this is not rendered yet. What I can try and do to have this functionality work as expected regardless of the index of the unread message within a report is:
This would look good from a UI/UX perspective and would be fool-proof functionality wise. I'll put this on HOLD until I test / implement this idea and will let you know if it's doable and works as expected. |
@ishpaul777 I tried to implement the functionality proposed in my previous comment but it doesn't work because of the way our current logic works:
Given this, there's no way to automatically scroll past the first batch given the current logic because the So this PR's logic only works when a user already opened the report, they received some new messages and they open the report again - which defeats the purpose of this
The current PR achieves none of these 3, but only a reduced version of number (3.), therefore I will close it and call it quits since this is above my level of technicality given the current app logic. |
Details
We need a new useEffect within the
ReportActionsList
component which willscrollToUnreadMessageIndex
when we open the report which has lots of unread messages (going out of messages initial view), using the DeviceEventEmitter listener.To do this we modified our existing
reportScrollManager.scrollToIndex
function to optionally take in theviewPosition
argument because we're inverting the flatlist which means that we would need to passviewPosition: 1
to the FlatList'sscrollToIndex
function such that we are scrolling to the top of the new message (unread marker).Fixed Issues
$ #35011
PROPOSAL: #35011 (comment)
Tests
Additionally, make sure these issues are not reproducible while testing:
[HOLD for payment 2024-05-22] Chat - After marking a message as unread, sending a new message causes the chat to scroll up #42100
Chat - App fails to scroll chat to the first unread message in offline mode #42148
making sure any other previously existing report scrolling functionality will not be affected by this solution
Verify that no errors appear in the JS console
Offline tests
TLDR: same as Tests.
QA Steps
TLDR: same as 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.mov
Android: mWeb Chrome
android-mweb.mp4
iOS: Native
ios.mov
iOS: mWeb Safari
ios-mweb.mp4
MacOS: Chrome / Safari
web.mov
MacOS: Desktop
desktop.mp4