-
-
Notifications
You must be signed in to change notification settings - Fork 8.1k
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
message view: Do not mark selected message as read on narrow. #16313
base: main
Are you sure you want to change the base?
Conversation
Hello @zulip/server-message-view members, this pull request was labeled with the "area: message view" label, so you may want to check it out! |
static/js/message_scroll.js
Outdated
@@ -166,7 +166,7 @@ exports.initialize = function () { | |||
|
|||
// Scroll handler that marks messages as read when you scroll past them. | |||
$(document).on("message_selected.zulip", (event) => { | |||
if (event.id === -1) { | |||
if (event.id === -1 || event.id === event.previously_selected) { |
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 wonder if a good follow up fix here would be to rename event.id
and event.previously_selected
. It's not obvious that either is a message id, and when you look at this code out of context, it seems funny to compare those two things.
7c62ca5
to
e8a7d6d
Compare
e8a7d6d
to
4b4e683
Compare
I merged the first commit, which is a nice refactor; we might also want to rename |
On activating a narrow we always mark the first message it selects as read, which is usually the first unread message. This behaviour is unwanted. The flow is as follows: * On activating the narrow we call the `MessageList.select_id` method along with a `force_rerender` param. Here event = { id: X, previously_selected_id: -1, ... } where X = the first unread message id to be selected. * Due to this `force_rerender` field, we first call the `rerender` method and then trigger our custom event handler (`message_selected.zulip`) which is responsible for marking message as read. * However, due to this call path: `this.select_id` > `this.rerender` > `this.rerender_view` > `this.redo_selection` > `this.select_id`, the `message_selected.zulip` event gets triggered with event as = { id: X, previously_selected_id: X, ... } * Thus the second selection event gets triggered before the first one having the current and previous id equal to "X". This above `id = previously_selected_id` consition only occurs for narrow activation (due to the `force_rerender` flag) or when a message is selected again by clicking on it (message is already read in this case). For the All Messages view we have similar logic where, we pass `mark_read` as false (which was previously unused) which skips the "message_selected.zulip" event in `message_scroll.js`. Work towards zulip#10886.
Hello @ryanreh99, it seems like you have referenced #10886 in your pull request description, but you have not referenced them in your commit message description(s). When you reference an issue in a commit message, it automatically closes the corresponding issue when the commit is merged. Please run An example of a correctly-formatted commit:
Thank you for your contributions to Zulip! |
I rebased this and reworded the commit message and removed The commit message explains why the Now to begin marking messages as read, the user has to interact with the middle message feed. Also, one point to note is that due to the above condition above it seems that the following flow interaction occurs:
However the reselected message does gets marked as read due to this event handler. |
So, thinking about this PR, I had been envisioning a different approach for fixing #10886, where we'd:
I think that's a more intuitive model, since then we preserve the property that selecting a message marks it as read, rather than it depending how you ended up selecting the message. Thoughts? |
Heads up @ryanreh99, we just merged some commits that conflict with the changes you made in this pull request! You can review this repository's recent commits to see where the conflicts occur. Please rebase your feature branch against the |
4ec3636
to
88b200c
Compare
I have another branch where I'm working on the last read message selection approach.
Now, the selected message isn't read when the message list initially renders,
for the narrows in the left sidebar.
The entire message list gets marked as read if the bottom message is visible
when the narrow activates, this behavior remains the same .
Also works for the All Messages view.
WIP as tests are remaining and I'll do some more manual testing.
Fixes #10886.