mirror of
https://github.com/zulip/zulip.git
synced 2025-11-07 15:33:30 +00:00
user_topics: Rename muted_topics.js to user_topics.js.
This commit is contained in:
committed by
Tim Abbott
parent
87a6c3924b
commit
47e5ccf086
@@ -6,7 +6,7 @@ const {zrequire} = require("../zjsunit/namespace");
|
|||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
const blueslip = require("../zjsunit/zblueslip");
|
const blueslip = require("../zjsunit/zblueslip");
|
||||||
|
|
||||||
const muted_topics = zrequire("muted_topics");
|
const user_topics = zrequire("user_topics");
|
||||||
const muted_users = zrequire("muted_users");
|
const muted_users = zrequire("muted_users");
|
||||||
const {MessageListData} = zrequire("../js/message_list_data");
|
const {MessageListData} = zrequire("../js/message_list_data");
|
||||||
const {Filter} = zrequire("filter");
|
const {Filter} = zrequire("filter");
|
||||||
@@ -143,7 +143,7 @@ run_test("muting", () => {
|
|||||||
{id: 9, type: "private", to_user_ids: "9", sender_id: 11}, // 1:1 PM to non-muted
|
{id: 9, type: "private", to_user_ids: "9", sender_id: 11}, // 1:1 PM to non-muted
|
||||||
];
|
];
|
||||||
|
|
||||||
muted_topics.add_muted_topic(1, "muted");
|
user_topics.add_muted_topic(1, "muted");
|
||||||
muted_users.add_muted_user(10);
|
muted_users.add_muted_user(10);
|
||||||
|
|
||||||
// `messages_filtered_for_topic_mutes` should skip filtering
|
// `messages_filtered_for_topic_mutes` should skip filtering
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const {run_test} = require("../zjsunit/test");
|
|||||||
const blueslip = require("../zjsunit/zblueslip");
|
const blueslip = require("../zjsunit/zblueslip");
|
||||||
const {page_params} = require("../zjsunit/zpage_params");
|
const {page_params} = require("../zjsunit/zpage_params");
|
||||||
|
|
||||||
const muted_topics = zrequire("muted_topics");
|
const user_topics = zrequire("user_topics");
|
||||||
const muted_users = zrequire("muted_users");
|
const muted_users = zrequire("muted_users");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
|
|
||||||
@@ -43,7 +43,7 @@ stream_data.add_sub(social);
|
|||||||
|
|
||||||
function test(label, f) {
|
function test(label, f) {
|
||||||
run_test(label, ({override}) => {
|
run_test(label, ({override}) => {
|
||||||
muted_topics.set_muted_topics([]);
|
user_topics.set_muted_topics([]);
|
||||||
muted_users.set_muted_users([]);
|
muted_users.set_muted_users([]);
|
||||||
f({override});
|
f({override});
|
||||||
});
|
});
|
||||||
@@ -51,31 +51,31 @@ function test(label, f) {
|
|||||||
|
|
||||||
test("edge_cases", () => {
|
test("edge_cases", () => {
|
||||||
// private messages
|
// private messages
|
||||||
assert.ok(!muted_topics.is_topic_muted(undefined, undefined));
|
assert.ok(!user_topics.is_topic_muted(undefined, undefined));
|
||||||
|
|
||||||
// invalid user
|
// invalid user
|
||||||
assert.ok(!muted_users.is_user_muted(undefined));
|
assert.ok(!muted_users.is_user_muted(undefined));
|
||||||
});
|
});
|
||||||
|
|
||||||
test("add_and_remove_mutes", () => {
|
test("add_and_remove_mutes", () => {
|
||||||
assert.ok(!muted_topics.is_topic_muted(devel.stream_id, "java"));
|
assert.ok(!user_topics.is_topic_muted(devel.stream_id, "java"));
|
||||||
muted_topics.add_muted_topic(devel.stream_id, "java");
|
user_topics.add_muted_topic(devel.stream_id, "java");
|
||||||
assert.ok(muted_topics.is_topic_muted(devel.stream_id, "java"));
|
assert.ok(user_topics.is_topic_muted(devel.stream_id, "java"));
|
||||||
|
|
||||||
// test idempotency
|
// test idempotency
|
||||||
muted_topics.add_muted_topic(devel.stream_id, "java");
|
user_topics.add_muted_topic(devel.stream_id, "java");
|
||||||
assert.ok(muted_topics.is_topic_muted(devel.stream_id, "java"));
|
assert.ok(user_topics.is_topic_muted(devel.stream_id, "java"));
|
||||||
|
|
||||||
muted_topics.remove_muted_topic(devel.stream_id, "java");
|
user_topics.remove_muted_topic(devel.stream_id, "java");
|
||||||
assert.ok(!muted_topics.is_topic_muted(devel.stream_id, "java"));
|
assert.ok(!user_topics.is_topic_muted(devel.stream_id, "java"));
|
||||||
|
|
||||||
// test idempotency
|
// test idempotency
|
||||||
muted_topics.remove_muted_topic(devel.stream_id, "java");
|
user_topics.remove_muted_topic(devel.stream_id, "java");
|
||||||
assert.ok(!muted_topics.is_topic_muted(devel.stream_id, "java"));
|
assert.ok(!user_topics.is_topic_muted(devel.stream_id, "java"));
|
||||||
|
|
||||||
// test unknown stream is harmless too
|
// test unknown stream is harmless too
|
||||||
muted_topics.remove_muted_topic(unknown.stream_id, "java");
|
user_topics.remove_muted_topic(unknown.stream_id, "java");
|
||||||
assert.ok(!muted_topics.is_topic_muted(unknown.stream_id, "java"));
|
assert.ok(!user_topics.is_topic_muted(unknown.stream_id, "java"));
|
||||||
|
|
||||||
assert.ok(!muted_users.is_user_muted(1));
|
assert.ok(!muted_users.is_user_muted(1));
|
||||||
muted_users.add_muted_user(1);
|
muted_users.add_muted_user(1);
|
||||||
@@ -118,10 +118,10 @@ test("get_unmuted_users", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("get_mutes", () => {
|
test("get_mutes", () => {
|
||||||
assert.deepEqual(muted_topics.get_muted_topics(), []);
|
assert.deepEqual(user_topics.get_muted_topics(), []);
|
||||||
muted_topics.add_muted_topic(office.stream_id, "gossip", 1577836800);
|
user_topics.add_muted_topic(office.stream_id, "gossip", 1577836800);
|
||||||
muted_topics.add_muted_topic(devel.stream_id, "java", 1577836700);
|
user_topics.add_muted_topic(devel.stream_id, "java", 1577836700);
|
||||||
const all_muted_topics = muted_topics
|
const all_muted_topics = user_topics
|
||||||
.get_muted_topics()
|
.get_muted_topics()
|
||||||
.sort((a, b) => a.date_muted - b.date_muted);
|
.sort((a, b) => a.date_muted - b.date_muted);
|
||||||
|
|
||||||
@@ -175,10 +175,10 @@ test("unknown streams", () => {
|
|||||||
{id: 3, timestamp: 1577836800},
|
{id: 3, timestamp: 1577836800},
|
||||||
{id: 2, timestamp: 1577836800},
|
{id: 2, timestamp: 1577836800},
|
||||||
];
|
];
|
||||||
muted_topics.initialize();
|
user_topics.initialize();
|
||||||
muted_users.initialize();
|
muted_users.initialize();
|
||||||
|
|
||||||
assert.deepEqual(muted_topics.get_muted_topics().sort(), [
|
assert.deepEqual(user_topics.get_muted_topics().sort(), [
|
||||||
{
|
{
|
||||||
date_muted: 1577836800000,
|
date_muted: 1577836800000,
|
||||||
date_muted_str: "Jan\u00A001,\u00A02020",
|
date_muted_str: "Jan\u00A001,\u00A02020",
|
||||||
@@ -210,9 +210,9 @@ test("unknown streams", () => {
|
|||||||
});
|
});
|
||||||
|
|
||||||
test("case_insensitivity", () => {
|
test("case_insensitivity", () => {
|
||||||
muted_topics.set_muted_topics([]);
|
user_topics.set_muted_topics([]);
|
||||||
assert.ok(!muted_topics.is_topic_muted(social.stream_id, "breakfast"));
|
assert.ok(!user_topics.is_topic_muted(social.stream_id, "breakfast"));
|
||||||
muted_topics.set_muted_topics([["SOCial", "breakfast"]]);
|
user_topics.set_muted_topics([["SOCial", "breakfast"]]);
|
||||||
assert.ok(muted_topics.is_topic_muted(social.stream_id, "breakfast"));
|
assert.ok(user_topics.is_topic_muted(social.stream_id, "breakfast"));
|
||||||
assert.ok(muted_topics.is_topic_muted(social.stream_id, "breakFAST"));
|
assert.ok(user_topics.is_topic_muted(social.stream_id, "breakFAST"));
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -49,7 +49,7 @@ set_global("setTimeout", (f, t) => {
|
|||||||
f();
|
f();
|
||||||
});
|
});
|
||||||
|
|
||||||
mock_esm("../../static/js/muted_topics", {
|
mock_esm("../../static/js/user_topics", {
|
||||||
is_topic_muted: () => false,
|
is_topic_muted: () => false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
|||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
const blueslip = require("../zjsunit/zblueslip");
|
const blueslip = require("../zjsunit/zblueslip");
|
||||||
|
|
||||||
mock_esm("../../static/js/muted_topics", {
|
mock_esm("../../static/js/user_topics", {
|
||||||
is_topic_muted: () => false,
|
is_topic_muted: () => false,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ const _navigator = {
|
|||||||
};
|
};
|
||||||
set_global("navigator", _navigator);
|
set_global("navigator", _navigator);
|
||||||
|
|
||||||
const muted_topics = zrequire("muted_topics");
|
const user_topics = zrequire("user_topics");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
const spoilers = zrequire("spoilers");
|
const spoilers = zrequire("spoilers");
|
||||||
spoilers.hide_spoilers_in_notification = () => {};
|
spoilers.hide_spoilers_in_notification = () => {};
|
||||||
@@ -47,7 +47,7 @@ const muted = {
|
|||||||
stream_data.add_sub(general);
|
stream_data.add_sub(general);
|
||||||
stream_data.add_sub(muted);
|
stream_data.add_sub(muted);
|
||||||
|
|
||||||
muted_topics.add_muted_topic(general.stream_id, "muted topic");
|
user_topics.add_muted_topic(general.stream_id, "muted topic");
|
||||||
|
|
||||||
function test(label, f) {
|
function test(label, f) {
|
||||||
run_test(label, (helpers) => {
|
run_test(label, (helpers) => {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
|
|||||||
const {zrequire} = require("../zjsunit/namespace");
|
const {zrequire} = require("../zjsunit/namespace");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
|
|
||||||
const muted_topics = zrequire("muted_topics");
|
const user_topics = zrequire("user_topics");
|
||||||
const muted_users = zrequire("muted_users");
|
const muted_users = zrequire("muted_users");
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
const pmc = zrequire("pm_conversations");
|
const pmc = zrequire("pm_conversations");
|
||||||
@@ -23,7 +23,7 @@ const params = {
|
|||||||
function test(label, f) {
|
function test(label, f) {
|
||||||
run_test(label, ({override}) => {
|
run_test(label, ({override}) => {
|
||||||
pmc.clear_for_testing();
|
pmc.clear_for_testing();
|
||||||
muted_topics.set_muted_topics([]);
|
user_topics.set_muted_topics([]);
|
||||||
muted_users.set_muted_users([]);
|
muted_users.set_muted_users([]);
|
||||||
people.initialize_current_user(15);
|
people.initialize_current_user(15);
|
||||||
f({override});
|
f({override});
|
||||||
|
|||||||
@@ -93,7 +93,7 @@ mock_esm("../../static/js/message_store", {
|
|||||||
mock_esm("../../static/js/message_view_header", {
|
mock_esm("../../static/js/message_view_header", {
|
||||||
render_title_area: noop,
|
render_title_area: noop,
|
||||||
});
|
});
|
||||||
mock_esm("../../static/js/muted_topics", {
|
mock_esm("../../static/js/user_topics", {
|
||||||
is_topic_muted: (stream_id, topic) => {
|
is_topic_muted: (stream_id, topic) => {
|
||||||
if (stream_id === stream1 && topic === topic7) {
|
if (stream_id === stream1 && topic === topic7) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ const muted_topics_ui = mock_esm("../../static/js/muted_topics_ui");
|
|||||||
|
|
||||||
const settings_muted_topics = zrequire("settings_muted_topics");
|
const settings_muted_topics = zrequire("settings_muted_topics");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
const muted_topics = zrequire("muted_topics");
|
const user_topics = zrequire("user_topics");
|
||||||
|
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
|
|
||||||
@@ -22,7 +22,7 @@ const frontend = {
|
|||||||
stream_data.add_sub(frontend);
|
stream_data.add_sub(frontend);
|
||||||
|
|
||||||
run_test("settings", ({override}) => {
|
run_test("settings", ({override}) => {
|
||||||
muted_topics.add_muted_topic(frontend.stream_id, "js", 1577836800);
|
user_topics.add_muted_topic(frontend.stream_id, "js", 1577836800);
|
||||||
let populate_list_called = false;
|
let populate_list_called = false;
|
||||||
override(list_widget, "create", ($container, list) => {
|
override(list_widget, "create", ($container, list) => {
|
||||||
assert.deepEqual(list, [
|
assert.deepEqual(list, [
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
|
|||||||
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
|
|
||||||
const muted_topics = mock_esm("../../static/js/muted_topics");
|
const user_topics = mock_esm("../../static/js/user_topics");
|
||||||
const stream_data = mock_esm("../../static/js/stream_data");
|
const stream_data = mock_esm("../../static/js/stream_data");
|
||||||
const stream_topic_history = mock_esm("../../static/js/stream_topic_history");
|
const stream_topic_history = mock_esm("../../static/js/stream_topic_history");
|
||||||
const unread = mock_esm("../../static/js/unread");
|
const unread = mock_esm("../../static/js/unread");
|
||||||
@@ -105,7 +105,7 @@ run_test("topics", ({override}) => {
|
|||||||
[devel_stream_id, muted_stream_id].includes(stream_id),
|
[devel_stream_id, muted_stream_id].includes(stream_id),
|
||||||
);
|
);
|
||||||
|
|
||||||
override(muted_topics, "is_topic_muted", (stream_name, topic) => topic === "muted");
|
override(user_topics, "is_topic_muted", (stream_name, topic) => topic === "muted");
|
||||||
|
|
||||||
let next_item = tg.get_next_topic("announce", "whatever");
|
let next_item = tg.get_next_topic("announce", "whatever");
|
||||||
assert.deepEqual(next_item, {
|
assert.deepEqual(next_item, {
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ const _ = require("lodash");
|
|||||||
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
|
|
||||||
const muted_topics = mock_esm("../../static/js/muted_topics", {
|
const user_topics = mock_esm("../../static/js/user_topics", {
|
||||||
is_topic_muted() {
|
is_topic_muted() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
@@ -183,7 +183,7 @@ test("get_list_info unreads", ({override}) => {
|
|||||||
add_unreads("topic 5", 5);
|
add_unreads("topic 5", 5);
|
||||||
add_unreads("topic 13", 13);
|
add_unreads("topic 13", 13);
|
||||||
|
|
||||||
override(muted_topics, "is_topic_muted", (stream_id, topic_name) => {
|
override(user_topics, "is_topic_muted", (stream_id, topic_name) => {
|
||||||
assert.equal(stream_id, general.stream_id);
|
assert.equal(stream_id, general.stream_id);
|
||||||
return topic_name === "topic 4";
|
return topic_name === "topic 4";
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -12,7 +12,7 @@ page_params.realm_push_notifications_enabled = false;
|
|||||||
|
|
||||||
const {FoldDict} = zrequire("fold_dict");
|
const {FoldDict} = zrequire("fold_dict");
|
||||||
const message_store = zrequire("message_store");
|
const message_store = zrequire("message_store");
|
||||||
const muted_topics = zrequire("muted_topics");
|
const user_topics = zrequire("user_topics");
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
const sub_store = zrequire("sub_store");
|
const sub_store = zrequire("sub_store");
|
||||||
@@ -57,7 +57,7 @@ function test_notifiable_count(home_unread_messages, expected_notifiable_count)
|
|||||||
function test(label, f) {
|
function test(label, f) {
|
||||||
run_test(label, (helpers) => {
|
run_test(label, (helpers) => {
|
||||||
unread.declare_bankruptcy();
|
unread.declare_bankruptcy();
|
||||||
muted_topics.set_muted_topics([]);
|
user_topics.set_muted_topics([]);
|
||||||
f(helpers);
|
f(helpers);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -230,7 +230,7 @@ test("muting", () => {
|
|||||||
assert.deepEqual(unread.get_msg_ids_for_stream(stream_id), [message.id]);
|
assert.deepEqual(unread.get_msg_ids_for_stream(stream_id), [message.id]);
|
||||||
test_notifiable_count(counts.home_unread_messages, 0);
|
test_notifiable_count(counts.home_unread_messages, 0);
|
||||||
|
|
||||||
muted_topics.add_muted_topic(social.stream_id, "test_muting");
|
user_topics.add_muted_topic(social.stream_id, "test_muting");
|
||||||
counts = unread.get_counts();
|
counts = unread.get_counts();
|
||||||
assert.equal(counts.stream_count.get(stream_id), 0);
|
assert.equal(counts.stream_count.get(stream_id), 0);
|
||||||
assert.equal(counts.home_unread_messages, 0);
|
assert.equal(counts.home_unread_messages, 0);
|
||||||
@@ -463,7 +463,7 @@ test("mentions", () => {
|
|||||||
|
|
||||||
const muted_stream_id = 401;
|
const muted_stream_id = 401;
|
||||||
|
|
||||||
muted_topics.add_muted_topic(401, "lunch");
|
user_topics.add_muted_topic(401, "lunch");
|
||||||
|
|
||||||
const already_read_message = {
|
const already_read_message = {
|
||||||
id: 14,
|
id: 14,
|
||||||
|
|||||||
@@ -3,10 +3,10 @@ import _ from "lodash";
|
|||||||
import * as blueslip from "./blueslip";
|
import * as blueslip from "./blueslip";
|
||||||
import {FetchStatus} from "./fetch_status";
|
import {FetchStatus} from "./fetch_status";
|
||||||
import {Filter} from "./filter";
|
import {Filter} from "./filter";
|
||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import * as muted_users from "./muted_users";
|
import * as muted_users from "./muted_users";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as unread from "./unread";
|
import * as unread from "./unread";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
|
||||||
export class MessageListData {
|
export class MessageListData {
|
||||||
@@ -175,7 +175,7 @@ export class MessageListData {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return (
|
return (
|
||||||
!muted_topics.is_topic_muted(message.stream_id, message.topic) || message.mentioned
|
!user_topics.is_topic_muted(message.stream_id, message.topic) || message.mentioned
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,6 @@ import * as message_edit from "./message_edit";
|
|||||||
import * as message_lists from "./message_lists";
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as $message_viewport from "./message_viewport";
|
import * as $message_viewport from "./message_viewport";
|
||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import * as muted_users from "./muted_users";
|
import * as muted_users from "./muted_users";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
@@ -35,6 +34,7 @@ import * as stream_data from "./stream_data";
|
|||||||
import * as sub_store from "./sub_store";
|
import * as sub_store from "./sub_store";
|
||||||
import * as submessage from "./submessage";
|
import * as submessage from "./submessage";
|
||||||
import * as timerender from "./timerender";
|
import * as timerender from "./timerender";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
|
||||||
function same_day(earlier_msg, later_msg) {
|
function same_day(earlier_msg, later_msg) {
|
||||||
@@ -212,7 +212,7 @@ function populate_group_from_message_container(group, message_container) {
|
|||||||
group.stream_id = sub.stream_id;
|
group.stream_id = sub.stream_id;
|
||||||
}
|
}
|
||||||
group.topic_is_resolved = resolved_topic.is_resolved(group.topic);
|
group.topic_is_resolved = resolved_topic.is_resolved(group.topic);
|
||||||
group.topic_muted = muted_topics.is_topic_muted(group.stream_id, group.topic);
|
group.topic_muted = user_topics.is_topic_muted(group.stream_id, group.topic);
|
||||||
} else if (group.is_private) {
|
} else if (group.is_private) {
|
||||||
group.pm_with_url = message_container.pm_with_url;
|
group.pm_with_url = message_container.pm_with_url;
|
||||||
group.display_reply_to = message_store.get_pm_full_names(message_container.msg);
|
group.display_reply_to = message_store.get_pm_full_names(message_container.msg);
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import * as channel from "./channel";
|
|||||||
import * as feedback_widget from "./feedback_widget";
|
import * as feedback_widget from "./feedback_widget";
|
||||||
import {$t} from "./i18n";
|
import {$t} from "./i18n";
|
||||||
import * as message_lists from "./message_lists";
|
import * as message_lists from "./message_lists";
|
||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import * as overlays from "./overlays";
|
import * as overlays from "./overlays";
|
||||||
import * as recent_topics_ui from "./recent_topics_ui";
|
import * as recent_topics_ui from "./recent_topics_ui";
|
||||||
import * as settings_muted_topics from "./settings_muted_topics";
|
import * as settings_muted_topics from "./settings_muted_topics";
|
||||||
@@ -14,6 +13,7 @@ import * as stream_data from "./stream_data";
|
|||||||
import * as stream_list from "./stream_list";
|
import * as stream_list from "./stream_list";
|
||||||
import * as stream_popover from "./stream_popover";
|
import * as stream_popover from "./stream_popover";
|
||||||
import * as unread_ui from "./unread_ui";
|
import * as unread_ui from "./unread_ui";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
|
|
||||||
export function rerender_for_muted_topic(old_muted_topics) {
|
export function rerender_for_muted_topic(old_muted_topics) {
|
||||||
stream_list.update_streams_sidebar();
|
stream_list.update_streams_sidebar();
|
||||||
@@ -28,7 +28,7 @@ export function rerender_for_muted_topic(old_muted_topics) {
|
|||||||
// We only update those topics which could have been affected, because
|
// We only update those topics which could have been affected, because
|
||||||
// we want to avoid doing a complete rerender of the recent topics view,
|
// we want to avoid doing a complete rerender of the recent topics view,
|
||||||
// because that can be expensive.
|
// because that can be expensive.
|
||||||
const current_muted_topics = muted_topics.get_muted_topics();
|
const current_muted_topics = user_topics.get_muted_topics();
|
||||||
const maybe_affected_topics = _.unionWith(old_muted_topics, current_muted_topics, _.isEqual);
|
const maybe_affected_topics = _.unionWith(old_muted_topics, current_muted_topics, _.isEqual);
|
||||||
|
|
||||||
for (const topic_data of maybe_affected_topics) {
|
for (const topic_data of maybe_affected_topics) {
|
||||||
@@ -37,8 +37,8 @@ export function rerender_for_muted_topic(old_muted_topics) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export function handle_topic_updates(muted_topics_list) {
|
export function handle_topic_updates(muted_topics_list) {
|
||||||
const old_muted_topics = muted_topics.get_muted_topics();
|
const old_muted_topics = user_topics.get_muted_topics();
|
||||||
muted_topics.set_muted_topics(muted_topics_list);
|
user_topics.set_muted_topics(muted_topics_list);
|
||||||
stream_popover.hide_topic_popover();
|
stream_popover.hide_topic_popover();
|
||||||
unread_ui.update_unread_counts();
|
unread_ui.update_unread_counts();
|
||||||
rerender_for_muted_topic(old_muted_topics);
|
rerender_for_muted_topic(old_muted_topics);
|
||||||
@@ -108,7 +108,7 @@ export function toggle_topic_mute(message) {
|
|||||||
const stream_id = message.stream_id;
|
const stream_id = message.stream_id;
|
||||||
const topic = message.topic;
|
const topic = message.topic;
|
||||||
|
|
||||||
if (muted_topics.is_topic_muted(stream_id, topic)) {
|
if (user_topics.is_topic_muted(stream_id, topic)) {
|
||||||
unmute_topic(stream_id, topic);
|
unmute_topic(stream_id, topic);
|
||||||
} else if (message.type === "stream") {
|
} else if (message.type === "stream") {
|
||||||
mute_topic(stream_id, topic, true);
|
mute_topic(stream_id, topic, true);
|
||||||
|
|||||||
@@ -10,7 +10,6 @@ import * as hash_util from "./hash_util";
|
|||||||
import {$t} from "./i18n";
|
import {$t} from "./i18n";
|
||||||
import * as message_lists from "./message_lists";
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import * as narrow from "./narrow";
|
import * as narrow from "./narrow";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as navigate from "./navigate";
|
import * as navigate from "./navigate";
|
||||||
@@ -25,6 +24,7 @@ import * as ui from "./ui";
|
|||||||
import * as unread from "./unread";
|
import * as unread from "./unread";
|
||||||
import * as unread_ops from "./unread_ops";
|
import * as unread_ops from "./unread_ops";
|
||||||
import {user_settings} from "./user_settings";
|
import {user_settings} from "./user_settings";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
|
|
||||||
const notice_memory = new Map();
|
const notice_memory = new Map();
|
||||||
|
|
||||||
@@ -378,10 +378,7 @@ export function message_is_notifiable(message) {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (message.type === "stream" && user_topics.is_topic_muted(message.stream_id, message.topic)) {
|
||||||
message.type === "stream" &&
|
|
||||||
muted_topics.is_topic_muted(message.stream_id, message.topic)
|
|
||||||
) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -559,10 +556,7 @@ export function get_local_notify_mix_reason(message) {
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (
|
if (message.type === "stream" && user_topics.is_topic_muted(message.stream_id, message.topic)) {
|
||||||
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."});
|
return $t({defaultMessage: "Sent! Your message was sent to a topic you have muted."});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ import {localstorage} from "./localstorage";
|
|||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as message_util from "./message_util";
|
import * as message_util from "./message_util";
|
||||||
import * as message_view_header from "./message_view_header";
|
import * as message_view_header from "./message_view_header";
|
||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import * as narrow from "./narrow";
|
import * as narrow from "./narrow";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as navigate from "./navigate";
|
import * as navigate from "./navigate";
|
||||||
@@ -30,6 +29,7 @@ import * as timerender from "./timerender";
|
|||||||
import * as top_left_corner from "./top_left_corner";
|
import * as top_left_corner from "./top_left_corner";
|
||||||
import * as unread from "./unread";
|
import * as unread from "./unread";
|
||||||
import * as unread_ui from "./unread_ui";
|
import * as unread_ui from "./unread_ui";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
|
|
||||||
let topics_widget;
|
let topics_widget;
|
||||||
// Sets the number of avatars to display.
|
// Sets the number of avatars to display.
|
||||||
@@ -267,7 +267,7 @@ function format_topic(topic_data) {
|
|||||||
// We only supply the data to the topic rows and let jquery
|
// We only supply the data to the topic rows and let jquery
|
||||||
// display / hide them according to filters instead of
|
// display / hide them according to filters instead of
|
||||||
// doing complete re-render.
|
// doing complete re-render.
|
||||||
const topic_muted = Boolean(muted_topics.is_topic_muted(stream_id, topic));
|
const topic_muted = Boolean(user_topics.is_topic_muted(stream_id, topic));
|
||||||
const stream_muted = stream_data.is_muted(stream_id);
|
const stream_muted = stream_data.is_muted(stream_id);
|
||||||
const muted = topic_muted || stream_muted;
|
const muted = topic_muted || stream_muted;
|
||||||
const unread_count = unread.num_unread_for_topic(stream_id, topic);
|
const unread_count = unread.num_unread_for_topic(stream_id, topic);
|
||||||
@@ -386,7 +386,7 @@ export function filters_should_hide_topic(topic_data) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!filters.has("include_muted")) {
|
if (!filters.has("include_muted")) {
|
||||||
const topic_muted = Boolean(muted_topics.is_topic_muted(msg.stream_id, msg.topic));
|
const topic_muted = Boolean(user_topics.is_topic_muted(msg.stream_id, msg.topic));
|
||||||
const stream_muted = stream_data.is_muted(msg.stream_id);
|
const stream_muted = stream_data.is_muted(msg.stream_id);
|
||||||
if (topic_muted || stream_muted) {
|
if (topic_muted || stream_muted) {
|
||||||
return true;
|
return true;
|
||||||
|
|||||||
@@ -3,14 +3,14 @@ import $ from "jquery";
|
|||||||
import render_muted_topic_ui_row from "../templates/muted_topic_ui_row.hbs";
|
import render_muted_topic_ui_row from "../templates/muted_topic_ui_row.hbs";
|
||||||
|
|
||||||
import * as ListWidget from "./list_widget";
|
import * as ListWidget from "./list_widget";
|
||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import * as muted_topics_ui from "./muted_topics_ui";
|
import * as muted_topics_ui from "./muted_topics_ui";
|
||||||
import * as ui from "./ui";
|
import * as ui from "./ui";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
|
|
||||||
export let loaded = false;
|
export let loaded = false;
|
||||||
|
|
||||||
export function populate_list() {
|
export function populate_list() {
|
||||||
const all_muted_topics = muted_topics.get_muted_topics();
|
const all_muted_topics = user_topics.get_muted_topics();
|
||||||
const $muted_topics_table = $("#muted_topics_table");
|
const $muted_topics_table = $("#muted_topics_table");
|
||||||
const $search_input = $("#muted_topics_search");
|
const $search_input = $("#muted_topics_search");
|
||||||
|
|
||||||
|
|||||||
@@ -22,7 +22,6 @@ import {DropdownListWidget} from "./dropdown_list_widget";
|
|||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import {$t, $t_html} from "./i18n";
|
import {$t, $t_html} from "./i18n";
|
||||||
import * as message_edit from "./message_edit";
|
import * as message_edit from "./message_edit";
|
||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import * as muted_topics_ui from "./muted_topics_ui";
|
import * as muted_topics_ui from "./muted_topics_ui";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as popovers from "./popovers";
|
import * as popovers from "./popovers";
|
||||||
@@ -38,6 +37,7 @@ import * as sub_store from "./sub_store";
|
|||||||
import * as ui_report from "./ui_report";
|
import * as ui_report from "./ui_report";
|
||||||
import * as unread_ops from "./unread_ops";
|
import * as unread_ops from "./unread_ops";
|
||||||
import {user_settings} from "./user_settings";
|
import {user_settings} from "./user_settings";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
|
|
||||||
// We handle stream popovers and topic popovers in this
|
// We handle stream popovers and topic popovers in this
|
||||||
// module. Both are popped up from the left sidebar.
|
// module. Both are popped up from the left sidebar.
|
||||||
@@ -279,7 +279,7 @@ function build_topic_popover(opts) {
|
|||||||
popovers.hide_all();
|
popovers.hide_all();
|
||||||
show_streamlist_sidebar();
|
show_streamlist_sidebar();
|
||||||
|
|
||||||
const topic_muted = muted_topics.is_topic_muted(sub.stream_id, topic_name);
|
const topic_muted = user_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;
|
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
|
// Arguably, we could offer the "Move topic" option even if users
|
||||||
// can only edit the name within a stream.
|
// can only edit the name within a stream.
|
||||||
|
|||||||
@@ -1,9 +1,9 @@
|
|||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import * as pm_conversations from "./pm_conversations";
|
import * as pm_conversations from "./pm_conversations";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
import * as stream_sort from "./stream_sort";
|
import * as stream_sort from "./stream_sort";
|
||||||
import * as stream_topic_history from "./stream_topic_history";
|
import * as stream_topic_history from "./stream_topic_history";
|
||||||
import * as unread from "./unread";
|
import * as unread from "./unread";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
|
|
||||||
export function next_topic(streams, get_topics, has_unread_messages, curr_stream, curr_topic) {
|
export function next_topic(streams, get_topics, has_unread_messages, curr_stream, curr_topic) {
|
||||||
const curr_stream_index = streams.indexOf(curr_stream); // -1 if not found
|
const curr_stream_index = streams.indexOf(curr_stream); // -1 if not found
|
||||||
@@ -67,7 +67,7 @@ export function get_next_topic(curr_stream, curr_topic) {
|
|||||||
function get_unmuted_topics(stream_name) {
|
function get_unmuted_topics(stream_name) {
|
||||||
const stream_id = stream_data.get_stream_id(stream_name);
|
const stream_id = stream_data.get_stream_id(stream_name);
|
||||||
let topics = stream_topic_history.get_recent_topic_names(stream_id);
|
let topics = stream_topic_history.get_recent_topic_names(stream_id);
|
||||||
topics = topics.filter((topic) => !muted_topics.is_topic_muted(stream_id, topic));
|
topics = topics.filter((topic) => !user_topics.is_topic_muted(stream_id, topic));
|
||||||
return topics;
|
return topics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -1,11 +1,11 @@
|
|||||||
import * as resolved_topic from "../shared/js/resolved_topic";
|
import * as resolved_topic from "../shared/js/resolved_topic";
|
||||||
|
|
||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as stream_topic_history from "./stream_topic_history";
|
import * as stream_topic_history from "./stream_topic_history";
|
||||||
import * as topic_list from "./topic_list";
|
import * as topic_list from "./topic_list";
|
||||||
import * as unread from "./unread";
|
import * as unread from "./unread";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
|
||||||
const max_topics = 5;
|
const max_topics = 5;
|
||||||
@@ -32,7 +32,7 @@ export function get_list_info(stream_id, zoomed) {
|
|||||||
for (const [idx, topic_name] of topic_names.entries()) {
|
for (const [idx, topic_name] of topic_names.entries()) {
|
||||||
const num_unread = unread.num_unread_for_topic(stream_id, topic_name);
|
const num_unread = unread.num_unread_for_topic(stream_id, topic_name);
|
||||||
const is_active_topic = active_topic === topic_name.toLowerCase();
|
const is_active_topic = active_topic === topic_name.toLowerCase();
|
||||||
const is_topic_muted = muted_topics.is_topic_muted(stream_id, topic_name);
|
const is_topic_muted = user_topics.is_topic_muted(stream_id, topic_name);
|
||||||
const [topic_resolved_prefix, topic_display_name] =
|
const [topic_resolved_prefix, topic_display_name] =
|
||||||
resolved_topic.display_parts(topic_name);
|
resolved_topic.display_parts(topic_name);
|
||||||
|
|
||||||
|
|||||||
@@ -50,7 +50,6 @@ import * as message_lists from "./message_lists";
|
|||||||
import * as message_scroll from "./message_scroll";
|
import * as message_scroll from "./message_scroll";
|
||||||
import * as message_view_header from "./message_view_header";
|
import * as message_view_header from "./message_view_header";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import * as muted_users from "./muted_users";
|
import * as muted_users from "./muted_users";
|
||||||
import * as navbar_alerts from "./navbar_alerts";
|
import * as navbar_alerts from "./navbar_alerts";
|
||||||
import * as navigate from "./navigate";
|
import * as navigate from "./navigate";
|
||||||
@@ -103,6 +102,7 @@ import * as user_groups from "./user_groups";
|
|||||||
import {initialize_user_settings, user_settings} from "./user_settings";
|
import {initialize_user_settings, user_settings} from "./user_settings";
|
||||||
import * as user_status from "./user_status";
|
import * as user_status from "./user_status";
|
||||||
import * as user_status_ui from "./user_status_ui";
|
import * as user_status_ui from "./user_status_ui";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
|
|
||||||
// This is where most of our initialization takes place.
|
// This is where most of our initialization takes place.
|
||||||
// TODO: Organize it a lot better. In particular, move bigger
|
// TODO: Organize it a lot better. In particular, move bigger
|
||||||
@@ -620,7 +620,7 @@ export function initialize_everything() {
|
|||||||
stream_edit_subscribers.initialize();
|
stream_edit_subscribers.initialize();
|
||||||
stream_data.initialize(stream_data_params);
|
stream_data.initialize(stream_data_params);
|
||||||
pm_conversations.recent.initialize(pm_conversations_params);
|
pm_conversations.recent.initialize(pm_conversations_params);
|
||||||
muted_topics.initialize();
|
user_topics.initialize();
|
||||||
muted_users.initialize();
|
muted_users.initialize();
|
||||||
stream_settings_ui.initialize();
|
stream_settings_ui.initialize();
|
||||||
stream_list.initialize();
|
stream_list.initialize();
|
||||||
|
|||||||
@@ -1,12 +1,12 @@
|
|||||||
import {FoldDict} from "./fold_dict";
|
import {FoldDict} from "./fold_dict";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as muted_topics from "./muted_topics";
|
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as settings_config from "./settings_config";
|
import * as settings_config from "./settings_config";
|
||||||
import * as stream_data from "./stream_data";
|
import * as stream_data from "./stream_data";
|
||||||
import * as sub_store from "./sub_store";
|
import * as sub_store from "./sub_store";
|
||||||
import {user_settings} from "./user_settings";
|
import {user_settings} from "./user_settings";
|
||||||
|
import * as user_topics from "./user_topics";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
|
||||||
// The unread module tracks the message IDs and locations of the
|
// The unread module tracks the message IDs and locations of the
|
||||||
@@ -251,7 +251,7 @@ class UnreadTopicCounter {
|
|||||||
let stream_count = 0;
|
let stream_count = 0;
|
||||||
for (const [topic, msgs] of per_stream_bucketer) {
|
for (const [topic, msgs] of per_stream_bucketer) {
|
||||||
const topic_count = msgs.size;
|
const topic_count = msgs.size;
|
||||||
if (!muted_topics.is_topic_muted(stream_id, topic)) {
|
if (!user_topics.is_topic_muted(stream_id, topic)) {
|
||||||
stream_count += topic_count;
|
stream_count += topic_count;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -316,7 +316,7 @@ class UnreadTopicCounter {
|
|||||||
|
|
||||||
const sub = sub_store.get(stream_id);
|
const sub = sub_store.get(stream_id);
|
||||||
for (const [topic, msgs] of per_stream_bucketer) {
|
for (const [topic, msgs] of per_stream_bucketer) {
|
||||||
if (sub && !muted_topics.is_topic_muted(stream_id, topic)) {
|
if (sub && !user_topics.is_topic_muted(stream_id, topic)) {
|
||||||
stream_count += msgs.size;
|
stream_count += msgs.size;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -348,7 +348,7 @@ class UnreadTopicCounter {
|
|||||||
const ids = [];
|
const ids = [];
|
||||||
const sub = sub_store.get(stream_id);
|
const sub = sub_store.get(stream_id);
|
||||||
for (const [topic, id_set] of per_stream_bucketer) {
|
for (const [topic, id_set] of per_stream_bucketer) {
|
||||||
if (sub && !muted_topics.is_topic_muted(stream_id, topic)) {
|
if (sub && !user_topics.is_topic_muted(stream_id, topic)) {
|
||||||
for (const id of id_set) {
|
for (const id of id_set) {
|
||||||
ids.push(id);
|
ids.push(id);
|
||||||
}
|
}
|
||||||
@@ -484,7 +484,7 @@ export function update_message_for_mention(message) {
|
|||||||
const is_unmuted_mention =
|
const is_unmuted_mention =
|
||||||
message.type === "stream" &&
|
message.type === "stream" &&
|
||||||
message.mentioned &&
|
message.mentioned &&
|
||||||
!muted_topics.is_topic_muted(message.stream_id, message.topic);
|
!user_topics.is_topic_muted(message.stream_id, message.topic);
|
||||||
|
|
||||||
if (is_unmuted_mention || message.mentioned_me_directly) {
|
if (is_unmuted_mention || message.mentioned_me_directly) {
|
||||||
unread_mentions_counter.add(message.id);
|
unread_mentions_counter.add(message.id);
|
||||||
|
|||||||
Reference in New Issue
Block a user