mirror of https://github.com/zulip/zulip.git
js: Rename muting module to muted_topics.
This commit is contained in:
parent
968a8c4e50
commit
5f74e78bee
|
@ -11,7 +11,7 @@ set_global("setTimeout", (f, delay) => {
|
|||
return f();
|
||||
});
|
||||
|
||||
const muting = zrequire("muting");
|
||||
const muted_topics = zrequire("muted_topics");
|
||||
const muted_users = zrequire("muted_users");
|
||||
const {MessageListData} = zrequire("../js/message_list_data");
|
||||
const {Filter} = zrequire("filter");
|
||||
|
@ -130,7 +130,7 @@ run_test("muting", () => {
|
|||
// `messages_filtered_for_topic_mutes` should skip filtering
|
||||
// messages if `excludes_muted_topics` is false.
|
||||
with_field(
|
||||
muting,
|
||||
muted_topics,
|
||||
"is_topic_muted",
|
||||
() => {
|
||||
throw new Error(
|
||||
|
@ -146,7 +146,7 @@ run_test("muting", () => {
|
|||
// If we are in a 1:1 PM narrow, `messages_filtered_for_user_mutes` should skip
|
||||
// filtering messages.
|
||||
with_field(
|
||||
muting,
|
||||
muted_topics,
|
||||
"is_user_muted",
|
||||
() => {
|
||||
throw new Error("Messages should not be filtered for user mutes in 1:1 PM narrows.");
|
||||
|
@ -160,7 +160,7 @@ run_test("muting", () => {
|
|||
// Test actual behaviour of `messages_filtered_for_*` methods.
|
||||
mld.excludes_muted_topics = true;
|
||||
mld.filter = new Filter([{operator: "stream", operand: "general"}]);
|
||||
muting.add_muted_topic(1, "muted");
|
||||
muted_topics.add_muted_topic(1, "muted");
|
||||
const res = mld.messages_filtered_for_topic_mutes(msgs);
|
||||
assert.deepEqual(res, [
|
||||
{id: 2, type: "stream", stream_id: 1, topic: "whatever"},
|
||||
|
|
|
@ -7,7 +7,7 @@ const {run_test} = require("../zjsunit/test");
|
|||
const blueslip = require("../zjsunit/zblueslip");
|
||||
const {page_params} = require("../zjsunit/zpage_params");
|
||||
|
||||
const muting = zrequire("muting");
|
||||
const muted_topics = zrequire("muted_topics");
|
||||
const muted_users = zrequire("muted_users");
|
||||
const stream_data = zrequire("stream_data");
|
||||
|
||||
|
@ -43,7 +43,7 @@ stream_data.add_sub(social);
|
|||
|
||||
function test(label, f) {
|
||||
run_test(label, ({override}) => {
|
||||
muting.set_muted_topics([]);
|
||||
muted_topics.set_muted_topics([]);
|
||||
muted_users.set_muted_users([]);
|
||||
f({override});
|
||||
});
|
||||
|
@ -51,31 +51,31 @@ function test(label, f) {
|
|||
|
||||
test("edge_cases", () => {
|
||||
// private messages
|
||||
assert.ok(!muting.is_topic_muted(undefined, undefined));
|
||||
assert.ok(!muted_topics.is_topic_muted(undefined, undefined));
|
||||
|
||||
// invalid user
|
||||
assert.ok(!muted_users.is_user_muted(undefined));
|
||||
});
|
||||
|
||||
test("add_and_remove_mutes", () => {
|
||||
assert.ok(!muting.is_topic_muted(devel.stream_id, "java"));
|
||||
muting.add_muted_topic(devel.stream_id, "java");
|
||||
assert.ok(muting.is_topic_muted(devel.stream_id, "java"));
|
||||
assert.ok(!muted_topics.is_topic_muted(devel.stream_id, "java"));
|
||||
muted_topics.add_muted_topic(devel.stream_id, "java");
|
||||
assert.ok(muted_topics.is_topic_muted(devel.stream_id, "java"));
|
||||
|
||||
// test idempotentcy
|
||||
muting.add_muted_topic(devel.stream_id, "java");
|
||||
assert.ok(muting.is_topic_muted(devel.stream_id, "java"));
|
||||
muted_topics.add_muted_topic(devel.stream_id, "java");
|
||||
assert.ok(muted_topics.is_topic_muted(devel.stream_id, "java"));
|
||||
|
||||
muting.remove_muted_topic(devel.stream_id, "java");
|
||||
assert.ok(!muting.is_topic_muted(devel.stream_id, "java"));
|
||||
muted_topics.remove_muted_topic(devel.stream_id, "java");
|
||||
assert.ok(!muted_topics.is_topic_muted(devel.stream_id, "java"));
|
||||
|
||||
// test idempotentcy
|
||||
muting.remove_muted_topic(devel.stream_id, "java");
|
||||
assert.ok(!muting.is_topic_muted(devel.stream_id, "java"));
|
||||
muted_topics.remove_muted_topic(devel.stream_id, "java");
|
||||
assert.ok(!muted_topics.is_topic_muted(devel.stream_id, "java"));
|
||||
|
||||
// test unknown stream is harmless too
|
||||
muting.remove_muted_topic(unknown.stream_id, "java");
|
||||
assert.ok(!muting.is_topic_muted(unknown.stream_id, "java"));
|
||||
muted_topics.remove_muted_topic(unknown.stream_id, "java");
|
||||
assert.ok(!muted_topics.is_topic_muted(unknown.stream_id, "java"));
|
||||
|
||||
assert.ok(!muted_users.is_user_muted(1));
|
||||
muted_users.add_muted_user(1);
|
||||
|
@ -118,10 +118,12 @@ test("get_unmuted_users", () => {
|
|||
});
|
||||
|
||||
test("get_mutes", () => {
|
||||
assert.deepEqual(muting.get_muted_topics(), []);
|
||||
muting.add_muted_topic(office.stream_id, "gossip", 1577836800);
|
||||
muting.add_muted_topic(devel.stream_id, "java", 1577836700);
|
||||
const all_muted_topics = muting.get_muted_topics().sort((a, b) => a.date_muted - b.date_muted);
|
||||
assert.deepEqual(muted_topics.get_muted_topics(), []);
|
||||
muted_topics.add_muted_topic(office.stream_id, "gossip", 1577836800);
|
||||
muted_topics.add_muted_topic(devel.stream_id, "java", 1577836700);
|
||||
const all_muted_topics = muted_topics
|
||||
.get_muted_topics()
|
||||
.sort((a, b) => a.date_muted - b.date_muted);
|
||||
|
||||
assert.deepEqual(all_muted_topics, [
|
||||
{
|
||||
|
@ -143,7 +145,10 @@ test("get_mutes", () => {
|
|||
assert.deepEqual(muted_users.get_muted_users(), []);
|
||||
muted_users.add_muted_user(6, 1577836800);
|
||||
muted_users.add_muted_user(4, 1577836800);
|
||||
const all_muted_users = muted_users.get_muted_users().sort((a, b) => a.date_muted - b.date_muted);
|
||||
const all_muted_users = muted_users
|
||||
.get_muted_users()
|
||||
.sort((a, b) => a.date_muted - b.date_muted);
|
||||
|
||||
assert.deepEqual(all_muted_users, [
|
||||
{
|
||||
date_muted: 1577836800000,
|
||||
|
@ -170,10 +175,10 @@ test("unknown streams", () => {
|
|||
{id: 3, timestamp: 1577836800},
|
||||
{id: 2, timestamp: 1577836800},
|
||||
];
|
||||
muting.initialize();
|
||||
muted_topics.initialize();
|
||||
muted_users.initialize();
|
||||
|
||||
assert.deepEqual(muting.get_muted_topics().sort(), [
|
||||
assert.deepEqual(muted_topics.get_muted_topics().sort(), [
|
||||
{
|
||||
date_muted: 1577836800000,
|
||||
date_muted_str: "Jan\u00A001,\u00A02020",
|
||||
|
@ -205,9 +210,9 @@ test("unknown streams", () => {
|
|||
});
|
||||
|
||||
test("case_insensitivity", () => {
|
||||
muting.set_muted_topics([]);
|
||||
assert.ok(!muting.is_topic_muted(social.stream_id, "breakfast"));
|
||||
muting.set_muted_topics([["SOCial", "breakfast"]]);
|
||||
assert.ok(muting.is_topic_muted(social.stream_id, "breakfast"));
|
||||
assert.ok(muting.is_topic_muted(social.stream_id, "breakFAST"));
|
||||
muted_topics.set_muted_topics([]);
|
||||
assert.ok(!muted_topics.is_topic_muted(social.stream_id, "breakfast"));
|
||||
muted_topics.set_muted_topics([["SOCial", "breakfast"]]);
|
||||
assert.ok(muted_topics.is_topic_muted(social.stream_id, "breakfast"));
|
||||
assert.ok(muted_topics.is_topic_muted(social.stream_id, "breakFAST"));
|
||||
});
|
||||
|
|
|
@ -48,7 +48,7 @@ set_global("setTimeout", (f, t) => {
|
|||
f();
|
||||
});
|
||||
|
||||
mock_esm("../../static/js/muting", {
|
||||
mock_esm("../../static/js/muted_topics", {
|
||||
is_topic_muted: () => false,
|
||||
});
|
||||
|
||||
|
|
|
@ -6,7 +6,7 @@ const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
|||
const {run_test} = require("../zjsunit/test");
|
||||
const blueslip = require("../zjsunit/zblueslip");
|
||||
|
||||
mock_esm("../../static/js/muting", {
|
||||
mock_esm("../../static/js/muted_topics", {
|
||||
is_topic_muted: () => false,
|
||||
});
|
||||
|
||||
|
|
|
@ -18,7 +18,7 @@ const _navigator = {
|
|||
};
|
||||
set_global("navigator", _navigator);
|
||||
|
||||
const muting = zrequire("muting");
|
||||
const muted_topics = zrequire("muted_topics");
|
||||
const stream_data = zrequire("stream_data");
|
||||
const ui = zrequire("ui");
|
||||
const spoilers = zrequire("spoilers");
|
||||
|
@ -47,7 +47,7 @@ const muted = {
|
|||
stream_data.add_sub(general);
|
||||
stream_data.add_sub(muted);
|
||||
|
||||
muting.add_muted_topic(general.stream_id, "muted topic");
|
||||
muted_topics.add_muted_topic(general.stream_id, "muted topic");
|
||||
|
||||
function test(label, f) {
|
||||
run_test(label, ({override}) => {
|
||||
|
|
|
@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
|
|||
const {zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
|
||||
const muting = zrequire("muting");
|
||||
const muted_topics = zrequire("muted_topics");
|
||||
const muted_users = zrequire("muted_users");
|
||||
const people = zrequire("people");
|
||||
const pmc = zrequire("pm_conversations");
|
||||
|
@ -23,7 +23,7 @@ const params = {
|
|||
function test(label, f) {
|
||||
run_test(label, ({override}) => {
|
||||
pmc.clear_for_testing();
|
||||
muting.set_muted_topics([]);
|
||||
muted_topics.set_muted_topics([]);
|
||||
muted_users.set_muted_users([]);
|
||||
people.initialize_current_user(15);
|
||||
f({override});
|
||||
|
|
|
@ -89,7 +89,7 @@ mock_esm("../../static/js/message_store", {
|
|||
mock_esm("../../static/js/message_view_header", {
|
||||
render_title_area: noop,
|
||||
});
|
||||
mock_esm("../../static/js/muting", {
|
||||
mock_esm("../../static/js/muted_topics", {
|
||||
is_topic_muted: (stream_id, topic) => {
|
||||
if (stream_id === stream1 && topic === topic7) {
|
||||
return true;
|
||||
|
|
|
@ -10,7 +10,7 @@ const muting_ui = mock_esm("../../static/js/muting_ui");
|
|||
|
||||
const settings_muted_topics = zrequire("settings_muted_topics");
|
||||
const stream_data = zrequire("stream_data");
|
||||
const muting = zrequire("muting");
|
||||
const muted_topics = zrequire("muted_topics");
|
||||
|
||||
const noop = () => {};
|
||||
|
||||
|
@ -21,10 +21,10 @@ const frontend = {
|
|||
stream_data.add_sub(frontend);
|
||||
|
||||
run_test("settings", ({override}) => {
|
||||
muting.add_muted_topic(frontend.stream_id, "js", 1577836800);
|
||||
muted_topics.add_muted_topic(frontend.stream_id, "js", 1577836800);
|
||||
let populate_list_called = false;
|
||||
override(settings_muted_topics, "populate_list", () => {
|
||||
const opts = muting.get_muted_topics();
|
||||
const opts = muted_topics.get_muted_topics();
|
||||
assert.deepEqual(opts, [
|
||||
{
|
||||
date_muted: 1577836800000,
|
||||
|
|
|
@ -8,7 +8,7 @@ const {run_test} = require("../zjsunit/test");
|
|||
const pm_conversations = zrequire("pm_conversations");
|
||||
pm_conversations.recent = {};
|
||||
|
||||
const muting = zrequire("muting");
|
||||
const muted_topics = zrequire("muted_topics");
|
||||
const unread = zrequire("unread");
|
||||
const stream_data = zrequire("stream_data");
|
||||
const stream_topic_history = zrequire("stream_topic_history");
|
||||
|
@ -104,7 +104,7 @@ run_test("topics", ({override}) => {
|
|||
[devel_stream_id, muted_stream_id].includes(stream_id),
|
||||
);
|
||||
|
||||
override(muting, "is_topic_muted", (stream_name, topic) => topic === "muted");
|
||||
override(muted_topics, "is_topic_muted", (stream_name, topic) => topic === "muted");
|
||||
|
||||
let next_item = tg.get_next_topic("announce", "whatever");
|
||||
assert.deepEqual(next_item, {
|
||||
|
|
|
@ -7,7 +7,7 @@ const _ = require("lodash");
|
|||
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
||||
const {run_test} = require("../zjsunit/test");
|
||||
|
||||
const muting = mock_esm("../../static/js/muting", {
|
||||
const muted_topics = mock_esm("../../static/js/muted_topics", {
|
||||
is_topic_muted() {
|
||||
return false;
|
||||
},
|
||||
|
@ -153,7 +153,7 @@ test("get_list_info unreads", ({override}) => {
|
|||
unread_cnt.set("topic 5", 5);
|
||||
unread_cnt.set("topic 13", 13);
|
||||
|
||||
override(muting, "is_topic_muted", (stream_id, topic_name) => {
|
||||
override(muted_topics, "is_topic_muted", (stream_id, topic_name) => {
|
||||
assert.equal(stream_id, general.stream_id);
|
||||
return topic_name === "topic 4";
|
||||
});
|
||||
|
|
|
@ -12,7 +12,7 @@ page_params.realm_push_notifications_enabled = false;
|
|||
|
||||
const {FoldDict} = zrequire("fold_dict");
|
||||
const message_store = zrequire("message_store");
|
||||
const muting = zrequire("muting");
|
||||
const muted_topics = zrequire("muted_topics");
|
||||
const people = zrequire("people");
|
||||
const stream_data = zrequire("stream_data");
|
||||
const sub_store = zrequire("sub_store");
|
||||
|
@ -57,7 +57,7 @@ function test_notifiable_count(home_unread_messages, expected_notifiable_count)
|
|||
function test(label, f) {
|
||||
run_test(label, ({override}) => {
|
||||
unread.declare_bankruptcy();
|
||||
muting.set_muted_topics([]);
|
||||
muted_topics.set_muted_topics([]);
|
||||
f({override});
|
||||
});
|
||||
}
|
||||
|
@ -228,7 +228,7 @@ test("muting", () => {
|
|||
assert.deepEqual(unread.get_msg_ids_for_stream(stream_id), [message.id]);
|
||||
test_notifiable_count(counts.home_unread_messages, 0);
|
||||
|
||||
muting.add_muted_topic(social.stream_id, "test_muting");
|
||||
muted_topics.add_muted_topic(social.stream_id, "test_muting");
|
||||
counts = unread.get_counts();
|
||||
assert.equal(counts.stream_count.get(stream_id), 0);
|
||||
assert.equal(counts.home_unread_messages, 0);
|
||||
|
@ -467,7 +467,7 @@ test("mentions", () => {
|
|||
|
||||
const muted_stream_id = 401;
|
||||
|
||||
muting.add_muted_topic(401, "lunch");
|
||||
muted_topics.add_muted_topic(401, "lunch");
|
||||
|
||||
const already_read_message = {
|
||||
id: 14,
|
||||
|
|
|
@ -3,8 +3,8 @@ import _ from "lodash";
|
|||
import * as blueslip from "./blueslip";
|
||||
import {FetchStatus} from "./fetch_status";
|
||||
import {Filter} from "./filter";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as muted_users from "./muted_users";
|
||||
import * as muting from "./muting";
|
||||
import {page_params} from "./page_params";
|
||||
import * as unread from "./unread";
|
||||
import * as util from "./util";
|
||||
|
@ -174,7 +174,9 @@ export class MessageListData {
|
|||
if (message.type !== "stream") {
|
||||
return true;
|
||||
}
|
||||
return !muting.is_topic_muted(message.stream_id, message.topic) || message.mentioned;
|
||||
return (
|
||||
!muted_topics.is_topic_muted(message.stream_id, message.topic) || message.mentioned
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
|
|
@ -19,8 +19,8 @@ import * as message_edit from "./message_edit";
|
|||
import * as message_lists from "./message_lists";
|
||||
import * as message_store from "./message_store";
|
||||
import * as message_viewport from "./message_viewport";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as muted_users from "./muted_users";
|
||||
import * as muting from "./muting";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import {page_params} from "./page_params";
|
||||
import * as people from "./people";
|
||||
|
@ -160,7 +160,7 @@ function populate_group_from_message_container(group, message_container) {
|
|||
} else {
|
||||
group.stream_id = sub.stream_id;
|
||||
}
|
||||
group.topic_muted = muting.is_topic_muted(group.stream_id, group.topic);
|
||||
group.topic_muted = muted_topics.is_topic_muted(group.stream_id, group.topic);
|
||||
} else if (group.is_private) {
|
||||
group.pm_with_url = message_container.pm_with_url;
|
||||
group.display_reply_to = message_store.get_pm_full_names(message_container.msg);
|
||||
|
|
|
@ -10,8 +10,8 @@ import * as confirm_dialog from "./confirm_dialog";
|
|||
import * as feedback_widget from "./feedback_widget";
|
||||
import {$t} from "./i18n";
|
||||
import * as message_lists from "./message_lists";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as muted_users from "./muted_users";
|
||||
import * as muting from "./muting";
|
||||
import * as overlays from "./overlays";
|
||||
import * as people from "./people";
|
||||
import * as pm_list from "./pm_list";
|
||||
|
@ -37,7 +37,7 @@ export function rerender_for_muted_topic(old_muted_topics) {
|
|||
// We only update those topics which could have been affected, because
|
||||
// we want to avoid doing a complete rerender of the recent topics view,
|
||||
// because that can be expensive.
|
||||
const current_muted_topics = muting.get_muted_topics();
|
||||
const current_muted_topics = muted_topics.get_muted_topics();
|
||||
const maybe_affected_topics = _.unionWith(old_muted_topics, current_muted_topics, _.isEqual);
|
||||
|
||||
for (const topic_data of maybe_affected_topics) {
|
||||
|
@ -46,8 +46,8 @@ export function rerender_for_muted_topic(old_muted_topics) {
|
|||
}
|
||||
|
||||
export function handle_topic_updates(muted_topics) {
|
||||
const old_muted_topics = muting.get_muted_topics();
|
||||
muting.set_muted_topics(muted_topics);
|
||||
const old_muted_topics = muted_topics.get_muted_topics();
|
||||
muted_topics.set_muted_topics(muted_topics);
|
||||
stream_popover.hide_topic_popover();
|
||||
unread_ui.update_unread_counts();
|
||||
rerender_for_muted_topic(old_muted_topics);
|
||||
|
@ -117,7 +117,7 @@ export function toggle_topic_mute(message) {
|
|||
const stream_id = message.stream_id;
|
||||
const topic = message.topic;
|
||||
|
||||
if (muting.is_topic_muted(stream_id, topic)) {
|
||||
if (muted_topics.is_topic_muted(stream_id, topic)) {
|
||||
unmute_topic(stream_id, topic);
|
||||
} else if (message.type === "stream") {
|
||||
mute_topic(stream_id, topic, true);
|
||||
|
|
|
@ -10,7 +10,7 @@ import * as favicon from "./favicon";
|
|||
import {$t} from "./i18n";
|
||||
import * as message_lists from "./message_lists";
|
||||
import * as message_store from "./message_store";
|
||||
import * as muting from "./muting";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as narrow from "./narrow";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as navigate from "./navigate";
|
||||
|
@ -361,7 +361,10 @@ export function message_is_notifiable(message) {
|
|||
return false;
|
||||
}
|
||||
|
||||
if (message.type === "stream" && muting.is_topic_muted(message.stream_id, message.topic)) {
|
||||
if (
|
||||
message.type === "stream" &&
|
||||
muted_topics.is_topic_muted(message.stream_id, message.topic)
|
||||
) {
|
||||
return false;
|
||||
}
|
||||
|
||||
|
@ -539,7 +542,10 @@ export function get_local_notify_mix_reason(message) {
|
|||
return undefined;
|
||||
}
|
||||
|
||||
if (message.type === "stream" && muting.is_topic_muted(message.stream_id, message.topic)) {
|
||||
if (
|
||||
message.type === "stream" &&
|
||||
muted_topics.is_topic_muted(message.stream_id, message.topic)
|
||||
) {
|
||||
return $t({defaultMessage: "Sent! Your message was sent to a topic you have muted."});
|
||||
}
|
||||
|
||||
|
|
|
@ -28,8 +28,8 @@ 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 message_viewport from "./message_viewport";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as muted_users from "./muted_users";
|
||||
import * as muting from "./muting";
|
||||
import * as muting_ui from "./muting_ui";
|
||||
import * as narrow from "./narrow";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
|
@ -422,9 +422,9 @@ export function toggle_actions_popover(element, id) {
|
|||
}
|
||||
const topic = message.topic;
|
||||
const can_mute_topic =
|
||||
message.stream && topic && !muting.is_topic_muted(message.stream_id, topic);
|
||||
message.stream && topic && !muted_topics.is_topic_muted(message.stream_id, topic);
|
||||
const can_unmute_topic =
|
||||
message.stream && topic && muting.is_topic_muted(message.stream_id, topic);
|
||||
message.stream && topic && muted_topics.is_topic_muted(message.stream_id, topic);
|
||||
|
||||
const should_display_edit_history_option =
|
||||
message.edit_history &&
|
||||
|
|
|
@ -12,7 +12,7 @@ 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 muting from "./muting";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as narrow from "./narrow";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as navbar_alerts from "./navbar_alerts";
|
||||
|
@ -233,7 +233,7 @@ function format_topic(topic_data) {
|
|||
// We only supply the data to the topic rows and let jquery
|
||||
// display / hide them according to filters instead of
|
||||
// doing complete re-render.
|
||||
const topic_muted = Boolean(muting.is_topic_muted(stream_id, topic));
|
||||
const topic_muted = Boolean(muted_topics.is_topic_muted(stream_id, topic));
|
||||
const stream_muted = stream_data.is_muted(stream_id);
|
||||
const muted = topic_muted || stream_muted;
|
||||
const unread_count = unread.num_unread_for_topic(stream_id, topic);
|
||||
|
@ -341,7 +341,7 @@ export function filters_should_hide_topic(topic_data) {
|
|||
}
|
||||
|
||||
if (!filters.has("include_muted")) {
|
||||
const topic_muted = Boolean(muting.is_topic_muted(msg.stream_id, msg.topic));
|
||||
const topic_muted = Boolean(muted_topics.is_topic_muted(msg.stream_id, msg.topic));
|
||||
const stream_muted = stream_data.is_muted(msg.stream_id);
|
||||
if (topic_muted || stream_muted) {
|
||||
return true;
|
||||
|
|
|
@ -3,14 +3,14 @@ import $ from "jquery";
|
|||
import render_muted_topic_ui_row from "../templates/muted_topic_ui_row.hbs";
|
||||
|
||||
import * as ListWidget from "./list_widget";
|
||||
import * as muting from "./muting";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as muting_ui from "./muting_ui";
|
||||
import * as ui from "./ui";
|
||||
|
||||
export let loaded = false;
|
||||
|
||||
export function populate_list() {
|
||||
const all_muted_topics = muting.get_muted_topics();
|
||||
const all_muted_topics = muted_topics.get_muted_topics();
|
||||
const muted_topics_table = $("#muted_topics_table");
|
||||
const $search_input = $("#muted_topics_search");
|
||||
|
||||
|
|
|
@ -17,7 +17,7 @@ import {DropdownListWidget as dropdown_list_widget} from "./dropdown_list_widget
|
|||
import * as hash_util from "./hash_util";
|
||||
import {$t, $t_html} from "./i18n";
|
||||
import * as message_edit from "./message_edit";
|
||||
import * as muting from "./muting";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as muting_ui from "./muting_ui";
|
||||
import * as overlays from "./overlays";
|
||||
import {page_params} from "./page_params";
|
||||
|
@ -261,7 +261,7 @@ function build_topic_popover(opts) {
|
|||
popovers.hide_all();
|
||||
show_streamlist_sidebar();
|
||||
|
||||
const topic_muted = muting.is_topic_muted(sub.stream_id, topic_name);
|
||||
const topic_muted = muted_topics.is_topic_muted(sub.stream_id, topic_name);
|
||||
const has_starred_messages = starred_messages.get_count_in_topic(sub.stream_id, topic_name) > 0;
|
||||
// Arguably, we could offer the "Move topic" option even if users
|
||||
// can only edit the name within a stream.
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
import * as muting from "./muting";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as pm_conversations from "./pm_conversations";
|
||||
import * as stream_data from "./stream_data";
|
||||
import * as stream_sort from "./stream_sort";
|
||||
|
@ -67,7 +67,7 @@ export function get_next_topic(curr_stream, curr_topic) {
|
|||
function get_unmuted_topics(stream_name) {
|
||||
const stream_id = stream_data.get_stream_id(stream_name);
|
||||
let topics = stream_topic_history.get_recent_topic_names(stream_id);
|
||||
topics = topics.filter((topic) => !muting.is_topic_muted(stream_id, topic));
|
||||
topics = topics.filter((topic) => !muted_topics.is_topic_muted(stream_id, topic));
|
||||
return topics;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import * as hash_util from "./hash_util";
|
||||
import * as muting from "./muting";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as narrow_state from "./narrow_state";
|
||||
import * as stream_topic_history from "./stream_topic_history";
|
||||
import * as topic_list from "./topic_list";
|
||||
|
@ -30,7 +30,7 @@ export function get_list_info(stream_id, zoomed) {
|
|||
for (const [idx, topic_name] of topic_names.entries()) {
|
||||
const num_unread = unread.num_unread_for_topic(stream_id, topic_name);
|
||||
const is_active_topic = active_topic === topic_name.toLowerCase();
|
||||
const is_topic_muted = muting.is_topic_muted(stream_id, topic_name);
|
||||
const is_topic_muted = muted_topics.is_topic_muted(stream_id, topic_name);
|
||||
|
||||
if (!zoomed) {
|
||||
function should_show_topic(topics_selected) {
|
||||
|
|
|
@ -40,8 +40,8 @@ import * as message_lists from "./message_lists";
|
|||
import * as message_scroll from "./message_scroll";
|
||||
import * as message_view_header from "./message_view_header";
|
||||
import * as message_viewport from "./message_viewport";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import * as muted_users from "./muted_users";
|
||||
import * as muting from "./muting";
|
||||
import * as navbar_alerts from "./navbar_alerts";
|
||||
import * as navigate from "./navigate";
|
||||
import * as notifications from "./notifications";
|
||||
|
@ -486,7 +486,7 @@ export function initialize_everything() {
|
|||
stream_edit.initialize();
|
||||
stream_data.initialize(stream_data_params);
|
||||
pm_conversations.recent.initialize(pm_conversations_params);
|
||||
muting.initialize();
|
||||
muted_topics.initialize();
|
||||
muted_users.initialize();
|
||||
subs.initialize();
|
||||
stream_list.initialize();
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
import {FoldDict} from "./fold_dict";
|
||||
import * as message_store from "./message_store";
|
||||
import * as muting from "./muting";
|
||||
import * as muted_topics from "./muted_topics";
|
||||
import {page_params} from "./page_params";
|
||||
import * as people from "./people";
|
||||
import * as settings_config from "./settings_config";
|
||||
|
@ -251,7 +251,7 @@ class UnreadTopicCounter {
|
|||
let stream_count = 0;
|
||||
for (const [topic, msgs] of per_stream_bucketer) {
|
||||
const topic_count = msgs.size;
|
||||
if (!muting.is_topic_muted(stream_id, topic)) {
|
||||
if (!muted_topics.is_topic_muted(stream_id, topic)) {
|
||||
stream_count += topic_count;
|
||||
}
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ class UnreadTopicCounter {
|
|||
|
||||
const sub = sub_store.get(stream_id);
|
||||
for (const [topic, msgs] of per_stream_bucketer) {
|
||||
if (sub && !muting.is_topic_muted(stream_id, topic)) {
|
||||
if (sub && !muted_topics.is_topic_muted(stream_id, topic)) {
|
||||
stream_count += msgs.size;
|
||||
}
|
||||
}
|
||||
|
@ -348,7 +348,7 @@ class UnreadTopicCounter {
|
|||
const ids = [];
|
||||
const sub = sub_store.get(stream_id);
|
||||
for (const [topic, id_set] of per_stream_bucketer) {
|
||||
if (sub && !muting.is_topic_muted(stream_id, topic)) {
|
||||
if (sub && !muted_topics.is_topic_muted(stream_id, topic)) {
|
||||
for (const id of id_set) {
|
||||
ids.push(id);
|
||||
}
|
||||
|
@ -451,7 +451,7 @@ export function update_message_for_mention(message) {
|
|||
const is_unmuted_mention =
|
||||
message.type === "stream" &&
|
||||
message.mentioned &&
|
||||
!muting.is_topic_muted(message.stream_id, message.topic);
|
||||
!muted_topics.is_topic_muted(message.stream_id, message.topic);
|
||||
|
||||
if (is_unmuted_mention || message.mentioned_me_directly) {
|
||||
unread_mentions_counter.add(message.id);
|
||||
|
|
Loading…
Reference in New Issue