recent_topics_ui: Cut dependency on `muted_topics_ui.js`.

This commit is contained in:
Lalit 2023-06-28 16:54:25 +05:30 committed by Tim Abbott
parent 9447381d03
commit 65d49b5ad8
4 changed files with 26 additions and 16 deletions

View File

@ -22,7 +22,6 @@ import * as hashchange from "./hashchange";
import * as message_edit from "./message_edit";
import * as message_lists from "./message_lists";
import * as message_store from "./message_store";
import * as muted_topics_ui from "./muted_topics_ui";
import * as narrow from "./narrow";
import * as navigate from "./navigate";
import {page_params} from "./page_params";
@ -388,7 +387,7 @@ export function initialize() {
// Mute topic in a unmuted stream
$("body").on("click", ".message_header .stream_unmuted.on_hover_topic_mute", (e) => {
e.stopPropagation();
muted_topics_ui.mute_or_unmute_topic(
user_topics.set_visibility_policy_for_element(
$(e.target),
user_topics.all_visibility_policies.MUTED,
);
@ -397,7 +396,7 @@ export function initialize() {
// Unmute topic in a unmuted stream
$("body").on("click", ".message_header .stream_unmuted.on_hover_topic_unmute", (e) => {
e.stopPropagation();
muted_topics_ui.mute_or_unmute_topic(
user_topics.set_visibility_policy_for_element(
$(e.target),
user_topics.all_visibility_policies.INHERIT,
);
@ -406,7 +405,7 @@ export function initialize() {
// Unmute topic in a muted stream
$("body").on("click", ".message_header .stream_muted.on_hover_topic_unmute", (e) => {
e.stopPropagation();
muted_topics_ui.mute_or_unmute_topic(
user_topics.set_visibility_policy_for_element(
$(e.target),
user_topics.all_visibility_policies.UNMUTED,
);
@ -415,7 +414,7 @@ export function initialize() {
// Mute topic in a muted stream
$("body").on("click", ".message_header .stream_muted.on_hover_topic_mute", (e) => {
e.stopPropagation();
muted_topics_ui.mute_or_unmute_topic(
user_topics.set_visibility_policy_for_element(
$(e.target),
user_topics.all_visibility_policies.INHERIT,
);

View File

@ -54,9 +54,3 @@ export function toggle_topic_visibility_policy(message) {
}
}
}
export function mute_or_unmute_topic($elt, visibility_policy) {
const stream_id = Number.parseInt($elt.attr("data-stream-id"), 10);
const topic = $elt.attr("data-topic-name");
user_topics.set_user_topic_visibility_policy(stream_id, topic, visibility_policy);
}

View File

@ -17,7 +17,6 @@ import {localstorage} from "./localstorage";
import * as message_store from "./message_store";
import * as message_util from "./message_util";
import * as message_view_header from "./message_view_header";
import * as muted_topics_ui from "./muted_topics_ui";
import * as muted_users from "./muted_users";
import * as narrow from "./narrow";
import * as narrow_state from "./narrow_state";
@ -1271,7 +1270,10 @@ export function initialize() {
const $elt = $(e.target);
const topic_row_index = $elt.closest("tr").index();
focus_clicked_element(topic_row_index, COLUMNS.mute);
muted_topics_ui.mute_or_unmute_topic($elt, user_topics.all_visibility_policies.MUTED);
user_topics.set_visibility_policy_for_element(
$elt,
user_topics.all_visibility_policies.MUTED,
);
});
// Unmute topic in a unmuted stream
@ -1280,7 +1282,10 @@ export function initialize() {
const $elt = $(e.target);
const topic_row_index = $elt.closest("tr").index();
focus_clicked_element(topic_row_index, COLUMNS.mute);
muted_topics_ui.mute_or_unmute_topic($elt, user_topics.all_visibility_policies.INHERIT);
user_topics.set_visibility_policy_for_element(
$elt,
user_topics.all_visibility_policies.INHERIT,
);
});
// Unmute topic in a muted stream
@ -1289,7 +1294,10 @@ export function initialize() {
const $elt = $(e.target);
const topic_row_index = $elt.closest("tr").index();
focus_clicked_element(topic_row_index, COLUMNS.mute);
muted_topics_ui.mute_or_unmute_topic($elt, user_topics.all_visibility_policies.UNMUTED);
user_topics.set_visibility_policy_for_element(
$elt,
user_topics.all_visibility_policies.UNMUTED,
);
});
// Mute topic in a muted stream
@ -1298,7 +1306,10 @@ export function initialize() {
const $elt = $(e.target);
const topic_row_index = $elt.closest("tr").index();
focus_clicked_element(topic_row_index, COLUMNS.mute);
muted_topics_ui.mute_or_unmute_topic($elt, user_topics.all_visibility_policies.INHERIT);
user_topics.set_visibility_policy_for_element(
$elt,
user_topics.all_visibility_policies.INHERIT,
);
});
$("body").on("click", "#recent_topics_search", (e) => {

View File

@ -136,6 +136,12 @@ export function set_user_topic_visibility_policy(
});
}
export function set_visibility_policy_for_element($elt, visibility_policy) {
const stream_id = Number.parseInt($elt.attr("data-stream-id"), 10);
const topic = $elt.attr("data-topic-name");
set_user_topic_visibility_policy(stream_id, topic, visibility_policy);
}
export function set_user_topic(user_topic) {
const stream_id = user_topic.stream_id;
const topic = user_topic.topic_name;