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 MessageList.muting_enabled.

Abhijeet Prasad Bodas9ae44c769c5c
diff --git a/frontend_tests/node_tests/message_list_data.js b/frontend_tests/node_tests/message_list_data.js
index b9fa689c9f0..89109805ebf 100644
--- a/frontend_tests/node_tests/message_list_data.js
+++ b/frontend_tests/node_tests/message_list_data.js
@@ -38,7 +38,7 @@ function assert_contents(mld, msg_ids) {
run_test("basics", () => {
const mld = new MessageListData({
- muting_enabled: false,
+ excludes_muted_topics: false,
filter: undefined,
});
@@ -105,7 +105,7 @@ run_test("basics", () => {
run_test("muting enabled", () => {
const mld = new MessageListData({
- muting_enabled: true,
+ excludes_muted_topics: true,
filter: undefined,
});
@@ -139,7 +139,7 @@ run_test("more muting", () => {
};
const mld = new MessageListData({
- muting_enabled: true,
+ excludes_muted_topics: true,
filter: undefined,
});
@@ -202,7 +202,7 @@ run_test("more muting", () => {
run_test("errors", () => {
const mld = new MessageListData({
- muting_enabled: false,
+ excludes_muted_topics: false,
filter: undefined,
});
assert.equal(mld.get("bogus-id"), undefined);
diff --git a/frontend_tests/node_tests/narrow_local.js b/frontend_tests/node_tests/narrow_local.js
index 9f8da69ed6c..9dd2a5c73db 100644
--- a/frontend_tests/node_tests/narrow_local.js
+++ b/frontend_tests/node_tests/narrow_local.js
@@ -32,10 +32,10 @@ function test_with(fixture) {
}
}
- const muting_enabled = narrow_state.muting_enabled();
+ const excludes_muted_topics = narrow_state.excludes_muted_topics();
const msg_data = new MessageListData({
filter: narrow_state.filter(),
- muting_enabled,
+ excludes_muted_topics,
});
const id_info = {
target_id: fixture.target_id,
diff --git a/frontend_tests/node_tests/narrow_state.js b/frontend_tests/node_tests/narrow_state.js
index 4b7b377c1ce..d7a2e345e93 100644
--- a/frontend_tests/node_tests/narrow_state.js
+++ b/frontend_tests/node_tests/narrow_state.js
@@ -140,27 +140,27 @@ run_test("operators", () => {
assert.equal(result.length, 0);
});
-run_test("muting_enabled", () => {
+run_test("excludes_muted_topics", () => {
set_filter([["stream", "devel"]]);
- assert(narrow_state.muting_enabled());
+ assert(narrow_state.excludes_muted_topics());
narrow_state.reset_current_filter(); // not narrowed, basically
- assert(narrow_state.muting_enabled());
+ assert(narrow_state.excludes_muted_topics());
set_filter([
["stream", "devel"],
["topic", "mac"],
]);
- assert(!narrow_state.muting_enabled());
+ assert(!narrow_state.excludes_muted_topics());
set_filter([["search", "whatever"]]);
- assert(!narrow_state.muting_enabled());
+ assert(!narrow_state.excludes_muted_topics());
set_filter([["is", "private"]]);
- assert(!narrow_state.muting_enabled());
+ assert(!narrow_state.excludes_muted_topics());
set_filter([["is", "starred"]]);
- assert(!narrow_state.muting_enabled());
+ assert(!narrow_state.excludes_muted_topics());
});
run_test("set_compose_defaults", () => {
diff --git a/static/js/message_fetch.js b/static/js/message_fetch.js
index 6e493259119..c80061df349 100644
--- a/static/js/message_fetch.js
+++ b/static/js/message_fetch.js
@@ -466,7 +466,7 @@ exports.initialize = function () {
// without a `table_name` attached.
const recent_topics_message_list = new message_list.MessageList({
filter: new Filter([{operator: "in", operand: "home"}]),
- muting_enabled: true,
+ excludes_muted_topics: true,
});
exports.load_messages({
anchor: "newest",
diff --git a/static/js/message_list.js b/static/js/message_list.js
index e4bcee26333..d1902b3f302 100644
--- a/static/js/message_list.js
+++ b/static/js/message_list.js
@@ -10,14 +10,14 @@ exports.set_narrowed = function (value) {
class MessageList {
constructor(opts) {
if (opts.data) {
- this.muting_enabled = opts.data.muting_enabled;
+ this.excludes_muted_topics = opts.data.excludes_muted_topics;
this.data = opts.data;
} else {
const filter = opts.filter;
- this.muting_enabled = opts.muting_enabled;
+ this.excludes_muted_topics = opts.excludes_muted_topics;
this.data = new MessageListData({
- muting_enabled: this.muting_enabled,
+ excludes_muted_topics: this.excludes_muted_topics,
filter,
});
}
@@ -375,7 +375,7 @@ class MessageList {
}
update_muting_and_rerender() {
- if (!this.muting_enabled) {
+ if (!this.excludes_muted_topics) {
return;
}
this.data.update_items_for_muting();
@@ -412,7 +412,7 @@ class MessageList {
exports.MessageList = MessageList;
exports.all = new MessageList({
- muting_enabled: false,
+ excludes_muted_topics: false,
});
window.message_list = exports;
diff --git a/static/js/message_list_data.js b/static/js/message_list_data.js
index 2bc44becac7..83fb0f8fc72 100644
--- a/static/js/message_list_data.js
+++ b/static/js/message_list_data.js
@@ -6,8 +6,8 @@ const util = require("./util");
class MessageListData {
constructor(opts) {
- this.muting_enabled = opts.muting_enabled;
- if (this.muting_enabled) {
+ this.excludes_muted_topics = opts.excludes_muted_topics;
+ if (this.excludes_muted_topics) {
this._all_items = [];
}
this._items = [];
@@ -110,7 +110,7 @@ class MessageListData {
}
clear() {
- if (this.muting_enabled) {
+ if (this.excludes_muted_topics) {
this._all_items = [];
}
@@ -178,7 +178,7 @@ class MessageListData {
}
update_items_for_muting() {
- if (!this.muting_enabled) {
+ if (!this.excludes_muted_topics) {
return;
}
this._items = this.unmuted_messages(this._all_items);
@@ -253,7 +253,7 @@ class MessageListData {
// "interior" messages to add and can't optimize
// things by only doing prepend or only doing append.
let viewable_messages;
- if (this.muting_enabled) {
+ if (this.excludes_muted_topics) {
this._all_items = messages.concat(this._all_items);
this._all_items.sort((a, b) => a.id - b.id);
@@ -272,7 +272,7 @@ class MessageListData {
append(messages) {
// Caller should have already filtered
let viewable_messages;
- if (this.muting_enabled) {
+ if (this.excludes_muted_topics) {
this._all_items = this._all_items.concat(messages);
viewable_messages = this.unmuted_messages(messages);
} else {
@@ -286,7 +286,7 @@ class MessageListData {
prepend(messages) {
// Caller should have already filtered
let viewable_messages;
- if (this.muting_enabled) {
+ if (this.excludes_muted_topics) {
this._all_items = messages.concat(this._all_items);
viewable_messages = this.unmuted_messages(messages);
} else {
@@ -305,7 +305,7 @@ class MessageListData {
}
this._items = this._items.filter((msg) => !msg_ids_to_remove.has(msg.id));
- if (this.muting_enabled) {
+ if (this.excludes_muted_topics) {
this._all_items = this._all_items.filter((msg) => !msg_ids_to_remove.has(msg.id));
}
}
@@ -496,7 +496,7 @@ class MessageListData {
) {
blueslip.debug("Changed message ID from server caused out-of-order list, reordering");
this._items.sort(message_sort_func);
- if (this.muting_enabled) {
+ if (this.excludes_muted_topics) {
this._all_items.sort(message_sort_func);
}
return true;
diff --git a/static/js/muting_ui.js b/static/js/muting_ui.js
index 3ac33095162..7130d583a0d 100644
--- a/static/js/muting_ui.js
+++ b/static/js/muting_ui.js
@@ -16,7 +16,7 @@ exports.rerender_on_topic_update = function () {
// re-doing a mute or unmute is a pretty recoverable thing.
stream_list.update_streams_sidebar();
- if (current_msg_list.muting_enabled) {
+ if (current_msg_list.excludes_muted_topics) {
current_msg_list.update_muting_and_rerender();
}
if (current_msg_list !== home_msg_list) {
diff --git a/static/js/narrow.js b/static/js/narrow.js
index 0ac994adf89..59b9e5867ee 100644
--- a/static/js/narrow.js
+++ b/static/js/narrow.js
@@ -218,14 +218,14 @@ exports.activate = function (raw_operators, opts) {
// reflect the upcoming narrow.
narrow_state.set_current_filter(filter);
- const muting_enabled = narrow_state.muting_enabled();
+ const excludes_muted_topics = narrow_state.excludes_muted_topics();
// Save how far from the pointer the top of the message list was.
exports.save_pre_narrow_offset_for_reload();
let msg_data = new MessageListData({
filter: narrow_state.filter(),
- muting_enabled,
+ excludes_muted_topics,
});
// Populate the message list if we can apply our filter locally (i.e.
@@ -246,7 +246,7 @@ exports.activate = function (raw_operators, opts) {
// the block we're about to request from the server instead.
msg_data = new MessageListData({
filter: narrow_state.filter(),
- muting_enabled,
+ excludes_muted_topics,
});
}
diff --git a/static/js/narrow_state.js b/static/js/narrow_state.js
index 1c2da2eab4a..264e6682bb0 100644
--- a/static/js/narrow_state.js
+++ b/static/js/narrow_state.js
@@ -326,7 +326,7 @@ exports.narrowed_to_starred = function () {
return current_filter.has_operand("is", "starred");
};
-exports.muting_enabled = function () {
+exports.excludes_muted_topics = function () {
return (
!exports.narrowed_to_topic() &&
!exports.narrowed_to_search() &&
diff --git a/static/js/zulip.js b/static/js/zulip.js
index ec7189965d2..9eba2d9e904 100644
--- a/static/js/zulip.js
+++ b/static/js/zulip.js
@@ -7,7 +7,7 @@
const home_msg_list = new message_list.MessageList({
table_name: "zhome",
filter: new Filter([{operator: "in", operand: "home"}]),
- muting_enabled: true,
+ excludes_muted_topics: true,
});
window.home_msg_list = home_msg_list;