Skip to content

armgit / zulip

Public Imported from GitHub
0

Zulip server and web application. Open-source team chat that helps teams stay productive and focused.

left_sidebar: Add mark all messages unread to three dot topic menu.

roanster00704013cdec18e
diff --git a/web/src/popover_menus_data.js b/web/src/popover_menus_data.js
index cd7f1589104..3d6286ce49d 100644
--- a/web/src/popover_menus_data.js
+++ b/web/src/popover_menus_data.js
@@ -16,6 +16,7 @@ import * as settings_data from "./settings_data";
import * as starred_messages from "./starred_messages";
import * as stream_data from "./stream_data";
import * as sub_store from "./sub_store";
+import {num_unread_for_topic} from "./unread";
import {user_settings} from "./user_settings";
import * as user_status from "./user_status";
import * as user_topics from "./user_topics";
@@ -118,6 +119,7 @@ export function get_topic_popover_content_context({stream_id, topic_name, url})
const sub = sub_store.get(stream_id);
const topic_unmuted = user_topics.is_topic_unmuted(sub.stream_id, topic_name);
const has_starred_messages = starred_messages.get_count_in_topic(sub.stream_id, topic_name) > 0;
+ const has_unread_messages = num_unread_for_topic(sub.stream_id, topic_name) > 0;
const can_move_topic = settings_data.user_can_move_messages_between_streams();
const can_rename_topic = settings_data.user_can_move_messages_to_another_topic();
const visibility_policy = user_topics.get_topic_visibility_policy(sub.stream_id, topic_name);
@@ -133,6 +135,7 @@ export function get_topic_popover_content_context({stream_id, topic_name, url})
is_realm_admin: page_params.is_admin,
topic_is_resolved: resolved_topic.is_resolved(topic_name),
has_starred_messages,
+ has_unread_messages,
url,
visibility_policy,
all_visibility_policies,
diff --git a/web/src/topic_popover.js b/web/src/topic_popover.js
index ddd8e0bd859..7f7d5790888 100644
--- a/web/src/topic_popover.js
+++ b/web/src/topic_popover.js
@@ -123,6 +123,11 @@ export function initialize() {
instance.hide();
});
+ $popper.one("click", ".sidebar-popover-mark-topic-unread", () => {
+ unread_ops.mark_topic_as_unread(stream_id, topic_name);
+ instance.hide();
+ });
+
$popper.one("click", ".sidebar-popover-delete-topic-messages", () => {
const html_body = render_delete_topic_modal({topic_name});
diff --git a/web/src/unread_ops.js b/web/src/unread_ops.js
index a64852df68c..8cfb895a56e 100644
--- a/web/src/unread_ops.js
+++ b/web/src/unread_ops.js
@@ -498,6 +498,20 @@ export function mark_topic_as_read(stream_id, topic) {
);
}
+export function mark_topic_as_unread(stream_id, topic) {
+ bulk_update_read_flags_for_narrow(
+ [
+ {operator: "stream", operand: stream_id},
+ {operator: "topic", operand: topic},
+ ],
+ "remove",
+ {
+ stream_id,
+ topic,
+ },
+ );
+}
+
export function mark_all_as_read() {
bulk_update_read_flags_for_narrow(all_unread_messages_narrow, "add");
}
diff --git a/web/templates/topic_sidebar_actions.hbs b/web/templates/topic_sidebar_actions.hbs
index 07b1274b1ea..d45dedc684e 100644
--- a/web/templates/topic_sidebar_actions.hbs
+++ b/web/templates/topic_sidebar_actions.hbs
@@ -35,12 +35,21 @@
</li>
{{/if}}
+ {{#if has_unread_messages}}
<li class="topic-menu-item hidden-for-spectators">
<a tabindex="0" class="sidebar-popover-mark-topic-read" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
<i class="fa fa-book" aria-hidden="true"></i>
{{t "Mark all messages as read"}}
</a>
</li>
+ {{else}}
+ <li class="topic-menu-item hidden-for-spectators">
+ <a tabindex="0" class="sidebar-popover-mark-topic-unread" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
+ <i class="fa fa-book" aria-hidden="true"></i>
+ {{t "Mark all messages as unread"}}
+ </a>
+ </li>
+ {{/if}}
<li class="topic-menu-item">
<a tabindex="0" class="sidebar-popover-copy-link-to-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}" data-clipboard-text="{{ url }}">