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.

message_list: Downgrade message_list.all to MessageListData.

Anders Kaseorg6f764ce4b3c0
diff --git a/frontend_tests/node_tests/example5.js b/frontend_tests/node_tests/example5.js
index 74b8a2b2d1f..2205eae3676 100644
--- a/frontend_tests/node_tests/example5.js
+++ b/frontend_tests/node_tests/example5.js
@@ -90,6 +90,7 @@ run_test("insert_message", (override) => {
assert.equal(message_store.get(new_message.id), undefined);
helper.redirect(huddle_data, "process_loaded_messages");
+ helper.redirect(message_util, "add_new_messages_data");
helper.redirect(message_util, "add_new_messages");
helper.redirect(notifications, "received_messages");
helper.redirect(resize, "resize_page_components");
@@ -107,7 +108,7 @@ run_test("insert_message", (override) => {
// comes in:
assert.deepEqual(helper.events, [
[huddle_data, "process_loaded_messages"],
- [message_util, "add_new_messages"],
+ [message_util, "add_new_messages_data"],
[message_util, "add_new_messages"],
[unread_ui, "update_unread_counts"],
[resize, "resize_page_components"],
diff --git a/frontend_tests/node_tests/example7.js b/frontend_tests/node_tests/example7.js
index 550619ab2fe..4c510660f48 100644
--- a/frontend_tests/node_tests/example7.js
+++ b/frontend_tests/node_tests/example7.js
@@ -109,9 +109,6 @@ run_test("unread_ops", (override) => {
override(message_lists.current, "all_messages", () => test_messages);
// Ignore these interactions for now:
- message_list.all = {
- show_message_as_read() {},
- };
override(message_lists.home, "show_message_as_read", () => {});
override(notifications, "close_notification", () => {});
override(unread_ui, "update_unread_counts", () => {});
diff --git a/frontend_tests/node_tests/message_fetch.js b/frontend_tests/node_tests/message_fetch.js
index a8afb4673a3..345e5d51f62 100644
--- a/frontend_tests/node_tests/message_fetch.js
+++ b/frontend_tests/node_tests/message_fetch.js
@@ -48,6 +48,7 @@ set_global("document", "document-stub");
const message_fetch = zrequire("message_fetch");
+const {all_messages_data} = zrequire("all_messages_data");
const {Filter} = zrequire("../js/filter");
const message_list = zrequire("message_list");
const people = zrequire("people");
@@ -76,16 +77,11 @@ function make_home_msg_list() {
return list;
}
-function make_all_list() {
- return new message_list.MessageList({});
-}
-
function reset_lists() {
message_lists.home = make_home_msg_list();
message_lists.current = message_lists.home;
- message_list.__Rewire__("all", make_all_list());
+ all_messages_data.clear();
stub_message_view(message_lists.home);
- stub_message_view(message_list.all);
}
function config_fake_channel(conf) {
@@ -460,8 +456,7 @@ run_test("loading_newer", () => {
empty_msg_list: true,
});
- message_list.all.append_to_view = () => {};
- message_list.all.append(message_range(444, 445), false);
+ all_messages_data.append(message_range(444, 445), false);
test_happy_path({
msg_list,
diff --git a/frontend_tests/node_tests/narrow_activate.js b/frontend_tests/node_tests/narrow_activate.js
index 6a9ce5ab1ca..bbc42506f7f 100644
--- a/frontend_tests/node_tests/narrow_activate.js
+++ b/frontend_tests/node_tests/narrow_activate.js
@@ -11,6 +11,7 @@ mock_esm("../../static/js/resize", {
resize_stream_filters_container: () => {},
});
+const all_messages_data = mock_esm("../../static/js/all_messages_data");
const channel = mock_esm("../../static/js/channel");
const compose = mock_esm("../../static/js/compose");
const compose_actions = mock_esm("../../static/js/compose_actions");
@@ -159,16 +160,14 @@ run_test("basics", () => {
message_lists.current.selected_id = () => -1;
message_lists.current.get_row = () => row;
- message_list.all = {
+ all_messages_data.all_messages_data = {
all_messages: () => messages,
get: (msg_id) => {
assert.equal(msg_id, selected_id);
return selected_message;
},
- data: {
- fetch_status: {
- has_found_newest: () => true,
- },
+ fetch_status: {
+ has_found_newest: () => true,
},
empty: () => false,
first: () => ({id: 900}),
diff --git a/frontend_tests/node_tests/narrow_local.js b/frontend_tests/node_tests/narrow_local.js
index 9b17f722588..a64a55a54f5 100644
--- a/frontend_tests/node_tests/narrow_local.js
+++ b/frontend_tests/node_tests/narrow_local.js
@@ -5,7 +5,7 @@ const {strict: assert} = require("assert");
const {mock_esm, zrequire} = require("../zjsunit/namespace");
const {run_test} = require("../zjsunit/test");
-const message_list = mock_esm("../../static/js/message_list");
+const all_messages_data = mock_esm("../../static/js/all_messages_data");
const {Filter} = zrequire("../js/filter");
const {MessageListData} = zrequire("../js/message_list_data");
@@ -38,11 +38,9 @@ function test_with(fixture) {
final_select_id: undefined,
};
- message_list.all = {
- data: {
- fetch_status: {
- has_found_newest: () => fixture.has_found_newest,
- },
+ all_messages_data.all_messages_data = {
+ fetch_status: {
+ has_found_newest: () => fixture.has_found_newest,
},
empty: () => fixture.empty,
all_messages: () => {
@@ -394,7 +392,7 @@ run_test("stream/topic not in all_messages", () => {
// This is a bit of a corner case, but you could have a scenario
// where you've gone way back in a topic (perhaps something that
// has been muted a long time) and find an unread message that isn't
- // actually in message_list.all.
+ // actually in all_messages_data.
const fixture = {
filter_terms: [
{operator: "stream", operand: "one"},
diff --git a/frontend_tests/node_tests/recent_senders.js b/frontend_tests/node_tests/recent_senders.js
index b65b305285d..747a79b1235 100644
--- a/frontend_tests/node_tests/recent_senders.js
+++ b/frontend_tests/node_tests/recent_senders.js
@@ -23,8 +23,8 @@ function make_stream_message({stream_id, topic, sender_id}) {
return message;
}
-const message_list = mock_esm("../../static/js/message_list", {
- all: {
+const {all_messages_data} = mock_esm("../../static/js/all_messages_data", {
+ all_messages_data: {
all_messages() {
return Array.from(messages.values());
},
@@ -210,7 +210,7 @@ test("process_message_for_senders", (override) => {
const reduced_msgs = [message3, message4, message7, message8];
- override(message_list.all, "all_messages", () => reduced_msgs);
+ override(all_messages_data, "all_messages", () => reduced_msgs);
assert.equal(rs.get_topic_recent_senders(stream1, topic1).toString(), "2,1");
// delete message1 and message5 sent by sender1
rs.update_topics_of_deleted_message_ids([message1.id, message5.id]);
diff --git a/frontend_tests/node_tests/recent_topics.js b/frontend_tests/node_tests/recent_topics.js
index 005957a868f..254a9805467 100644
--- a/frontend_tests/node_tests/recent_topics.js
+++ b/frontend_tests/node_tests/recent_topics.js
@@ -37,8 +37,8 @@ const topic9 = "topic-9";
const topic10 = "topic-10";
mock_cjs("jquery", $);
-const message_list = mock_esm("../../static/js/message_list", {
- all: {
+const {all_messages_data} = mock_esm("../../static/js/all_messages_data", {
+ all_messages_data: {
all_messages() {
return messages;
},
@@ -698,7 +698,7 @@ test("test_delete_messages", (override) => {
// messages[0] was removed.
let reduced_msgs = messages.slice(1);
- override(message_list.all, "all_messages", () => reduced_msgs);
+ override(all_messages_data, "all_messages", () => reduced_msgs);
let all_topics = rt.get();
assert.equal(
diff --git a/frontend_tests/node_tests/stream_events.js b/frontend_tests/node_tests/stream_events.js
index 128c8d1c520..aa621c98780 100644
--- a/frontend_tests/node_tests/stream_events.js
+++ b/frontend_tests/node_tests/stream_events.js
@@ -20,8 +20,8 @@ const subs = mock_esm("../../static/js/subs", {
update_settings_for_subscribed: noop,
});
-mock_esm("../../static/js/message_list", {
- all: {
+mock_esm("../../static/js/all_messages_data", {
+ all_messages_data: {
all_messages() {
return ["msg"];
},
diff --git a/frontend_tests/node_tests/stream_topic_history.js b/frontend_tests/node_tests/stream_topic_history.js
index 67883c9ff9b..620c34c4058 100644
--- a/frontend_tests/node_tests/stream_topic_history.js
+++ b/frontend_tests/node_tests/stream_topic_history.js
@@ -8,7 +8,7 @@ const {run_test} = require("../zjsunit/test");
const channel = mock_esm("../../static/js/channel");
const message_util = mock_esm("../../static/js/message_util");
-const message_list = zrequire("message_list");
+const all_messages_data = zrequire("all_messages_data");
const unread = zrequire("unread");
const stream_data = zrequire("stream_data");
const stream_topic_history = zrequire("stream_topic_history");
@@ -128,21 +128,19 @@ test("is_complete_for_stream_id", () => {
};
stream_data.add_sub(sub);
- const message_list_all = {
+ const all_messages_data_stub = {
empty: () => false,
- data: {
- fetch_status: {
- has_found_newest: () => true,
- },
+ fetch_status: {
+ has_found_newest: () => true,
},
first: () => ({id: 5}),
};
- with_field(message_list, "all", message_list_all, () => {
+ with_field(all_messages_data, "all_messages_data", all_messages_data_stub, () => {
assert.equal(stream_topic_history.is_complete_for_stream_id(sub.stream_id), true);
// Now simulate a more recent message id.
- message_list.all.first = () => ({id: sub.first_message_id + 1});
+ all_messages_data.all_messages_data.first = () => ({id: sub.first_message_id + 1});
// Note that we'll return `true` here due to
// fetched_stream_ids having the stream_id now.
@@ -164,7 +162,7 @@ test("server_history", () => {
const stream_id = sub.stream_id;
stream_data.add_sub(sub);
- message_list.all.data.fetch_status.has_found_newest = () => false;
+ all_messages_data.all_messages_data.fetch_status.has_found_newest = () => false;
assert.equal(stream_topic_history.is_complete_for_stream_id(stream_id), false);
@@ -355,12 +353,16 @@ test("all_topics_in_cache", (override) => {
assert.equal(stream_topic_history.all_topics_in_cache(sub), false);
- message_list.all.data.clear();
- message_list.all.data.add_messages(messages);
+ all_messages_data.all_messages_data.clear();
+ all_messages_data.all_messages_data.add_messages(messages);
let has_found_newest = false;
- override(message_list.all.data.fetch_status, "has_found_newest", () => has_found_newest);
+ override(
+ all_messages_data.all_messages_data.fetch_status,
+ "has_found_newest",
+ () => has_found_newest,
+ );
assert.equal(stream_topic_history.all_topics_in_cache(sub), false);
has_found_newest = true;
diff --git a/static/js/all_messages_data.js b/static/js/all_messages_data.js
new file mode 100644
index 00000000000..c94b96b42ca
--- /dev/null
+++ b/static/js/all_messages_data.js
@@ -0,0 +1,5 @@
+import {MessageListData} from "./message_list_data";
+
+export const all_messages_data = new MessageListData({
+ excludes_muted_topics: false,
+});
diff --git a/static/js/bundles/app.js b/static/js/bundles/app.js
index 8d3ac5649ee..8ac9761390c 100644
--- a/static/js/bundles/app.js
+++ b/static/js/bundles/app.js
@@ -11,7 +11,6 @@ import "flatpickr";
// Import app JS
import "../setup";
-import "../message_list";
import "../reload";
import "../hotkey";
import "../notifications";
diff --git a/static/js/echo.js b/static/js/echo.js
index 88dbffb5d13..b7007206d3b 100644
--- a/static/js/echo.js
+++ b/static/js/echo.js
@@ -1,6 +1,7 @@
import $ from "jquery";
import * as alert_words from "./alert_words";
+import {all_messages_data} from "./all_messages_data";
import * as blueslip from "./blueslip";
import * as compose from "./compose";
import * as local_message from "./local_message";
@@ -314,7 +315,10 @@ export function reify_message_id(local_id, server_id) {
}
export function update_message_lists({old_id, new_id}) {
- for (const msg_list of [message_list.all, message_lists.home, message_list.narrowed]) {
+ if (all_messages_data !== undefined) {
+ all_messages_data.change_message_id(old_id, new_id);
+ }
+ for (const msg_list of [message_lists.home, message_list.narrowed]) {
if (msg_list !== undefined) {
msg_list.change_message_id(old_id, new_id);
@@ -403,7 +407,8 @@ export function message_send_error(message_id, error_response) {
function abort_message(message) {
// Remove in all lists in which it exists
- for (const msg_list of [message_list.all, message_lists.home, message_lists.current]) {
+ all_messages_data.remove([message.id]);
+ for (const msg_list of [message_lists.home, message_lists.current]) {
msg_list.remove_and_rerender([message.id]);
}
}
diff --git a/static/js/local_message.js b/static/js/local_message.js
index e33f8208050..9bd2e6977ea 100644
--- a/static/js/local_message.js
+++ b/static/js/local_message.js
@@ -1,5 +1,5 @@
+import {all_messages_data} from "./all_messages_data";
import * as blueslip from "./blueslip";
-import * as message_list from "./message_list";
import {page_params} from "./page_params";
function truncate_precision(float) {
@@ -12,8 +12,8 @@ export const get_next_id_float = (function () {
return function () {
const local_id_increment = 0.01;
let latest = page_params.max_message_id;
- if (message_list.all.last() !== undefined) {
- latest = message_list.all.last().id;
+ if (all_messages_data.last() !== undefined) {
+ latest = all_messages_data.last().id;
}
latest = Math.max(0, latest);
const local_id_float = truncate_precision(latest + local_id_increment);
diff --git a/static/js/message_events.js b/static/js/message_events.js
index 9b6d09b358e..df63eec236e 100644
--- a/static/js/message_events.js
+++ b/static/js/message_events.js
@@ -1,6 +1,7 @@
import $ from "jquery";
import * as alert_words from "./alert_words";
+import {all_messages_data} from "./all_messages_data";
import * as channel from "./channel";
import * as compose_fade from "./compose_fade";
import * as compose_state from "./compose_state";
@@ -94,9 +95,9 @@ export function insert_new_messages(messages, sent_by_this_client) {
unread.process_loaded_messages(messages);
huddle_data.process_loaded_messages(messages);
- // message_list.all is a data-only list that we use to populate
+ // all_messages_data is the data that we use to populate
// other lists, so we always update this
- message_util.add_new_messages(messages, message_list.all);
+ message_util.add_new_messages_data(messages, all_messages_data);
let render_info;
@@ -422,7 +423,8 @@ export function update_messages(events) {
}
export function remove_messages(message_ids) {
- for (const list of [message_list.all, message_lists.home, message_list.narrowed]) {
+ all_messages_data.remove(message_ids);
+ for (const list of [message_lists.home, message_list.narrowed]) {
if (list === undefined) {
continue;
}
diff --git a/static/js/message_fetch.js b/static/js/message_fetch.js
index 3fb8045b467..677f5bbbe0b 100644
--- a/static/js/message_fetch.js
+++ b/static/js/message_fetch.js
@@ -1,5 +1,6 @@
import $ from "jquery";
+import {all_messages_data} from "./all_messages_data";
import * as channel from "./channel";
import {Filter} from "./filter";
import * as huddle_data from "./huddle_data";
@@ -62,10 +63,10 @@ function process_result(data, opts) {
message_util.do_unread_count_updates(messages);
// If we're loading more messages into the home view, save them to
- // the message_list.all as well, as the message_lists.home is reconstructed
- // from message_list.all.
+ // the all_messages_data as well, as the message_lists.home is
+ // reconstructed from all_messages_data.
if (opts.msg_list === message_lists.home) {
- message_util.add_old_messages(messages, message_list.all);
+ all_messages_data.add_messages(messages);
}
if (messages.length !== 0) {
@@ -94,10 +95,8 @@ function get_messages_success(data, opts) {
});
if (opts.msg_list === message_lists.home) {
// When we update message_lists.home, we need to also update
- // the fetch_status data structure for message_list.all,
- // which is never rendered (and just used for
- // prepopulating narrowed views).
- message_list.all.data.fetch_status.finish_older_batch({
+ // the fetch_status data structure for all_messages_data.
+ all_messages_data.fetch_status.finish_older_batch({
update_loading_indicator: false,
found_oldest: data.found_oldest,
history_limited: data.history_limited,
@@ -113,16 +112,11 @@ function get_messages_success(data, opts) {
});
if (opts.msg_list === message_lists.home) {
// When we update message_lists.home, we need to also update
- // the fetch_status data structure for message_list.all,
- // which is never rendered (and just used for
- // prepopulating narrowed views).
- opts.fetch_again = message_list.all.data.fetch_status.finish_newer_batch(
- data.messages,
- {
- update_loading_indicator: false,
- found_newest: data.found_newest,
- },
- );
+ // the fetch_status data structure for all_messages_data.
+ opts.fetch_again = all_messages_data.fetch_status.finish_newer_batch(data.messages, {
+ update_loading_indicator: false,
+ found_newest: data.found_newest,
+ });
}
}
@@ -198,7 +192,7 @@ export function load_messages(opts) {
// This block is a hack; structurally, we want to set
// data.narrow = opts.msg_list.data.filter.public_operators()
//
- // But support for the message_list.all sharing of data with
+ // But support for the all_messages_data sharing of data with
// message_lists.home and the (hacky) page_params.narrow feature
// requires a somewhat ugly bundle of conditionals.
if (opts.msg_list === message_lists.home) {
@@ -224,7 +218,7 @@ export function load_messages(opts) {
update_loading_indicator,
});
if (opts.msg_list === message_lists.home) {
- message_list.all.data.fetch_status.start_older_batch({
+ all_messages_data.fetch_status.start_older_batch({
update_loading_indicator,
});
}
@@ -237,7 +231,7 @@ export function load_messages(opts) {
update_loading_indicator,
});
if (opts.msg_list === message_lists.home) {
- message_list.all.data.fetch_status.start_newer_batch({
+ all_messages_data.fetch_status.start_newer_batch({
update_loading_indicator,
});
}
@@ -295,11 +289,9 @@ export function load_messages_for_narrow(opts) {
}
export function get_backfill_anchor(msg_list) {
- if (msg_list === message_lists.home) {
- msg_list = message_list.all;
- }
+ const oldest_msg =
+ msg_list === message_lists.home ? all_messages_data.first() : msg_list.first();
- const oldest_msg = msg_list.first();
if (oldest_msg) {
return oldest_msg.id;
}
@@ -310,11 +302,7 @@ export function get_backfill_anchor(msg_list) {
}
export function get_frontfill_anchor(msg_list) {
- if (msg_list === message_lists.home) {
- msg_list = message_list.all;
- }
-
- const last_msg = msg_list.last();
+ const last_msg = msg_list === message_lists.home ? all_messages_data.last() : msg_list.last();
if (last_msg) {
return last_msg.id;
diff --git a/static/js/message_list.js b/static/js/message_list.js
index 0c96f36345b..7e41b722399 100644
--- a/static/js/message_list.js
+++ b/static/js/message_list.js
@@ -414,7 +414,3 @@ export class MessageList {
return this.data.get_last_message_sent_by_me();
}
}
-
-export const all = new MessageList({
- excludes_muted_topics: false,
-});
diff --git a/static/js/message_live_update.js b/static/js/message_live_update.js
index 0524fd222f5..1cf0ea2e56f 100644
--- a/static/js/message_live_update.js
+++ b/static/js/message_live_update.js
@@ -4,7 +4,7 @@ import * as message_store from "./message_store";
import * as people from "./people";
function rerender_messages_view() {
- for (const list of [message_lists.home, message_list.narrowed, message_list.all]) {
+ for (const list of [message_lists.home, message_list.narrowed]) {
if (list === undefined) {
continue;
}
diff --git a/static/js/message_util.js b/static/js/message_util.js
index 78abeddf967..5ced5c23016 100644
--- a/static/js/message_util.js
+++ b/static/js/message_util.js
@@ -1,7 +1,7 @@
import $ from "jquery";
+import {all_messages_data} from "./all_messages_data";
import * as loading from "./loading";
-import * as message_list from "./message_list";
import * as message_store from "./message_store";
import * as resize from "./resize";
import * as unread from "./unread";
@@ -41,8 +41,20 @@ export function add_new_messages(messages, msg_list) {
return add_messages(messages, msg_list, {messages_are_new: true});
}
+export function add_new_messages_data(messages, msg_list_data) {
+ if (!msg_list_data.fetch_status.has_found_newest()) {
+ // The reasoning in add_new_messages applies here as well;
+ // we're trying to maintain a data structure that's a
+ // contiguous range of message history, so we can't append a
+ // new message that might not be adjacent to that range.
+ msg_list_data.fetch_status.update_expected_max_message_id(messages);
+ return undefined;
+ }
+ return msg_list_data.add_messages(messages);
+}
+
export function get_messages_in_topic(stream_id, topic) {
- return message_list.all
+ return all_messages_data
.all_messages()
.filter(
(x) =>
@@ -54,7 +66,7 @@ export function get_messages_in_topic(stream_id, topic) {
export function get_max_message_id_in_stream(stream_id) {
let max_message_id = 0;
- for (const msg of message_list.all.all_messages()) {
+ for (const msg of all_messages_data.all_messages()) {
if (msg.type === "stream" && msg.stream_id === stream_id && msg.id > max_message_id) {
max_message_id = msg.id;
}
diff --git a/static/js/narrow.js b/static/js/narrow.js
index d1f70be28b1..805b6547687 100644
--- a/static/js/narrow.js
+++ b/static/js/narrow.js
@@ -1,5 +1,6 @@
import $ from "jquery";
+import {all_messages_data} from "./all_messages_data";
import * as blueslip from "./blueslip";
import * as channel from "./channel";
import * as compose from "./compose";
@@ -416,10 +417,10 @@ function min_defined(a, b) {
function load_local_messages(msg_data) {
// This little helper loads messages into our narrow message
// data and returns true unless it's empty. We use this for
- // cases when our local cache (message_list.all) has at least
+ // cases when our local cache (all_messages_data) has at least
// one message the user will expect to see in the new narrow.
- const in_msgs = message_list.all.all_messages();
+ const in_msgs = all_messages_data.all_messages();
msg_data.add_messages(in_msgs);
return !msg_data.empty();
@@ -525,8 +526,8 @@ export function maybe_add_local_messages(opts) {
// Without unread messages or a target ID, we're narrowing to
// the very latest message or first unread if matching the narrow allows.
- if (!message_list.all.data.fetch_status.has_found_newest()) {
- // If message_list.all is not caught up, then we cannot
+ if (!all_messages_data.fetch_status.has_found_newest()) {
+ // If all_messages_data is not caught up, then we cannot
// populate the latest messages for the target narrow
// correctly from there, so we must go to the server.
return;
@@ -534,7 +535,7 @@ export function maybe_add_local_messages(opts) {
if (!load_local_messages(msg_data)) {
return;
}
- // Otherwise, we have matching messages, and message_list.all
+ // Otherwise, we have matching messages, and all_messages_data
// is caught up, so the last message in our now-populated
// msg_data object must be the last message matching the
// narrow the server could give us, so we can render locally.
@@ -550,14 +551,15 @@ export function maybe_add_local_messages(opts) {
id_info.final_select_id = id_info.target_id;
// TODO: We could improve on this next condition by considering
- // cases where `message_list.all.has_found_oldest(); which would
- // come up with e.g. `near: 0` in a small organization.
+ // cases where
+ // `all_messages_data.fetch_status.has_found_oldest()`; which
+ // would come up with e.g. `near: 0` in a small organization.
//
// And similarly for `near: max_int` with has_found_newest.
if (
- message_list.all.empty() ||
- id_info.target_id < message_list.all.first().id ||
- id_info.target_id > message_list.all.last().id
+ all_messages_data.empty() ||
+ id_info.target_id < all_messages_data.first().id ||
+ id_info.target_id > all_messages_data.last().id
) {
// If the target message is outside the range that we had
// available for local population, we must go to the server.
diff --git a/static/js/recent_senders.js b/static/js/recent_senders.js
index 1e20a54d34a..716d9af3761 100644
--- a/static/js/recent_senders.js
+++ b/static/js/recent_senders.js
@@ -52,7 +52,7 @@ export function process_topic_edit(old_stream_id, old_topic, new_topic, new_stre
// Re-processing every message in both the old and new topics is
// expensive. It also potentially loses data, because
- // `message_list.all()` only has contiguous message history, not
+ // `all_messages_data` only has contiguous message history, not
// the complete set of message IDs we've received to the
// `message_store` from the server (E.g. from when we narrowed to
// a stream). But it's the most correct implementation we can
diff --git a/static/js/stream_events.js b/static/js/stream_events.js
index d0e6503766b..b837dd82bb8 100644
--- a/static/js/stream_events.js
+++ b/static/js/stream_events.js
@@ -1,8 +1,8 @@
import $ from "jquery";
+import {all_messages_data} from "./all_messages_data";
import * as blueslip from "./blueslip";
import * as color_data from "./color_data";
-import * as message_list from "./message_list";
import * as message_lists from "./message_lists";
import * as message_util from "./message_util";
import * as message_view_header from "./message_view_header";
@@ -132,7 +132,7 @@ export function mark_subscribed(sub, subscribers, color) {
// Update unread counts as the new stream in sidebar might
// need its unread counts re-calculated
- message_util.do_unread_count_updates(message_list.all.all_messages());
+ message_util.do_unread_count_updates(all_messages_data.all_messages());
stream_list.add_sidebar_row(sub);
}
diff --git a/static/js/stream_muting.js b/static/js/stream_muting.js
index 59e70e8b6fa..02da9bbc2cc 100644
--- a/static/js/stream_muting.js
+++ b/static/js/stream_muting.js
@@ -1,6 +1,6 @@
import $ from "jquery";
-import * as message_list from "./message_list";
+import {all_messages_data} from "./all_messages_data";
import * as message_lists from "./message_lists";
import * as message_scroll from "./message_scroll";
import * as message_util from "./message_util";
@@ -27,8 +27,8 @@ export function update_is_muted(sub, value) {
message_lists.home.clear({clear_selected_id: false});
- // Recreate the message_lists.home with the newly filtered message_list.all
- message_util.add_old_messages(message_list.all.all_messages(), message_lists.home);
+ // Recreate the message_lists.home with the newly filtered all_messages_data
+ message_util.add_old_messages(all_messages_data.all_messages(), message_lists.home);
// Ensure we're still at the same scroll position
if (overlays.is_active()) {
diff --git a/static/js/stream_topic_history.js b/static/js/stream_topic_history.js
index 84a4bbc7b1a..c1dbd601644 100644
--- a/static/js/stream_topic_history.js
+++ b/static/js/stream_topic_history.js
@@ -1,6 +1,6 @@
+import {all_messages_data} from "./all_messages_data";
import * as channel from "./channel";
import {FoldDict} from "./fold_dict";
-import * as message_list from "./message_list";
import * as message_util from "./message_util";
import * as stream_data from "./stream_data";
import * as unread from "./unread";
@@ -10,19 +10,19 @@ const fetched_stream_ids = new Set();
export function all_topics_in_cache(sub) {
// Checks whether this browser's cache of contiguous messages
- // (used to locally render narrows) in message_list.all has all
+ // (used to locally render narrows) in all_messages_data has all
// messages from a given stream, and thus all historical topics
- // for it. Because message_list.all is a range, we just need to
+ // for it. Because all_messages_data is a range, we just need to
// compare it to the range of history on the stream.
// If the cache isn't initialized, it's a clear false.
- if (message_list.all === undefined || message_list.all.empty()) {
+ if (all_messages_data === undefined || all_messages_data.empty()) {
return false;
}
// If the cache doesn't have the latest messages, we can't be sure
// we have all topics.
- if (!message_list.all.data.fetch_status.has_found_newest()) {
+ if (!all_messages_data.fetch_status.has_found_newest()) {
return false;
}
@@ -37,7 +37,7 @@ export function all_topics_in_cache(sub) {
// message ID in the stream; if it's older, we're good, otherwise,
// we might be missing the oldest topics in this stream in our
// cache.
- const first_cached_message = message_list.all.first();
+ const first_cached_message = all_messages_data.first();
return first_cached_message.id <= sub.first_message_id;
}
diff --git a/static/js/ui.js b/static/js/ui.js
index c6eb2780aeb..4149a557080 100644
--- a/static/js/ui.js
+++ b/static/js/ui.js
@@ -52,7 +52,7 @@ export function reset_scrollbar(element_selector) {
}
function update_message_in_all_views(message_id, callback) {
- for (const list of [message_list.all, message_lists.home, message_list.narrowed]) {
+ for (const list of [message_lists.home, message_list.narrowed]) {
if (list === undefined) {
continue;
}
diff --git a/static/js/unread_ops.js b/static/js/unread_ops.js
index e6179104d12..e973849f3d2 100644
--- a/static/js/unread_ops.js
+++ b/static/js/unread_ops.js
@@ -33,7 +33,6 @@ export function mark_all_as_read() {
function process_newly_read_message(message, options) {
message_lists.home.show_message_as_read(message, options);
- message_list.all.show_message_as_read(message, options);
if (message_list.narrowed) {
message_list.narrowed.show_message_as_read(message, options);
}