-
Notifications
You must be signed in to change notification settings - Fork 13k
regression: unread banner appears for thread messages after channel creation #36331
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
Conversation
…reation Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
|
Looks like this PR is ready to merge! 🎉 |
|
| return; | ||
| } | ||
| setMessageJumpQueryStringParameter(message?._id); | ||
| chat.readStateManager.markAsRead(); |
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 seemed to be a fix for me. While clicking on the banner, It would take me to message. But when page is refreshed, the banner would reapper.
|
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## release-7.8.0 #36331 +/- ##
=================================================
- Coverage 64.55% 64.54% -0.01%
=================================================
Files 3147 3147
Lines 104629 104629
Branches 19766 19766
=================================================
- Hits 67544 67538 -6
- Misses 34401 34406 +5
- Partials 2684 2685 +1 🚀 New features to boost your workflow:
|
MartinSchoeler
left a comment
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.
Do we know the root cause of the issue (in what PR the bug was introduced)? Here it seems we are only patching the symptom, not actually fixing the root cause of the issue.
I think we can dive a little deeper and come up with a more elegant solution.
| [getMessage, setUnreadCount], | ||
| ); | ||
|
|
||
| useEffect(() => { |
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.
Could we find an alternative to this use effect? As it is, this is going to run every time the messagesCount prop changes (basically on every message). It seems costly for an operation that only needs to happen when the room is initialized.
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.
Actually this will run only once. In first run, the lastMessageDate will be set and there is a check to return early when lastMessageDate is set.
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.
Also, this is not expensive tasks. It is used only at one or two places all over the client. Plus it only runs once and loops around few messages. Next runs, it returns early. I dont think it is expensive.
| (a, b) => b.ts.getTime() - a.ts.getTime(), | ||
| ); | ||
| if (newest) { | ||
| setLastMessageDate(newest.ts); |
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.
We should avoid changing the value of a state that is in the dependency list
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.
same.
This will always return nothing sinc lastMessageDate is undefined. This will always return a number > 0 if lastMessageDate is undefined. |
I think we could fix the issue here, add an exception before we filter the messages since when the lastMessage is undefined, the filter does nothing (since infinity will always be larger). just by doing the issue seems to go away (just an example, need testing), so I think we don't need another useEffect, just to adjust the existing one Also it seems that this issue was introduced in #36158 |
Yes it will go back to the previous behavior. But still the issue with how we calculate lastMessageDate will remain same. It will be undefined for new rooms. Since there wont be enough messages which will cause a message to go invisible. And hence unread message banner might not show for new rooms. |
Signed-off-by: Abhinav Kumar <abhinav@avitechlab.com>
|
Behavior matches version 7.7.0 |
Proposed changes (including videos or screenshots)
When you create a brand-new channel and immediately reply to your own message in a thread, the unread-messages banner was showing up even though you hadn’t missed anything. This happened because the baseline timestamp (lastMessageDate) stayed undefined until an off-screen message was detected, so every reply looked like “new” content. Now, on first load—when the message count goes from zero to some number—we set lastMessageDate to the newest message’s timestamp, giving the unread-count logic a proper anchor and preventing self-sent thread replies from ever triggering the banner.
Issue(s)
Steps to test or reproduce
Further comments
CORE-1214