Zulip server and web application. Open-source team chat that helps teams stay productive and focused.
left_sidebar: Show `Mark all messages as unread` in channel popover.
Harsh60c6af2ab4a7
diff --git a/web/src/stream_popover.ts b/web/src/stream_popover.tsindex 184ec29a8e2..11873a19919 100644--- a/web/src/stream_popover.ts+++ b/web/src/stream_popover.ts@@ -35,6 +35,7 @@ import * as stream_settings_ui from "./stream_settings_ui.ts";import * as sub_store from "./sub_store.ts";import * as ui_report from "./ui_report.ts";import * as ui_util from "./ui_util.ts";+import * as unread from "./unread.ts";import * as unread_ops from "./unread_ops.ts";import {user_settings} from "./user_settings.ts";import * as util from "./util.ts";@@ -102,11 +103,15 @@ function build_stream_popover(opts: {elt: HTMLElement; stream_id: number}): voidconst show_go_to_channel_feed =user_settings.web_channel_default_view !==web_channel_default_view_values.channel_feed.code;+ const stream_unread = unread.unread_count_info_for_stream(stream_id);+ const stream_unread_count = stream_unread.unmuted_count + stream_unread.muted_count;+ const has_unread_messages = stream_unread_count > 0;const content = render_left_sidebar_stream_actions_popover({stream: {...sub_store.get(stream_id),url: browser_history.get_full_url(stream_hash),},+ has_unread_messages,show_go_to_channel_feed,});@@ -175,6 +180,14 @@ function build_stream_popover(opts: {elt: HTMLElement; stream_id: number}): voide.stopPropagation();});+ // Mark all messages in stream as unread+ $popper.on("click", ".mark_stream_as_unread", (e) => {+ const sub = stream_popover_sub(e);+ hide_stream_popover(instance);+ unread_ops.mark_stream_as_unread(sub.stream_id);+ e.stopPropagation();+ });+// Mute/unmute$popper.on("click", ".toggle_stream_muted", (e) => {const sub = stream_popover_sub(e);diff --git a/web/src/unread_ops.ts b/web/src/unread_ops.tsindex b9d54b075e8..570bee11fce 100644--- a/web/src/unread_ops.ts+++ b/web/src/unread_ops.ts@@ -637,6 +637,13 @@ export function mark_stream_as_read(stream_id: number): void {);}+export function mark_stream_as_unread(stream_id: number): void {+ bulk_update_read_flags_for_narrow(+ [{operator: "channel", operand: stream_id.toString()}],+ "remove",+ );+}+export function mark_topic_as_read(stream_id: number, topic: string): void {bulk_update_read_flags_for_narrow([diff --git a/web/templates/popovers/left_sidebar/left_sidebar_stream_actions_popover.hbs b/web/templates/popovers/left_sidebar/left_sidebar_stream_actions_popover.hbsindex 3d6602b8bd1..c0f9e928149 100644--- a/web/templates/popovers/left_sidebar/left_sidebar_stream_actions_popover.hbs+++ b/web/templates/popovers/left_sidebar/left_sidebar_stream_actions_popover.hbs@@ -9,12 +9,21 @@<span class="popover-stream-name">{{stream.name}}</span></li><li role="separator" class="popover-menu-separator"></li>+ {{#if has_unread_messages}}<li role="none" class="link-item popover-menu-list-item hidden-for-spectators"><a role="menuitem" class="mark_stream_as_read popover-menu-link" tabindex="0"><i class="popover-menu-icon zulip-icon zulip-icon-mark-as-read" aria-hidden="true"></i><span class="popover-menu-label">{{t "Mark all messages as read"}}</span></a></li>+ {{else}}+ <li role="none" class="link-item popover-menu-list-item hidden-for-spectators">+ <a role="menuitem" class="mark_stream_as_unread popover-menu-link" tabindex="0">+ <i class="popover-menu-icon zulip-icon zulip-icon-mark-as-unread" aria-hidden="true"></i>+ <span class="popover-menu-label">{{t "Mark all messages as unread"}}</span>+ </a>+ </li>+ {{/if}}{{#if show_go_to_channel_feed}}<li role="none" class="link-item popover-menu-list-item"><a role="menuitem" class="stream-popover-go-to-channel-feed popover-menu-link" tabindex="0">