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.

refactor: Rename frontend muting stuff to include 'topic'.

Abhijeet Prasad Bodasfd2bf0b31b64
diff --git a/frontend_tests/node_tests/dispatch.js b/frontend_tests/node_tests/dispatch.js
index 5da120f7419..fee444ae2f4 100644
--- a/frontend_tests/node_tests/dispatch.js
+++ b/frontend_tests/node_tests/dispatch.js
@@ -214,7 +214,7 @@ run_test("muted_topics", (override) => {
const event = event_fixtures.muted_topics;
with_stub((stub) => {
- override("muting_ui.handle_updates", stub.f);
+ override("muting_ui.handle_topic_updates", stub.f);
dispatch(event);
const args = stub.get_args("muted_topics");
assert_same(args.muted_topics, event.muted_topics);
diff --git a/frontend_tests/node_tests/hotkey.js b/frontend_tests/node_tests/hotkey.js
index 69d253a1ef0..d23c703a8e6 100644
--- a/frontend_tests/node_tests/hotkey.js
+++ b/frontend_tests/node_tests/hotkey.js
@@ -356,7 +356,7 @@ run_test("basic_chars", () => {
emoji_picker.reactions_popped = return_false;
assert_mapping("G", "navigate.to_end");
- assert_mapping("M", "muting_ui.toggle_mute");
+ assert_mapping("M", "muting_ui.toggle_topic_mute");
// Test keys that work when a message is selected and
// also when the message list is empty.
diff --git a/frontend_tests/node_tests/settings_muting.js b/frontend_tests/node_tests/settings_muting.js
index 4738150e5cb..4c6fbed5e80 100644
--- a/frontend_tests/node_tests/settings_muting.js
+++ b/frontend_tests/node_tests/settings_muting.js
@@ -25,7 +25,7 @@ stream_data.add_sub(frontend);
run_test("settings", () => {
muting.add_muted_topic(frontend.stream_id, "js", 1577836800);
- let set_up_ui_called = false;
+ let set_up_topic_ui_called = false;
muting_ui.set_up_muted_topics_ui = function () {
const opts = muting.get_muted_topics();
assert.deepEqual(opts, [
@@ -37,7 +37,7 @@ run_test("settings", () => {
topic: "js",
},
]);
- set_up_ui_called = true;
+ set_up_topic_ui_called = true;
};
assert.equal(settings_muting.loaded, false);
@@ -45,43 +45,43 @@ run_test("settings", () => {
settings_muting.set_up();
assert.equal(settings_muting.loaded, true);
- const click_handler = $("body").get_on_handler("click", ".settings-unmute-topic");
- assert.equal(typeof click_handler, "function");
+ const topic_click_handler = $("body").get_on_handler("click", ".settings-unmute-topic");
+ assert.equal(typeof topic_click_handler, "function");
const event = {
stopImmediatePropagation: noop,
};
- const fake_this = $.create("fake.settings-unmute-topic");
- const tr_html = $('tr[data-topic="js"]');
- fake_this.closest = function (opts) {
+ const topic_fake_this = $.create("fake.settings-unmute-topic");
+ const topic_tr_html = $('tr[data-topic="js"]');
+ topic_fake_this.closest = function (opts) {
assert.equal(opts, "tr");
- return tr_html;
+ return topic_tr_html;
};
- let data_called = 0;
- tr_html.attr = function (opts) {
+ let topic_data_called = 0;
+ topic_tr_html.attr = function (opts) {
if (opts === "data-stream-id") {
- data_called += 1;
+ topic_data_called += 1;
return frontend.stream_id;
}
if (opts === "data-topic") {
- data_called += 1;
+ topic_data_called += 1;
return "js";
}
throw new Error(`Unknown attribute ${opts}`);
};
- let unmute_called = false;
- muting_ui.unmute = function (stream_id, topic) {
+ let unmute_topic_called = false;
+ muting_ui.unmute_topic = function (stream_id, topic) {
assert.equal(stream_id, frontend.stream_id);
assert.equal(topic, "js");
- unmute_called = true;
+ unmute_topic_called = true;
};
- click_handler.call(fake_this, event);
- assert(unmute_called);
- assert(set_up_ui_called);
- assert.equal(data_called, 2);
+ topic_click_handler.call(topic_fake_this, event);
+ assert(unmute_topic_called);
+ assert(set_up_topic_ui_called);
+ assert.equal(topic_data_called, 2);
});
run_test("reset", () => {
diff --git a/static/js/click_handlers.js b/static/js/click_handlers.js
index 36b9b6f94c1..c085a10f8f3 100644
--- a/static/js/click_handlers.js
+++ b/static/js/click_handlers.js
@@ -392,7 +392,7 @@ exports.initialize = function () {
e.stopPropagation();
const stream_id = Number.parseInt($(e.currentTarget).attr("data-stream-id"), 10);
const topic = $(e.currentTarget).attr("data-topic-name");
- muting_ui.mute(stream_id, topic);
+ muting_ui.mute_topic(stream_id, topic);
});
$("body").on("keydown", ".on_hover_topic_mute", convert_enter_to_click);
@@ -401,7 +401,7 @@ exports.initialize = function () {
e.stopPropagation();
const stream_id = Number.parseInt($(e.currentTarget).attr("data-stream-id"), 10);
const topic = $(e.currentTarget).attr("data-topic-name");
- muting_ui.unmute(stream_id, topic);
+ muting_ui.unmute_topic(stream_id, topic);
});
$("body").on("keydown", ".on_hover_topic_unmute", convert_enter_to_click);
diff --git a/static/js/hotkey.js b/static/js/hotkey.js
index 471bdfb4438..0c70530df0d 100644
--- a/static/js/hotkey.js
+++ b/static/js/hotkey.js
@@ -89,7 +89,7 @@ const keypress_mappings = {
71: {name: "G_end", message_view_only: true}, // 'G'
74: {name: "vim_page_down", message_view_only: true}, // 'J'
75: {name: "vim_page_up", message_view_only: true}, // 'K'
- 77: {name: "toggle_mute", message_view_only: true}, // 'M'
+ 77: {name: "toggle_topic_mute", message_view_only: true}, // 'M'
80: {name: "narrow_private", message_view_only: true}, // 'P'
82: {name: "respond_to_author", message_view_only: true}, // 'R'
83: {name: "narrow_by_topic", message_view_only: true}, //'S'
@@ -824,8 +824,8 @@ exports.process_hotkey = function (e, hotkey) {
reactions.toggle_emoji_reaction(msg.id, canonical_name);
return true;
}
- case "toggle_mute":
- muting_ui.toggle_mute(msg);
+ case "toggle_topic_mute":
+ muting_ui.toggle_topic_mute(msg);
return true;
case "toggle_message_collapse":
condense.toggle_collapse(msg);
diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js
index 931a8ef5b5a..3ac33095162 100644
--- a/static/js/muting_ui.js
+++ b/static/js/muting_ui.js
@@ -9,7 +9,7 @@ function timestamp_ms() {
let last_topic_update = 0;
-exports.rerender = function () {
+exports.rerender_on_topic_update = function () {
// Note: We tend to optimistically rerender muting preferences before
// the backend actually acknowledges the mute. This gives a more
// immediate feel to the user, and if the backend fails temporarily,
@@ -27,7 +27,7 @@ exports.rerender = function () {
}
};
-exports.persist_mute = function (stream_id, topic_name) {
+exports.persist_topic_mute = function (stream_id, topic_name) {
const data = {
stream_id,
topic: topic_name,
@@ -41,7 +41,7 @@ exports.persist_mute = function (stream_id, topic_name) {
});
};
-exports.persist_unmute = function (stream_id, topic_name) {
+exports.persist_topic_unmute = function (stream_id, topic_name) {
const data = {
stream_id,
topic: topic_name,
@@ -55,7 +55,7 @@ exports.persist_unmute = function (stream_id, topic_name) {
});
};
-exports.handle_updates = function (muted_topics) {
+exports.handle_topic_updates = function (muted_topics) {
if (timestamp_ms() < last_topic_update + 1000) {
// This topic update is either the one that we just rendered, or,
// much less likely, it's coming from another device and would probably
@@ -64,7 +64,7 @@ exports.handle_updates = function (muted_topics) {
}
exports.update_muted_topics(muted_topics);
- exports.rerender();
+ exports.rerender_on_topic_update();
};
exports.update_muted_topics = function (muted_topics) {
@@ -96,14 +96,14 @@ exports.set_up_muted_topics_ui = function () {
});
};
-exports.mute = function (stream_id, topic) {
+exports.mute_topic = function (stream_id, topic) {
const stream_name = stream_data.maybe_get_stream_name(stream_id);
stream_popover.hide_topic_popover();
muting.add_muted_topic(stream_id, topic);
unread_ui.update_unread_counts();
- exports.rerender();
- exports.persist_mute(stream_id, topic);
+ exports.rerender_on_topic_update();
+ exports.persist_topic_mute(stream_id, topic);
feedback_widget.show({
populate(container) {
const rendered_html = render_topic_muted();
@@ -112,7 +112,7 @@ exports.mute = function (stream_id, topic) {
container.find(".topic").text(topic);
},
on_undo() {
- exports.unmute(stream_id, topic);
+ exports.unmute_topic(stream_id, topic);
},
title_text: i18n.t("Topic muted"),
undo_button_text: i18n.t("Unmute"),
@@ -120,27 +120,27 @@ exports.mute = function (stream_id, topic) {
recent_topics.update_topic_is_muted(stream_id, topic);
};
-exports.unmute = function (stream_id, topic) {
+exports.unmute_topic = function (stream_id, topic) {
// we don't run a unmute_notify function because it isn't an issue as much
// if someone accidentally unmutes a stream rather than if they mute it
// and miss out on info.
stream_popover.hide_topic_popover();
muting.remove_muted_topic(stream_id, topic);
unread_ui.update_unread_counts();
- exports.rerender();
- exports.persist_unmute(stream_id, topic);
+ exports.rerender_on_topic_update();
+ exports.persist_topic_unmute(stream_id, topic);
feedback_widget.dismiss();
recent_topics.update_topic_is_muted(stream_id, topic);
};
-exports.toggle_mute = function (message) {
+exports.toggle_topic_mute = function (message) {
const stream_id = message.stream_id;
const topic = message.topic;
if (muting.is_topic_muted(stream_id, topic)) {
- exports.unmute(stream_id, topic);
+ exports.unmute_topic(stream_id, topic);
} else if (message.type === "stream") {
- exports.mute(stream_id, topic);
+ exports.mute_topic(stream_id, topic);
}
};
diff --git a/static/js/popovers.js b/static/js/popovers.js
index 0a8fcef0436..3e19e206d23 100644
--- a/static/js/popovers.js
+++ b/static/js/popovers.js
@@ -1202,7 +1202,7 @@ exports.register_click_handlers = function () {
const topic = $(e.currentTarget).attr("data-msg-topic");
exports.hide_actions_popover();
- muting_ui.mute(stream_id, topic);
+ muting_ui.mute_topic(stream_id, topic);
e.stopPropagation();
e.preventDefault();
});
@@ -1212,7 +1212,7 @@ exports.register_click_handlers = function () {
const topic = $(e.currentTarget).attr("data-msg-topic");
exports.hide_actions_popover();
- muting_ui.unmute(stream_id, topic);
+ muting_ui.unmute_topic(stream_id, topic);
e.stopPropagation();
e.preventDefault();
});
diff --git a/static/js/server_events_dispatch.js b/static/js/server_events_dispatch.js
index 4cc4b87ba13..9ba673ffa00 100644
--- a/static/js/server_events_dispatch.js
+++ b/static/js/server_events_dispatch.js
@@ -76,7 +76,7 @@ exports.dispatch_normal_event = function dispatch_normal_event(event) {
break;
case "muted_topics":
- muting_ui.handle_updates(event.muted_topics);
+ muting_ui.handle_topic_updates(event.muted_topics);
break;
case "presence":
diff --git a/static/js/settings_muting.js b/static/js/settings_muting.js
index d1d00712a53..06e73c227d0 100644
--- a/static/js/settings_muting.js
+++ b/static/js/settings_muting.js
@@ -11,7 +11,7 @@ exports.set_up = function () {
e.stopImmediatePropagation();
- muting_ui.unmute(stream_id, topic);
+ muting_ui.unmute_topic(stream_id, topic);
$row.remove();
});
diff --git a/static/js/stream_popover.js b/static/js/stream_popover.js
index a3288e35f6b..6e3f69522c4 100644
--- a/static/js/stream_popover.js
+++ b/static/js/stream_popover.js
@@ -521,7 +521,7 @@ exports.register_topic_handlers = function () {
}
const topic = $(e.currentTarget).attr("data-topic-name");
- muting_ui.mute(stream_id, topic);
+ muting_ui.mute_topic(stream_id, topic);
e.stopPropagation();
e.preventDefault();
});
@@ -534,7 +534,7 @@ exports.register_topic_handlers = function () {
}
const topic = $(e.currentTarget).attr("data-topic-name");
- muting_ui.unmute(stream_id, topic);
+ muting_ui.unmute_topic(stream_id, topic);
e.stopPropagation();
e.preventDefault();
});