-
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
Fix new message is shown when send message #51113
Fix new message is shown when send message #51113
Conversation
@ikevin127 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] |
I can't send message on android mWeb. android.mweb.mp4 |
@bernhardoj Thanks, this looks good and works well in all tests, except for this 1 issue: Tip Steps to reproduce
issue-1.mov |
…rom current user message
@@ -223,7 +226,7 @@ function ReportActionsList({ | |||
const isNextMessageRead = !nextMessage || !isMessageUnread(nextMessage, unreadMarkerTime); | |||
const shouldDisplay = isCurrentMessageUnread && isNextMessageRead && !ReportActionsUtils.shouldHideNewMarker(reportAction); | |||
const isWithinVisibleThreshold = scrollingVerticalOffset.current < MSG_VISIBLE_THRESHOLD ? reportAction.created < (userActiveSince.current ?? '') : true; | |||
return shouldDisplay && isWithinVisibleThreshold; | |||
return shouldDisplay && isWithinVisibleThreshold && !lastActionAddedByCurrentUser.current; |
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.
Fixed by changing the check here to return false as long as lastActionAddedByCurrentUser
exists. What happened before is, we only store the last action in lastActionAddedByCurrentUser
. So, when we send message 1,2,3, the lastActionAddedByCurrentUser
will be 3 and unreadMarkerTime
is updated to 3's created
.
When we receive the BE response, the 1 created
value will be bigger than the optimistic 3 created
value and previously, we only prevent the unread marker to show if lastActionAddedByCurrentUser
is the same as the action that is being checked.
@bernhardoj Thanks, #51113 (comment) fixed the issue I reported here for large layout devices (Web / Desktop) but it seems to still be reproducible only on Android: mWeb for example (second half, the offline -> online case): android-mweb.webm |
Ah, that's because |
I have a new idea to solve it, but still fails for manually mark as unread. |
@bernhardoj I don't know if it's worth fixing the Android: mWeb only edge case at the expense of the manually mark as unread functionality. I vote to leave it as is now as the only edge case is happening on Android: mWeb and only in this scenario:
@MonilBhavsar What do you think ? |
@ikevin127 hmm, but this will still happen too. Here is my new idea. So, the base of the idea is, if the message is new or if it's previously an optimistic one and it's the current user message, then don't show the unread marker. How do we know this without
We can know that by comparing the current action with the previous action. So first, we need to convert the actions array to an object first, so it can easily be looked up through App/src/pages/home/report/ReportActionsList.tsx Lines 188 to 200 in f251dbc
In App/src/pages/home/report/ReportActionsList.tsx Lines 219 to 227 in f251dbc
// This checks if the message from the current user
const isFromCurrentUser = accountID === (ReportActionsUtils.isReportPreviewAction(reportAction) ? !reportAction.childLastActorAccountID : reportAction.actorAccountID);
// This checks if it's a new message. It's a new message if it's not available in the previous actions
const isNewMessage = !prevSortedVisibleReportActionsObjects[reportAction.reportActionID];
// This checks if it's previously an optimistic message
const isPreviouslyOptimistic = !!prevSortedVisibleReportActionsObjects[reportAction.reportActionID]?.isOptimisticAction && !reportAction.isOptimisticAction;
// All combined
const shouldIgnoreUnreadForCurrentUserMessage = isFromCurrentUser && (isNewMessage || isPreviouslyOptimistic); So, when the user adds a message, However, we still have a manual mark as unread for
I expected in step 3, the unread marker stays, but it disappeared. In I'm not suggesting removing
It's not the best in terms of performance since we need to convert the array to an object, but I think it's much more reliable than the other solution that we explored. @ikevin127 Let me know if that makes sense to you! |
@bernhardoj Thanks for the detailed explanation! Given my statement from #51113 (comment), looks like that would be one option in terms of compromising. If you were to apply the solution you suggested above, what would be the drawbacks of that in terms of functionality other than the performance of array -> object ? ? Meaning if we apply that solution would:
all of these scenarios pass the test ? From what I can tell currently it looks like we would have to compromise somewhere, am I wrong and we can have all these working ? |
So far it works well on all those cases.
web.1.mp4
web.2.mp4
web.3.mp4
web.4.mp4Notice the unread marker disappears when go online as I mentioned before
Here is the video showing the unread marker stays when removing web.5.mp4 |
@bernhardoj I appreciate the tests for each case! I'm fine with the behaviour of the second to last video, meaning keeping You can proceed with the changes and I will test again before moving forward with completing the checklist and approving. |
@ikevin127 done. Please check! 🙇 |
Reviewer Checklist
Screenshots/VideosAndroid: Nativeandroid.webmAndroid: mWeb Chromeandroid-mweb.webmiOS: Nativeios.mp4iOS: mWeb Safariios-mweb.mp4MacOS: Chrome / Safariweb.movMacOS: Desktopdesktop.mov |
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.
@bernhardoj Thanks for the updates, code looks solid! 🎉
🟢 I just retested all scenarios including testing against the current staging build to ensure nothing was changed except related to our fix and all tests pass now, including on Android: mWeb where we had the issues with the marker not going away when returning online.
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, thank you all! 🚀
✋ 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/MonilBhavsar in version: 9.0.55-0 🚀
|
🚀 Deployed to production by https://github.com/Beamanator in version: 9.0.55-10 🚀
|
Details
When the current user sends a message, an unread marker is shown.
Fixed Issues
$ #50469
PROPOSAL: #50469 (comment)
Tests
Same as QA Steps
Offline tests
Same as QA Steps
QA Steps
*an easier way is to go offline and no need to immediately scroll to the top, especially on small screen
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.mp4
Android: mWeb Chrome
iOS: Native
ios.mp4
iOS: mWeb Safari
ios.mweb.mp4
MacOS: Chrome / Safari
web.mp4
MacOS: Desktop
desktop.mp4