topics_sidebar_actions: Update topics_sidebar to include unmute option.

Updated topics_sidebar_actions.hbs to include a option to add/remove
unmute visibility_policy for a topic is in a muted stream,
if in development environment.

Added 2 new classes sidebar-popover-unmute-topic and
sidebar-popover-remove-unmute for unmute topic option. Also, Renamed
previous sidebar-popover-unmute-topic to sidebar-popover-remove-mute.

Added 4 new click handlersthat uses
user_topics.set_user_topic_visibility_policy() to update
topic's visibility_policy.

Fixes #24244
This commit is contained in:
Hardik Dharmani 2023-04-11 11:19:17 +05:30 committed by Tim Abbott
parent aab252f657
commit 7105a232aa
3 changed files with 56 additions and 6 deletions

View File

@ -30,7 +30,6 @@ import {$t, $t_html} from "./i18n";
import * as message_edit from "./message_edit";
import * as message_edit_history from "./message_edit_history";
import * as message_lists from "./message_lists";
import * as muted_topics_ui from "./muted_topics_ui";
import * as narrow_state from "./narrow_state";
import * as popover_menus_data from "./popover_menus_data";
import * as popovers from "./popovers";
@ -43,6 +42,7 @@ import * as stream_popover from "./stream_popover";
import {parse_html} from "./ui_util";
import * as unread_ops from "./unread_ops";
import {user_settings} from "./user_settings";
import * as user_topics from "./user_topics";
let message_actions_popover_keyboard_toggle = false;
@ -307,13 +307,39 @@ export function initialize() {
return;
}
$popper.one("click", ".sidebar-popover-mute-topic", () => {
muted_topics_ui.mute_topic(stream_id, topic_name);
$popper.one("click", ".sidebar-popover-unmute-topic", () => {
user_topics.set_user_topic_visibility_policy(
stream_id,
topic_name,
user_topics.all_visibility_policies.UNMUTED,
);
instance.hide();
});
$popper.one("click", ".sidebar-popover-unmute-topic", () => {
muted_topics_ui.unmute_topic(stream_id, topic_name);
$popper.one("click", ".sidebar-popover-remove-unmute", () => {
user_topics.set_user_topic_visibility_policy(
stream_id,
topic_name,
user_topics.all_visibility_policies.INHERIT,
);
instance.hide();
});
$popper.one("click", ".sidebar-popover-mute-topic", () => {
user_topics.set_user_topic_visibility_policy(
stream_id,
topic_name,
user_topics.all_visibility_policies.MUTED,
);
instance.hide();
});
$popper.one("click", ".sidebar-popover-remove-mute", () => {
user_topics.set_user_topic_visibility_policy(
stream_id,
topic_name,
user_topics.all_visibility_policies.INHERIT,
);
instance.hide();
});

View File

@ -128,13 +128,17 @@ export function get_actions_popover_content_context(message_id) {
export function get_topic_popover_content_context({stream_id, topic_name, url}) {
const sub = sub_store.get(stream_id);
const topic_muted = user_topics.is_topic_muted(sub.stream_id, topic_name);
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 can_move_topic = settings_data.user_can_move_messages_between_streams();
return {
stream_name: sub.name,
stream_id: sub.stream_id,
stream_muted: sub.is_muted,
topic_name,
topic_muted,
topic_unmuted,
development_environment: page_params.development_environment,
can_move_topic,
is_realm_admin: page_params.is_admin,
topic_is_resolved: resolved_topic.is_resolved(topic_name),

View File

@ -8,6 +8,26 @@
<hr />
{{#if development_environment}}
{{#if stream_muted}}
{{#unless topic_unmuted}}
<li class="hidden-for-spectators">
<a tabindex="0" class="sidebar-popover-unmute-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
<i class="zulip-icon zulip-icon-mute" aria-hidden="true"></i>
{{t "Unmute topic (muted stream)"}}
</a>
</li>
{{else}}
<li class="hidden-for-spectators">
<a tabindex="0" class="sidebar-popover-remove-unmute" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
<i class="zulip-icon zulip-icon-mute" aria-hidden="true"></i>
{{t "Mute topic (muted stream)"}}
</a>
</li>
{{/unless}}
{{/if}}
{{/if}}
{{#unless topic_muted}}
<li class="hidden-for-spectators">
<a tabindex="0" class="sidebar-popover-mute-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
@ -17,7 +37,7 @@
</li>
{{else}}
<li class="hidden-for-spectators">
<a tabindex="0" class="sidebar-popover-unmute-topic" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
<a tabindex="0" class="sidebar-popover-remove-mute" data-stream-id="{{ stream_id }}" data-topic-name="{{ topic_name }}">
<i class="zulip-icon zulip-icon-mute" aria-hidden="true"></i>
{{t "Unmute topic"}}
</a>