From 2e03e1b6ee4c51b36db7a8ac6e396f1cba29316c Mon Sep 17 00:00:00 2001 From: Lauryn Menard Date: Wed, 14 Jun 2023 18:40:44 +0200 Subject: [PATCH] narrow: Mark as read in `by_recipient` based on case ("dm" or "stream"). In commit #25837, we added in a check for the user's mark as read policy in the frontend for `by_topic` and `by_recipient` narrowing. In that change, the assumption was that for both functions, it was sufficient to check only for whether the user policy was to never mark as read. But because the `by_recipient` function may narrow to an interleaved stream view, it is possible that message will be marked as read when the user did not expect it to be (e.g. they marked all the messages in a topic narrow as unread and then used the `S` key shortcut to navigate back to the stream view) when they have conversation views only as their mark as read policy. Here we move the check for the user's mark as read policy to be in the two cases for `by_recipient` so that the mark as read behavior here matches the user's setting. (cherry picked from commit c5fbd3f085dbfd7f62d04b582ce67b5dda2cc819) --- web/src/narrow.js | 31 ++++++++++++++++++++----------- 1 file changed, 20 insertions(+), 11 deletions(-) diff --git a/web/src/narrow.js b/web/src/narrow.js index dd6cb1e34a..e837fc6308 100644 --- a/web/src/narrow.js +++ b/web/src/narrow.js @@ -928,23 +928,32 @@ export function by_recipient(target_id, opts) { // don't use message_lists.current as it won't work for muted messages or for out-of-narrow links const message = message_store.get(target_id); - if ( - user_settings.web_mark_read_on_scroll_policy !== - web_mark_read_on_scroll_policy_values.never.code - ) { - // We don't check message_list.can_mark_messages_read - // here because the target message_list isn't initialized; - // but the targeted message is about to be marked read - // in the new view. - unread_ops.notify_server_message_read(message); - } - switch (message.type) { case "private": + if ( + user_settings.web_mark_read_on_scroll_policy !== + web_mark_read_on_scroll_policy_values.never.code + ) { + // We don't check message_list.can_mark_messages_read + // here because the target message_list isn't initialized; + // but the targeted message is about to be marked read + // in the new view. + unread_ops.notify_server_message_read(message); + } by("dm", message.reply_to, opts); break; case "stream": + if ( + user_settings.web_mark_read_on_scroll_policy === + web_mark_read_on_scroll_policy_values.always.code + ) { + // We don't check message_list.can_mark_messages_read + // here because the target message_list isn't initialized; + // but the targeted message is about to be marked read + // in the new view. + unread_ops.notify_server_message_read(message); + } by("stream", message.stream, opts); break; }