mirror of https://github.com/zulip/zulip.git
js: Move current_msg_list, home_msg_list to ES6 module message_lists.
Signed-off-by: Anders Kaseorg <anders@zulip.com>
This commit is contained in:
parent
fbf5ff26af
commit
d43ac7357a
|
@ -104,26 +104,16 @@
|
||||||
"yoda": "error"
|
"yoda": "error"
|
||||||
},
|
},
|
||||||
"overrides": [
|
"overrides": [
|
||||||
{
|
|
||||||
"files": ["frontend_tests/node_tests/**"],
|
|
||||||
"globals": {
|
|
||||||
"current_msg_list": false,
|
|
||||||
"home_msg_list": false
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
{
|
||||||
"files": ["frontend_tests/puppeteer_lib/**", "frontend_tests/puppeteer_tests/**"],
|
"files": ["frontend_tests/puppeteer_lib/**", "frontend_tests/puppeteer_tests/**"],
|
||||||
"globals": {
|
"globals": {
|
||||||
"$": false,
|
"$": false,
|
||||||
"current_msg_list": false,
|
|
||||||
"zulip_test": false
|
"zulip_test": false
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"files": ["static/js/**"],
|
"files": ["static/js/**"],
|
||||||
"globals": {
|
"globals": {
|
||||||
"current_msg_list": true,
|
|
||||||
"home_msg_list": false,
|
|
||||||
"StripeCheckout": false,
|
"StripeCheckout": false,
|
||||||
"zxcvbn": false
|
"zxcvbn": false
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,9 +39,9 @@ mock_esm("../../static/js/common", {
|
||||||
mock_esm("../../static/js/unread_ops", {
|
mock_esm("../../static/js/unread_ops", {
|
||||||
notify_server_message_read: noop,
|
notify_server_message_read: noop,
|
||||||
});
|
});
|
||||||
set_global("current_msg_list", {
|
mock_esm("../../static/js/message_lists", {
|
||||||
can_mark_messages_read() {
|
current: {
|
||||||
return true;
|
can_mark_messages_read: () => true,
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ const compose_ui = zrequire("compose_ui");
|
||||||
const compose = zrequire("compose");
|
const compose = zrequire("compose");
|
||||||
const compose_state = zrequire("compose_state");
|
const compose_state = zrequire("compose_state");
|
||||||
const compose_actions = zrequire("compose_actions");
|
const compose_actions = zrequire("compose_actions");
|
||||||
|
const message_lists = zrequire("message_lists");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
|
|
||||||
const start = compose_actions.start;
|
const start = compose_actions.start;
|
||||||
|
@ -231,7 +232,7 @@ test("respond_to_message", (override) => {
|
||||||
type: "private",
|
type: "private",
|
||||||
sender_id: person.user_id,
|
sender_id: person.user_id,
|
||||||
};
|
};
|
||||||
override(current_msg_list, "selected_message", () => msg);
|
override(message_lists.current, "selected_message", () => msg);
|
||||||
|
|
||||||
let opts = {
|
let opts = {
|
||||||
reply_type: "personal",
|
reply_type: "personal",
|
||||||
|
@ -267,7 +268,7 @@ test("reply_with_mention", (override) => {
|
||||||
sender_full_name: "Bob Roberts",
|
sender_full_name: "Bob Roberts",
|
||||||
sender_id: 40,
|
sender_id: 40,
|
||||||
};
|
};
|
||||||
override(current_msg_list, "selected_message", () => msg);
|
override(message_lists.current, "selected_message", () => msg);
|
||||||
|
|
||||||
let syntax_to_insert;
|
let syntax_to_insert;
|
||||||
override(compose_ui, "insert_syntax_and_focus", (syntax) => {
|
override(compose_ui, "insert_syntax_and_focus", (syntax) => {
|
||||||
|
@ -314,7 +315,7 @@ test("quote_and_reply", (override) => {
|
||||||
override_private_message_recipient(override);
|
override_private_message_recipient(override);
|
||||||
|
|
||||||
let selected_message;
|
let selected_message;
|
||||||
override(current_msg_list, "selected_message", () => selected_message);
|
override(message_lists.current, "selected_message", () => selected_message);
|
||||||
|
|
||||||
let expected_replacement;
|
let expected_replacement;
|
||||||
let replaced;
|
let replaced;
|
||||||
|
@ -339,7 +340,7 @@ test("quote_and_reply", (override) => {
|
||||||
success_function = opts.success;
|
success_function = opts.success;
|
||||||
});
|
});
|
||||||
|
|
||||||
override(current_msg_list, "selected_id", () => 100);
|
override(message_lists.current, "selected_id", () => 100);
|
||||||
|
|
||||||
override(compose_ui, "insert_syntax_and_focus", (syntax) => {
|
override(compose_ui, "insert_syntax_and_focus", (syntax) => {
|
||||||
assert.equal(syntax, "[Quoting…]\n");
|
assert.equal(syntax, "[Quoting…]\n");
|
||||||
|
|
|
@ -32,6 +32,7 @@ const markdown = mock_esm("../../static/js/markdown");
|
||||||
const message_edit = mock_esm("../../static/js/message_edit");
|
const message_edit = mock_esm("../../static/js/message_edit");
|
||||||
const message_events = mock_esm("../../static/js/message_events");
|
const message_events = mock_esm("../../static/js/message_events");
|
||||||
const message_list = mock_esm("../../static/js/message_list");
|
const message_list = mock_esm("../../static/js/message_list");
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
const muting_ui = mock_esm("../../static/js/muting_ui");
|
const muting_ui = mock_esm("../../static/js/muting_ui");
|
||||||
const night_mode = mock_esm("../../static/js/night_mode");
|
const night_mode = mock_esm("../../static/js/night_mode");
|
||||||
const notifications = mock_esm("../../static/js/notifications");
|
const notifications = mock_esm("../../static/js/notifications");
|
||||||
|
@ -65,8 +66,8 @@ mock_esm("../../static/js/compose");
|
||||||
|
|
||||||
const electron_bridge = set_global("electron_bridge", {});
|
const electron_bridge = set_global("electron_bridge", {});
|
||||||
|
|
||||||
set_global("current_msg_list", {});
|
message_lists.current = {};
|
||||||
set_global("home_msg_list", {});
|
message_lists.home = {};
|
||||||
|
|
||||||
// page_params is highly coupled to dispatching now
|
// page_params is highly coupled to dispatching now
|
||||||
|
|
||||||
|
@ -629,20 +630,20 @@ run_test("update_display_settings", (override) => {
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
assert_same(page_params.left_side_userlist, true);
|
assert_same(page_params.left_side_userlist, true);
|
||||||
|
|
||||||
// We alias message_list.narrowed to current_msg_list
|
// We alias message_list.narrowed to message_lists.current
|
||||||
// to make sure we get line coverage on re-rendering
|
// to make sure we get line coverage on re-rendering
|
||||||
// the current message list. The actual code tests
|
// the current message list. The actual code tests
|
||||||
// that these two objects are equal. It is possible
|
// that these two objects are equal. It is possible
|
||||||
// we want a better strategy for that, or at least
|
// we want a better strategy for that, or at least
|
||||||
// a helper.
|
// a helper.
|
||||||
message_list.narrowed = current_msg_list;
|
message_list.narrowed = message_lists.current;
|
||||||
|
|
||||||
let called = false;
|
let called = false;
|
||||||
current_msg_list.rerender = () => {
|
message_lists.current.rerender = () => {
|
||||||
called = true;
|
called = true;
|
||||||
};
|
};
|
||||||
|
|
||||||
override(home_msg_list, "rerender", noop);
|
override(message_lists.home, "rerender", noop);
|
||||||
event = event_fixtures.update_display_settings__twenty_four_hour_time;
|
event = event_fixtures.update_display_settings__twenty_four_hour_time;
|
||||||
page_params.twenty_four_hour_time = false;
|
page_params.twenty_four_hour_time = false;
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const {strict: assert} = require("assert");
|
const {strict: assert} = require("assert");
|
||||||
|
|
||||||
const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
|
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
||||||
const {make_stub} = require("../zjsunit/stub");
|
const {make_stub} = require("../zjsunit/stub");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
const blueslip = require("../zjsunit/zblueslip");
|
const blueslip = require("../zjsunit/zblueslip");
|
||||||
|
@ -14,6 +14,7 @@ const event_fixtures = events.fixtures;
|
||||||
const test_user = events.test_user;
|
const test_user = events.test_user;
|
||||||
|
|
||||||
const compose_fade = mock_esm("../../static/js/compose_fade");
|
const compose_fade = mock_esm("../../static/js/compose_fade");
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
const narrow_state = mock_esm("../../static/js/narrow_state");
|
const narrow_state = mock_esm("../../static/js/narrow_state");
|
||||||
const overlays = mock_esm("../../static/js/overlays");
|
const overlays = mock_esm("../../static/js/overlays");
|
||||||
const settings_org = mock_esm("../../static/js/settings_org");
|
const settings_org = mock_esm("../../static/js/settings_org");
|
||||||
|
@ -21,7 +22,7 @@ const settings_streams = mock_esm("../../static/js/settings_streams");
|
||||||
const stream_events = mock_esm("../../static/js/stream_events");
|
const stream_events = mock_esm("../../static/js/stream_events");
|
||||||
const stream_list = mock_esm("../../static/js/stream_list");
|
const stream_list = mock_esm("../../static/js/stream_list");
|
||||||
const subs = mock_esm("../../static/js/subs");
|
const subs = mock_esm("../../static/js/subs");
|
||||||
set_global("current_msg_list", {});
|
message_lists.current = {};
|
||||||
|
|
||||||
const peer_data = zrequire("peer_data");
|
const peer_data = zrequire("peer_data");
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
|
@ -213,7 +214,7 @@ test("stream delete (normal)", (override) => {
|
||||||
narrow_state.is_for_stream_id = () => true;
|
narrow_state.is_for_stream_id = () => true;
|
||||||
|
|
||||||
let bookend_updates = 0;
|
let bookend_updates = 0;
|
||||||
override(current_msg_list, "update_trailing_bookend", () => {
|
override(message_lists.current, "update_trailing_bookend", () => {
|
||||||
bookend_updates += 1;
|
bookend_updates += 1;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -254,7 +255,7 @@ test("stream delete (special streams)", (override) => {
|
||||||
override(subs, "remove_stream", noop);
|
override(subs, "remove_stream", noop);
|
||||||
override(settings_org, "sync_realm_settings", noop);
|
override(settings_org, "sync_realm_settings", noop);
|
||||||
override(settings_streams, "update_default_streams_table", noop);
|
override(settings_streams, "update_default_streams_table", noop);
|
||||||
override(current_msg_list, "update_trailing_bookend", noop);
|
override(message_lists.current, "update_trailing_bookend", noop);
|
||||||
override(stream_list, "remove_sidebar_row", noop);
|
override(stream_list, "remove_sidebar_row", noop);
|
||||||
|
|
||||||
dispatch(event);
|
dispatch(event);
|
||||||
|
|
|
@ -4,12 +4,13 @@ const {strict: assert} = require("assert");
|
||||||
|
|
||||||
const MockDate = require("mockdate");
|
const MockDate = require("mockdate");
|
||||||
|
|
||||||
const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
|
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
||||||
const {make_stub} = require("../zjsunit/stub");
|
const {make_stub} = require("../zjsunit/stub");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
const {page_params} = require("../zjsunit/zpage_params");
|
const {page_params} = require("../zjsunit/zpage_params");
|
||||||
|
|
||||||
const markdown = mock_esm("../../static/js/markdown");
|
const markdown = mock_esm("../../static/js/markdown");
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
|
|
||||||
let disparities = [];
|
let disparities = [];
|
||||||
let messages_to_rerender = [];
|
let messages_to_rerender = [];
|
||||||
|
@ -30,16 +31,16 @@ mock_esm("../../static/js/message_store", {
|
||||||
update_booleans: () => {},
|
update_booleans: () => {},
|
||||||
});
|
});
|
||||||
|
|
||||||
set_global("home_msg_list", {
|
message_lists.home = {
|
||||||
view: {
|
view: {
|
||||||
rerender_messages: (msgs) => {
|
rerender_messages: (msgs) => {
|
||||||
messages_to_rerender = msgs;
|
messages_to_rerender = msgs;
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
|
||||||
mock_esm("../../static/js/message_list");
|
mock_esm("../../static/js/message_list");
|
||||||
set_global("current_msg_list", "");
|
message_lists.current = "";
|
||||||
|
|
||||||
const echo = zrequire("echo");
|
const echo = zrequire("echo");
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
|
@ -171,13 +172,13 @@ run_test("build_display_recipient", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("update_message_lists", () => {
|
run_test("update_message_lists", () => {
|
||||||
home_msg_list.view = {};
|
message_lists.home.view = {};
|
||||||
|
|
||||||
const stub = make_stub();
|
const stub = make_stub();
|
||||||
const view_stub = make_stub();
|
const view_stub = make_stub();
|
||||||
|
|
||||||
home_msg_list.change_message_id = stub.f;
|
message_lists.home.change_message_id = stub.f;
|
||||||
home_msg_list.view.change_message_id = view_stub.f;
|
message_lists.home.view.change_message_id = view_stub.f;
|
||||||
|
|
||||||
echo.update_message_lists({old_id: 401, new_id: 402});
|
echo.update_message_lists({old_id: 401, new_id: 402});
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const {strict: assert} = require("assert");
|
const {strict: assert} = require("assert");
|
||||||
|
|
||||||
const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
|
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -21,6 +21,7 @@ const {run_test} = require("../zjsunit/test");
|
||||||
// First we tell the compiler to skip certain modules and just
|
// First we tell the compiler to skip certain modules and just
|
||||||
// replace them with {}.
|
// replace them with {}.
|
||||||
const huddle_data = mock_esm("../../static/js/huddle_data");
|
const huddle_data = mock_esm("../../static/js/huddle_data");
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
const message_util = mock_esm("../../static/js/message_util");
|
const message_util = mock_esm("../../static/js/message_util");
|
||||||
const notifications = mock_esm("../../static/js/notifications");
|
const notifications = mock_esm("../../static/js/notifications");
|
||||||
const pm_list = mock_esm("../../static/js/pm_list");
|
const pm_list = mock_esm("../../static/js/pm_list");
|
||||||
|
@ -29,7 +30,7 @@ const stream_list = mock_esm("../../static/js/stream_list");
|
||||||
const unread_ops = mock_esm("../../static/js/unread_ops");
|
const unread_ops = mock_esm("../../static/js/unread_ops");
|
||||||
const unread_ui = mock_esm("../../static/js/unread_ui");
|
const unread_ui = mock_esm("../../static/js/unread_ui");
|
||||||
|
|
||||||
set_global("home_msg_list", {});
|
message_lists.home = {};
|
||||||
|
|
||||||
// And we will also test some real code, of course.
|
// And we will also test some real code, of course.
|
||||||
const message_events = zrequire("message_events");
|
const message_events = zrequire("message_events");
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const {strict: assert} = require("assert");
|
const {strict: assert} = require("assert");
|
||||||
|
|
||||||
const {mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
|
const {mock_esm, zrequire} = require("../zjsunit/namespace");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -51,20 +51,21 @@ const {run_test} = require("../zjsunit/test");
|
||||||
|
|
||||||
const channel = mock_esm("../../static/js/channel");
|
const channel = mock_esm("../../static/js/channel");
|
||||||
const message_list = mock_esm("../../static/js/message_list");
|
const message_list = mock_esm("../../static/js/message_list");
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
const message_viewport = mock_esm("../../static/js/message_viewport");
|
const message_viewport = mock_esm("../../static/js/message_viewport");
|
||||||
const notifications = mock_esm("../../static/js/notifications");
|
const notifications = mock_esm("../../static/js/notifications");
|
||||||
const overlays = mock_esm("../../static/js/overlays");
|
const overlays = mock_esm("../../static/js/overlays");
|
||||||
const unread_ui = mock_esm("../../static/js/unread_ui");
|
const unread_ui = mock_esm("../../static/js/unread_ui");
|
||||||
|
|
||||||
|
message_lists.current = {};
|
||||||
|
message_lists.home = {};
|
||||||
|
|
||||||
const message_store = zrequire("message_store");
|
const message_store = zrequire("message_store");
|
||||||
const recent_topics = zrequire("recent_topics");
|
const recent_topics = zrequire("recent_topics");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
const unread = zrequire("unread");
|
const unread = zrequire("unread");
|
||||||
const unread_ops = zrequire("unread_ops");
|
const unread_ops = zrequire("unread_ops");
|
||||||
|
|
||||||
const current_msg_list = set_global("current_msg_list", {});
|
|
||||||
const home_msg_list = set_global("home_msg_list", {});
|
|
||||||
|
|
||||||
const denmark_stream = {
|
const denmark_stream = {
|
||||||
color: "blue",
|
color: "blue",
|
||||||
name: "Denmark",
|
name: "Denmark",
|
||||||
|
@ -104,14 +105,14 @@ run_test("unread_ops", (override) => {
|
||||||
// Make us not be in a narrow (somewhat hackily).
|
// Make us not be in a narrow (somewhat hackily).
|
||||||
message_list.narrowed = undefined;
|
message_list.narrowed = undefined;
|
||||||
|
|
||||||
// Set current_msg_list containing messages that can be marked read
|
// Set message_lists.current containing messages that can be marked read
|
||||||
override(current_msg_list, "all_messages", () => test_messages);
|
override(message_lists.current, "all_messages", () => test_messages);
|
||||||
|
|
||||||
// Ignore these interactions for now:
|
// Ignore these interactions for now:
|
||||||
message_list.all = {
|
message_list.all = {
|
||||||
show_message_as_read() {},
|
show_message_as_read() {},
|
||||||
};
|
};
|
||||||
override(home_msg_list, "show_message_as_read", () => {});
|
override(message_lists.home, "show_message_as_read", () => {});
|
||||||
override(notifications, "close_notification", () => {});
|
override(notifications, "close_notification", () => {});
|
||||||
override(unread_ui, "update_unread_counts", () => {});
|
override(unread_ui, "update_unread_counts", () => {});
|
||||||
|
|
||||||
|
@ -129,7 +130,7 @@ run_test("unread_ops", (override) => {
|
||||||
// Set up an override to point to the above var, so we can
|
// Set up an override to point to the above var, so we can
|
||||||
// toggle it easily from within the test (and avoid complicated
|
// toggle it easily from within the test (and avoid complicated
|
||||||
// data setup).
|
// data setup).
|
||||||
override(current_msg_list, "can_mark_messages_read", () => can_mark_messages_read);
|
override(message_lists.current, "can_mark_messages_read", () => can_mark_messages_read);
|
||||||
|
|
||||||
// First, test for a message list that cannot read messages.
|
// First, test for a message list that cannot read messages.
|
||||||
can_mark_messages_read = false;
|
can_mark_messages_read = false;
|
||||||
|
|
|
@ -54,6 +54,7 @@ const gear_menu = mock_esm("../../static/js/gear_menu", {
|
||||||
const lightbox = mock_esm("../../static/js/lightbox");
|
const lightbox = mock_esm("../../static/js/lightbox");
|
||||||
const list_util = mock_esm("../../static/js/list_util");
|
const list_util = mock_esm("../../static/js/list_util");
|
||||||
const message_edit = mock_esm("../../static/js/message_edit");
|
const message_edit = mock_esm("../../static/js/message_edit");
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
const muting_ui = mock_esm("../../static/js/muting_ui");
|
const muting_ui = mock_esm("../../static/js/muting_ui");
|
||||||
const narrow = mock_esm("../../static/js/narrow");
|
const narrow = mock_esm("../../static/js/narrow");
|
||||||
const navigate = mock_esm("../../static/js/navigate");
|
const navigate = mock_esm("../../static/js/navigate");
|
||||||
|
@ -95,7 +96,7 @@ mock_esm("../../static/js/recent_topics", {
|
||||||
is_visible: () => false,
|
is_visible: () => false,
|
||||||
});
|
});
|
||||||
|
|
||||||
set_global("current_msg_list", {
|
message_lists.current = {
|
||||||
empty() {
|
empty() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
|
@ -112,7 +113,7 @@ set_global("current_msg_list", {
|
||||||
get_row() {
|
get_row() {
|
||||||
return 101;
|
return 101;
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
|
|
||||||
const emoji_codes = zrequire("../generated/emoji/emoji_codes.json");
|
const emoji_codes = zrequire("../generated/emoji/emoji_codes.json");
|
||||||
const emoji = zrequire("../shared/js/emoji");
|
const emoji = zrequire("../shared/js/emoji");
|
||||||
|
@ -331,7 +332,7 @@ run_test("misc", () => {
|
||||||
|
|
||||||
// Check that they do nothing without a selected message
|
// Check that they do nothing without a selected message
|
||||||
with_overrides((override) => {
|
with_overrides((override) => {
|
||||||
override(current_msg_list, "empty", () => true);
|
override(message_lists.current, "empty", () => true);
|
||||||
assert_unmapped(message_view_only_keys);
|
assert_unmapped(message_view_only_keys);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -440,7 +441,7 @@ run_test("motion_keys", () => {
|
||||||
}
|
}
|
||||||
|
|
||||||
list_util.inside_list = () => false;
|
list_util.inside_list = () => false;
|
||||||
current_msg_list.empty = () => true;
|
message_lists.current.empty = () => true;
|
||||||
overlays.settings_open = () => false;
|
overlays.settings_open = () => false;
|
||||||
overlays.streams_open = () => false;
|
overlays.streams_open = () => false;
|
||||||
overlays.lightbox_open = () => false;
|
overlays.lightbox_open = () => false;
|
||||||
|
@ -458,7 +459,7 @@ run_test("motion_keys", () => {
|
||||||
assert_mapping("down_arrow", list_util, "go_down");
|
assert_mapping("down_arrow", list_util, "go_down");
|
||||||
list_util.inside_list = () => false;
|
list_util.inside_list = () => false;
|
||||||
|
|
||||||
current_msg_list.empty = () => false;
|
message_lists.current.empty = () => false;
|
||||||
assert_mapping("down_arrow", navigate, "down");
|
assert_mapping("down_arrow", navigate, "down");
|
||||||
assert_mapping("end", navigate, "to_end");
|
assert_mapping("end", navigate, "to_end");
|
||||||
assert_mapping("home", navigate, "to_home");
|
assert_mapping("home", navigate, "to_home");
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const {strict: assert} = require("assert");
|
const {strict: assert} = require("assert");
|
||||||
|
|
||||||
const {mock_cjs, mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
|
const {mock_cjs, mock_esm, zrequire} = require("../zjsunit/namespace");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
const $ = require("../zjsunit/zjquery");
|
const $ = require("../zjsunit/zjquery");
|
||||||
const {page_params} = require("../zjsunit/zpage_params");
|
const {page_params} = require("../zjsunit/zpage_params");
|
||||||
|
@ -11,11 +11,12 @@ mock_cjs("jquery", $);
|
||||||
const condense = mock_esm("../../static/js/condense");
|
const condense = mock_esm("../../static/js/condense");
|
||||||
const message_edit = mock_esm("../../static/js/message_edit");
|
const message_edit = mock_esm("../../static/js/message_edit");
|
||||||
const message_list = mock_esm("../../static/js/message_list");
|
const message_list = mock_esm("../../static/js/message_list");
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
const notifications = mock_esm("../../static/js/notifications");
|
const notifications = mock_esm("../../static/js/notifications");
|
||||||
const pm_list = mock_esm("../../static/js/pm_list");
|
const pm_list = mock_esm("../../static/js/pm_list");
|
||||||
const stream_list = mock_esm("../../static/js/stream_list");
|
const stream_list = mock_esm("../../static/js/stream_list");
|
||||||
const unread_ui = mock_esm("../../static/js/unread_ui");
|
const unread_ui = mock_esm("../../static/js/unread_ui");
|
||||||
set_global("current_msg_list", {});
|
message_lists.current = {};
|
||||||
|
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
const message_events = zrequire("message_events");
|
const message_events = zrequire("message_events");
|
||||||
|
@ -90,15 +91,15 @@ run_test("update_messages", () => {
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
|
|
||||||
current_msg_list.get_row = (message_id) => {
|
message_lists.current.get_row = (message_id) => {
|
||||||
assert.equal(message_id, 111);
|
assert.equal(message_id, 111);
|
||||||
return ["row-stub"];
|
return ["row-stub"];
|
||||||
};
|
};
|
||||||
current_msg_list.view = {};
|
message_lists.current.view = {};
|
||||||
|
|
||||||
let rendered_mgs;
|
let rendered_mgs;
|
||||||
|
|
||||||
current_msg_list.view.rerender_messages = (msgs_to_rerender, message_content_edited) => {
|
message_lists.current.view.rerender_messages = (msgs_to_rerender, message_content_edited) => {
|
||||||
rendered_mgs = msgs_to_rerender;
|
rendered_mgs = msgs_to_rerender;
|
||||||
assert.equal(message_content_edited, true);
|
assert.equal(message_content_edited, true);
|
||||||
};
|
};
|
||||||
|
|
|
@ -30,6 +30,7 @@ mock_esm("../../static/js/ui_report", {
|
||||||
|
|
||||||
const channel = mock_esm("../../static/js/channel");
|
const channel = mock_esm("../../static/js/channel");
|
||||||
const message_helper = mock_esm("../../static/js/message_helper");
|
const message_helper = mock_esm("../../static/js/message_helper");
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
const message_store = mock_esm("../../static/js/message_store");
|
const message_store = mock_esm("../../static/js/message_store");
|
||||||
const message_util = mock_esm("../../static/js/message_util");
|
const message_util = mock_esm("../../static/js/message_util");
|
||||||
const pm_list = mock_esm("../../static/js/pm_list");
|
const pm_list = mock_esm("../../static/js/pm_list");
|
||||||
|
@ -80,10 +81,10 @@ function make_all_list() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function reset_lists() {
|
function reset_lists() {
|
||||||
set_global("home_msg_list", make_home_msg_list());
|
message_lists.home = make_home_msg_list();
|
||||||
set_global("current_msg_list", home_msg_list);
|
message_lists.current = message_lists.home;
|
||||||
message_list.__Rewire__("all", make_all_list());
|
message_list.__Rewire__("all", make_all_list());
|
||||||
stub_message_view(home_msg_list);
|
stub_message_view(message_lists.home);
|
||||||
stub_message_view(message_list.all);
|
stub_message_view(message_list.all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -313,7 +314,7 @@ function simulate_narrow() {
|
||||||
table_name: "zfilt",
|
table_name: "zfilt",
|
||||||
filter,
|
filter,
|
||||||
});
|
});
|
||||||
set_global("current_msg_list", msg_list);
|
message_lists.current = msg_list;
|
||||||
|
|
||||||
return msg_list;
|
return msg_list;
|
||||||
}
|
}
|
||||||
|
@ -424,7 +425,7 @@ run_test("loading_newer", () => {
|
||||||
|
|
||||||
(function test_home() {
|
(function test_home() {
|
||||||
reset_lists();
|
reset_lists();
|
||||||
const msg_list = home_msg_list;
|
const msg_list = message_lists.home;
|
||||||
|
|
||||||
const data = [
|
const data = [
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const {strict: assert} = require("assert");
|
const {strict: assert} = require("assert");
|
||||||
|
|
||||||
const {mock_esm, set_global, with_field, zrequire} = require("../zjsunit/namespace");
|
const {mock_esm, with_field, zrequire} = require("../zjsunit/namespace");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
|
|
||||||
const channel = mock_esm("../../static/js/channel");
|
const channel = mock_esm("../../static/js/channel");
|
||||||
|
@ -20,10 +20,6 @@ run_test("starred", (override) => {
|
||||||
const message = {
|
const message = {
|
||||||
id: 50,
|
id: 50,
|
||||||
};
|
};
|
||||||
set_global("current_msg_list", {
|
|
||||||
all_messages: () => [message],
|
|
||||||
is_search: () => false,
|
|
||||||
});
|
|
||||||
let ui_updated;
|
let ui_updated;
|
||||||
|
|
||||||
ui.update_starred_view = () => {
|
ui.update_starred_view = () => {
|
||||||
|
|
|
@ -13,7 +13,9 @@ set_global("document", "document-stub");
|
||||||
const noop = () => {};
|
const noop = () => {};
|
||||||
|
|
||||||
page_params.twenty_four_hour_time = false;
|
page_params.twenty_four_hour_time = false;
|
||||||
set_global("home_msg_list", "stub");
|
|
||||||
|
mock_esm("../../static/js/message_lists", {home: "stub"});
|
||||||
|
|
||||||
// timerender calls setInterval when imported
|
// timerender calls setInterval when imported
|
||||||
mock_esm("../../static/js/timerender", {
|
mock_esm("../../static/js/timerender", {
|
||||||
render_date(time1, time2) {
|
render_date(time1, time2) {
|
||||||
|
|
|
@ -21,6 +21,13 @@ const message_list = mock_esm("../../static/js/message_list", {
|
||||||
message_list.narrowed = value;
|
message_list.narrowed = value;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists", {
|
||||||
|
home: {},
|
||||||
|
current: {},
|
||||||
|
set_current(msg_list) {
|
||||||
|
message_lists.current = msg_list;
|
||||||
|
},
|
||||||
|
});
|
||||||
const message_scroll = mock_esm("../../static/js/message_scroll");
|
const message_scroll = mock_esm("../../static/js/message_scroll");
|
||||||
const message_view_header = mock_esm("../../static/js/message_view_header");
|
const message_view_header = mock_esm("../../static/js/message_view_header");
|
||||||
const notifications = mock_esm("../../static/js/notifications");
|
const notifications = mock_esm("../../static/js/notifications");
|
||||||
|
@ -34,8 +41,6 @@ mock_esm("../../static/js/recent_topics", {
|
||||||
hide: () => {},
|
hide: () => {},
|
||||||
is_visible: () => {},
|
is_visible: () => {},
|
||||||
});
|
});
|
||||||
set_global("current_msg_list", {});
|
|
||||||
set_global("home_msg_list", {});
|
|
||||||
|
|
||||||
//
|
//
|
||||||
// We have strange hacks in narrow.activate to sleep 0
|
// We have strange hacks in narrow.activate to sleep 0
|
||||||
|
@ -151,8 +156,8 @@ run_test("basics", () => {
|
||||||
offset: () => ({top: 25}),
|
offset: () => ({top: 25}),
|
||||||
};
|
};
|
||||||
|
|
||||||
current_msg_list.selected_id = () => -1;
|
message_lists.current.selected_id = () => -1;
|
||||||
current_msg_list.get_row = () => row;
|
message_lists.current.get_row = () => row;
|
||||||
|
|
||||||
message_list.all = {
|
message_list.all = {
|
||||||
all_messages: () => messages,
|
all_messages: () => messages,
|
||||||
|
@ -206,8 +211,8 @@ run_test("basics", () => {
|
||||||
[message_view_header, "initialize"],
|
[message_view_header, "initialize"],
|
||||||
]);
|
]);
|
||||||
|
|
||||||
current_msg_list.selected_id = () => -1;
|
message_lists.current.selected_id = () => -1;
|
||||||
current_msg_list.get_row = () => row;
|
message_lists.current.get_row = () => row;
|
||||||
util.sorted_ids = () => [];
|
util.sorted_ids = () => [];
|
||||||
|
|
||||||
narrow.activate([{operator: "is", operand: "private"}], {
|
narrow.activate([{operator: "is", operand: "private"}], {
|
||||||
|
|
|
@ -17,6 +17,9 @@ const stream_data = mock_esm("../../static/js/stream_data");
|
||||||
mock_esm("../../static/js/emoji_picker", {
|
mock_esm("../../static/js/emoji_picker", {
|
||||||
hide_emoji_popover: noop,
|
hide_emoji_popover: noop,
|
||||||
});
|
});
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists", {
|
||||||
|
current: {},
|
||||||
|
});
|
||||||
mock_esm("../../static/js/message_viewport", {
|
mock_esm("../../static/js/message_viewport", {
|
||||||
height: () => 500,
|
height: () => 500,
|
||||||
});
|
});
|
||||||
|
@ -28,7 +31,6 @@ mock_esm("../../static/js/stream_popover", {
|
||||||
hide_streamlist_sidebar: noop,
|
hide_streamlist_sidebar: noop,
|
||||||
});
|
});
|
||||||
|
|
||||||
set_global("current_msg_list", {});
|
|
||||||
page_params.is_admin = false;
|
page_params.is_admin = false;
|
||||||
page_params.realm_email_address_visibility = 3;
|
page_params.realm_email_address_visibility = 3;
|
||||||
page_params.custom_profile_fields = [];
|
page_params.custom_profile_fields = [];
|
||||||
|
@ -119,12 +121,12 @@ test_ui("sender_hover", (override) => {
|
||||||
|
|
||||||
rows.id = () => message.id;
|
rows.id = () => message.id;
|
||||||
|
|
||||||
current_msg_list.get = (msg_id) => {
|
message_lists.current.get = (msg_id) => {
|
||||||
assert.equal(msg_id, message.id);
|
assert.equal(msg_id, message.id);
|
||||||
return message;
|
return message;
|
||||||
};
|
};
|
||||||
|
|
||||||
current_msg_list.select_id = (msg_id) => {
|
message_lists.current.select_id = (msg_id) => {
|
||||||
assert.equal(msg_id, message.id);
|
assert.equal(msg_id, message.id);
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -218,7 +220,7 @@ test_ui("actions_popover", (override) => {
|
||||||
stream_id: 123,
|
stream_id: 123,
|
||||||
};
|
};
|
||||||
|
|
||||||
current_msg_list.get = (msg_id) => {
|
message_lists.current.get = (msg_id) => {
|
||||||
assert.equal(msg_id, message.id);
|
assert.equal(msg_id, message.id);
|
||||||
return message;
|
return message;
|
||||||
};
|
};
|
||||||
|
|
|
@ -44,9 +44,10 @@ const channel = mock_esm("../../static/js/channel");
|
||||||
const emoji_picker = mock_esm("../../static/js/emoji_picker", {
|
const emoji_picker = mock_esm("../../static/js/emoji_picker", {
|
||||||
hide_emoji_popover() {},
|
hide_emoji_popover() {},
|
||||||
});
|
});
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
const message_store = mock_esm("../../static/js/message_store");
|
const message_store = mock_esm("../../static/js/message_store");
|
||||||
|
|
||||||
set_global("current_msg_list", {
|
message_lists.current = {
|
||||||
selected_message() {
|
selected_message() {
|
||||||
return {sent_by_me: true};
|
return {sent_by_me: true};
|
||||||
},
|
},
|
||||||
|
@ -56,7 +57,7 @@ set_global("current_msg_list", {
|
||||||
selected_id() {
|
selected_id() {
|
||||||
return 42;
|
return 42;
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
set_global("document", "document-stub");
|
set_global("document", "document-stub");
|
||||||
page_params.user_id = alice_user_id;
|
page_params.user_id = alice_user_id;
|
||||||
|
|
||||||
|
@ -117,7 +118,7 @@ people.add_active_user(cali);
|
||||||
people.add_active_user(alexus);
|
people.add_active_user(alexus);
|
||||||
|
|
||||||
run_test("open_reactions_popover (sent by me)", () => {
|
run_test("open_reactions_popover (sent by me)", () => {
|
||||||
current_msg_list.selected_message = () => ({sent_by_me: true});
|
message_lists.current.selected_message = () => ({sent_by_me: true});
|
||||||
$(".selected-row").set_find_results(".actions_hover", ["action-stub"]);
|
$(".selected-row").set_find_results(".actions_hover", ["action-stub"]);
|
||||||
|
|
||||||
let called = false;
|
let called = false;
|
||||||
|
@ -132,7 +133,7 @@ run_test("open_reactions_popover (sent by me)", () => {
|
||||||
});
|
});
|
||||||
|
|
||||||
run_test("open_reactions_popover (not sent by me)", () => {
|
run_test("open_reactions_popover (not sent by me)", () => {
|
||||||
current_msg_list.selected_message = () => ({sent_by_me: false});
|
message_lists.current.selected_message = () => ({sent_by_me: false});
|
||||||
$(".selected-row").set_find_results(".reaction_button", ["reaction-stub"]);
|
$(".selected-row").set_find_results(".reaction_button", ["reaction-stub"]);
|
||||||
|
|
||||||
let called = false;
|
let called = false;
|
||||||
|
|
|
@ -21,17 +21,18 @@ set_global("addEventListener", noop);
|
||||||
|
|
||||||
mock_cjs("jquery", $);
|
mock_cjs("jquery", $);
|
||||||
const channel = mock_esm("../../static/js/channel");
|
const channel = mock_esm("../../static/js/channel");
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists");
|
||||||
mock_esm("../../static/js/reload_state", {
|
mock_esm("../../static/js/reload_state", {
|
||||||
is_in_progress() {
|
is_in_progress() {
|
||||||
return false;
|
return false;
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
set_global("home_msg_list", {
|
message_lists.home = {
|
||||||
select_id: noop,
|
select_id: noop,
|
||||||
selected_id() {
|
selected_id() {
|
||||||
return 1;
|
return 1;
|
||||||
},
|
},
|
||||||
});
|
};
|
||||||
page_params.test_suite = false;
|
page_params.test_suite = false;
|
||||||
|
|
||||||
// we also directly write to pointer
|
// we also directly write to pointer
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
|
|
||||||
const {strict: assert} = require("assert");
|
const {strict: assert} = require("assert");
|
||||||
|
|
||||||
const {mock_cjs, mock_esm, set_global, zrequire} = require("../zjsunit/namespace");
|
const {mock_cjs, mock_esm, zrequire} = require("../zjsunit/namespace");
|
||||||
const {make_stub} = require("../zjsunit/stub");
|
const {make_stub} = require("../zjsunit/stub");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
const blueslip = require("../zjsunit/zblueslip");
|
const blueslip = require("../zjsunit/zblueslip");
|
||||||
|
@ -27,13 +27,15 @@ mock_esm("../../static/js/message_list", {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists", {
|
||||||
|
current: {},
|
||||||
|
});
|
||||||
mock_esm("../../static/js/recent_topics", {
|
mock_esm("../../static/js/recent_topics", {
|
||||||
complete_rerender: () => {},
|
complete_rerender: () => {},
|
||||||
});
|
});
|
||||||
mock_esm("../../static/js/settings_notifications", {
|
mock_esm("../../static/js/settings_notifications", {
|
||||||
update_page: () => {},
|
update_page: () => {},
|
||||||
});
|
});
|
||||||
set_global("current_msg_list", {});
|
|
||||||
|
|
||||||
mock_esm("../../static/js/overlays", {streams_open: () => true});
|
mock_esm("../../static/js/overlays", {streams_open: () => true});
|
||||||
|
|
||||||
|
@ -280,7 +282,7 @@ test("marked_subscribed (normal)", (override) => {
|
||||||
override(stream_list, "add_sidebar_row", stream_list_stub.f);
|
override(stream_list, "add_sidebar_row", stream_list_stub.f);
|
||||||
override(message_util, "do_unread_count_updates", message_util_stub.f);
|
override(message_util, "do_unread_count_updates", message_util_stub.f);
|
||||||
override(message_view_header, "render_title_area", message_view_header_stub.f);
|
override(message_view_header, "render_title_area", message_view_header_stub.f);
|
||||||
override(current_msg_list, "update_trailing_bookend", () => {
|
override(message_lists.current, "update_trailing_bookend", () => {
|
||||||
list_updated = true;
|
list_updated = true;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -384,7 +386,7 @@ test("mark_unsubscribed (render_title_area)", (override) => {
|
||||||
override(message_view_header, "render_title_area", message_view_header_stub.f);
|
override(message_view_header, "render_title_area", message_view_header_stub.f);
|
||||||
override(stream_data, "unsubscribe_myself", noop);
|
override(stream_data, "unsubscribe_myself", noop);
|
||||||
override(subs, "update_settings_for_unsubscribed", noop);
|
override(subs, "update_settings_for_unsubscribed", noop);
|
||||||
override(current_msg_list, "update_trailing_bookend", noop);
|
override(message_lists.current, "update_trailing_bookend", noop);
|
||||||
override(stream_list, "remove_sidebar_row", noop);
|
override(stream_list, "remove_sidebar_row", noop);
|
||||||
|
|
||||||
stream_events.mark_unsubscribed(sub);
|
stream_events.mark_unsubscribed(sub);
|
||||||
|
|
|
@ -4,19 +4,15 @@ const {strict: assert} = require("assert");
|
||||||
|
|
||||||
const _ = require("lodash");
|
const _ = require("lodash");
|
||||||
|
|
||||||
const {set_global, zrequire} = require("../zjsunit/namespace");
|
const {zrequire} = require("../zjsunit/namespace");
|
||||||
const {run_test} = require("../zjsunit/test");
|
const {run_test} = require("../zjsunit/test");
|
||||||
const {page_params} = require("../zjsunit/zpage_params");
|
const {page_params} = require("../zjsunit/zpage_params");
|
||||||
|
|
||||||
page_params.realm_push_notifications_enabled = false;
|
page_params.realm_push_notifications_enabled = false;
|
||||||
|
|
||||||
const muting = zrequire("muting");
|
|
||||||
|
|
||||||
set_global("current_msg_list", {});
|
|
||||||
set_global("home_msg_list", {});
|
|
||||||
|
|
||||||
const {FoldDict} = zrequire("fold_dict");
|
const {FoldDict} = zrequire("fold_dict");
|
||||||
const message_store = zrequire("message_store");
|
const message_store = zrequire("message_store");
|
||||||
|
const muting = zrequire("muting");
|
||||||
const people = zrequire("people");
|
const people = zrequire("people");
|
||||||
const stream_data = zrequire("stream_data");
|
const stream_data = zrequire("stream_data");
|
||||||
const unread = zrequire("unread");
|
const unread = zrequire("unread");
|
||||||
|
|
|
@ -56,10 +56,10 @@ const fake_poll_widget = {
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const message_lists = mock_esm("../../static/js/message_lists", {current: {}});
|
||||||
const narrow_state = mock_esm("../../static/js/narrow_state");
|
const narrow_state = mock_esm("../../static/js/narrow_state");
|
||||||
mock_esm("../../static/js/poll_widget", fake_poll_widget);
|
mock_esm("../../static/js/poll_widget", fake_poll_widget);
|
||||||
|
|
||||||
const current_msg_list = set_global("current_msg_list", {});
|
|
||||||
set_global("document", "document-stub");
|
set_global("document", "document-stub");
|
||||||
|
|
||||||
const widgetize = zrequire("widgetize");
|
const widgetize = zrequire("widgetize");
|
||||||
|
@ -184,11 +184,11 @@ test("activate", (override) => {
|
||||||
assert(!is_event_handled);
|
assert(!is_event_handled);
|
||||||
|
|
||||||
/* Test narrow change message update */
|
/* Test narrow change message update */
|
||||||
override(current_msg_list, "get", (idx) => {
|
override(message_lists.current, "get", (idx) => {
|
||||||
assert.equal(idx, 2001);
|
assert.equal(idx, 2001);
|
||||||
return {};
|
return {};
|
||||||
});
|
});
|
||||||
override(current_msg_list, "get_row", (idx) => {
|
override(message_lists.current, "get_row", (idx) => {
|
||||||
assert.equal(idx, 2001);
|
assert.equal(idx, 2001);
|
||||||
return row;
|
return row;
|
||||||
});
|
});
|
||||||
|
|
|
@ -312,7 +312,7 @@ class CommonUtils {
|
||||||
- does it look to have been
|
- does it look to have been
|
||||||
re-rendered based on server info?
|
re-rendered based on server info?
|
||||||
*/
|
*/
|
||||||
const last_msg = current_msg_list.last();
|
const last_msg = zulip_test.current_msg_list.last();
|
||||||
if (last_msg === undefined) {
|
if (last_msg === undefined) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,6 @@ import "../reload";
|
||||||
import "../hotkey";
|
import "../hotkey";
|
||||||
import "../notifications";
|
import "../notifications";
|
||||||
import "../server_events";
|
import "../server_events";
|
||||||
import "../zulip";
|
|
||||||
import "../templates";
|
import "../templates";
|
||||||
import "../settings";
|
import "../settings";
|
||||||
import "../ui_init";
|
import "../ui_init";
|
||||||
|
|
|
@ -22,6 +22,7 @@ import {i18n} from "./i18n";
|
||||||
import * as message_edit from "./message_edit";
|
import * as message_edit from "./message_edit";
|
||||||
import * as message_edit_history from "./message_edit_history";
|
import * as message_edit_history from "./message_edit_history";
|
||||||
import * as message_flags from "./message_flags";
|
import * as message_flags from "./message_flags";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as muting_ui from "./muting_ui";
|
import * as muting_ui from "./muting_ui";
|
||||||
import * as narrow from "./narrow";
|
import * as narrow from "./narrow";
|
||||||
|
@ -69,7 +70,7 @@ export function initialize() {
|
||||||
if (!id) {
|
if (!id) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
current_msg_list.select_id(id);
|
message_lists.current.select_id(id);
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
// The algorithm to trigger long tap is that first, we check
|
// The algorithm to trigger long tap is that first, we check
|
||||||
// whether the message is still touched after MS_DELAY ms and
|
// whether the message is still touched after MS_DELAY ms and
|
||||||
|
@ -168,7 +169,7 @@ export function initialize() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_msg_list.select_id(id);
|
message_lists.current.select_id(id);
|
||||||
compose_actions.respond_to_message({trigger: "message click"});
|
compose_actions.respond_to_message({trigger: "message click"});
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
popovers.hide_all();
|
popovers.hide_all();
|
||||||
|
@ -230,8 +231,8 @@ export function initialize() {
|
||||||
$("body").on("click", ".message_edit_notice", (e) => {
|
$("body").on("click", ".message_edit_notice", (e) => {
|
||||||
popovers.hide_all();
|
popovers.hide_all();
|
||||||
const message_id = rows.id($(e.currentTarget).closest(".message_row"));
|
const message_id = rows.id($(e.currentTarget).closest(".message_row"));
|
||||||
const row = current_msg_list.get_row(message_id);
|
const row = message_lists.current.get_row(message_id);
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
const message_history_cancel_btn = $("#message-history-cancel");
|
const message_history_cancel_btn = $("#message-history-cancel");
|
||||||
|
|
||||||
if (page_params.realm_allow_edit_history) {
|
if (page_params.realm_allow_edit_history) {
|
||||||
|
@ -303,8 +304,8 @@ export function initialize() {
|
||||||
// MESSAGE EDITING
|
// MESSAGE EDITING
|
||||||
|
|
||||||
$("body").on("click", ".edit_content_button", function (e) {
|
$("body").on("click", ".edit_content_button", function (e) {
|
||||||
const row = current_msg_list.get_row(rows.id($(this).closest(".message_row")));
|
const row = message_lists.current.get_row(rows.id($(this).closest(".message_row")));
|
||||||
current_msg_list.select_id(rows.id(row));
|
message_lists.current.select_id(rows.id(row));
|
||||||
message_edit.start(row);
|
message_edit.start(row);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
popovers.hide_all();
|
popovers.hide_all();
|
||||||
|
@ -499,8 +500,8 @@ export function initialize() {
|
||||||
const group = rows.get_closest_group(narrow_link_elem);
|
const group = rows.get_closest_group(narrow_link_elem);
|
||||||
const msg_id = rows.id_for_recipient_row(group);
|
const msg_id = rows.id_for_recipient_row(group);
|
||||||
|
|
||||||
const nearest = current_msg_list.get(msg_id);
|
const nearest = message_lists.current.get(msg_id);
|
||||||
const selected = current_msg_list.selected_message();
|
const selected = message_lists.current.selected_message();
|
||||||
if (util.same_recipient(nearest, selected)) {
|
if (util.same_recipient(nearest, selected)) {
|
||||||
return selected.id;
|
return selected.id;
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import * as compose_ui from "./compose_ui";
|
||||||
import * as drafts from "./drafts";
|
import * as drafts from "./drafts";
|
||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import {i18n} from "./i18n";
|
import {i18n} from "./i18n";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as notifications from "./notifications";
|
import * as notifications from "./notifications";
|
||||||
|
@ -145,12 +146,12 @@ export function complete_starting_tasks(msg_type, opts) {
|
||||||
export function maybe_scroll_up_selected_message() {
|
export function maybe_scroll_up_selected_message() {
|
||||||
// If the compose box is obscuring the currently selected message,
|
// If the compose box is obscuring the currently selected message,
|
||||||
// scroll up until the message is no longer occluded.
|
// scroll up until the message is no longer occluded.
|
||||||
if (current_msg_list.selected_id() === -1) {
|
if (message_lists.current.selected_id() === -1) {
|
||||||
// If there's no selected message, there's no need to
|
// If there's no selected message, there's no need to
|
||||||
// scroll the compose box to avoid it.
|
// scroll the compose box to avoid it.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const selected_row = current_msg_list.selected_row();
|
const selected_row = message_lists.current.selected_row();
|
||||||
|
|
||||||
if (selected_row.height() > message_viewport.height() - 100) {
|
if (selected_row.height() > message_viewport.height() - 100) {
|
||||||
// For very tall messages whose height is close to the entire
|
// For very tall messages whose height is close to the entire
|
||||||
|
@ -298,7 +299,7 @@ export function respond_to_message(opts) {
|
||||||
// in-progress composition, snapshot it.
|
// in-progress composition, snapshot it.
|
||||||
drafts.update_draft();
|
drafts.update_draft();
|
||||||
|
|
||||||
const message = current_msg_list.selected_message();
|
const message = message_lists.current.selected_message();
|
||||||
|
|
||||||
if (message === undefined) {
|
if (message === undefined) {
|
||||||
// empty narrow implementation
|
// empty narrow implementation
|
||||||
|
@ -332,7 +333,7 @@ export function respond_to_message(opts) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_msg_list.can_mark_messages_read()) {
|
if (message_lists.current.can_mark_messages_read()) {
|
||||||
unread_ops.notify_server_message_read(message);
|
unread_ops.notify_server_message_read(message);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -373,7 +374,7 @@ export function respond_to_message(opts) {
|
||||||
|
|
||||||
export function reply_with_mention(opts) {
|
export function reply_with_mention(opts) {
|
||||||
respond_to_message(opts);
|
respond_to_message(opts);
|
||||||
const message = current_msg_list.selected_message();
|
const message = message_lists.current.selected_message();
|
||||||
const mention = people.get_mention_syntax(message.sender_full_name, message.sender_id);
|
const mention = people.get_mention_syntax(message.sender_full_name, message.sender_id);
|
||||||
compose_ui.insert_syntax_and_focus(mention);
|
compose_ui.insert_syntax_and_focus(mention);
|
||||||
}
|
}
|
||||||
|
@ -425,8 +426,8 @@ export function on_topic_narrow() {
|
||||||
|
|
||||||
export function quote_and_reply(opts) {
|
export function quote_and_reply(opts) {
|
||||||
const textarea = $("#compose-textarea");
|
const textarea = $("#compose-textarea");
|
||||||
const message_id = current_msg_list.selected_id();
|
const message_id = message_lists.current.selected_id();
|
||||||
const message = current_msg_list.selected_message();
|
const message = message_lists.current.selected_message();
|
||||||
|
|
||||||
if (compose_state.has_message_content()) {
|
if (compose_state.has_message_content()) {
|
||||||
// The user already started typing a message,
|
// The user already started typing a message,
|
||||||
|
|
|
@ -6,6 +6,7 @@ import * as compose_fade_helper from "./compose_fade_helper";
|
||||||
import * as compose_fade_users from "./compose_fade_users";
|
import * as compose_fade_users from "./compose_fade_users";
|
||||||
import * as compose_state from "./compose_state";
|
import * as compose_state from "./compose_state";
|
||||||
import * as floating_recipient_bar from "./floating_recipient_bar";
|
import * as floating_recipient_bar from "./floating_recipient_bar";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
import * as rows from "./rows";
|
import * as rows from "./rows";
|
||||||
|
@ -45,7 +46,7 @@ export function set_focused_recipient(msg_type) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function display_messages_normally() {
|
function display_messages_normally() {
|
||||||
const table = rows.get_table(current_msg_list.table_name);
|
const table = rows.get_table(message_lists.current.table_name);
|
||||||
table.find(".recipient_row").removeClass("message-fade");
|
table.find(".recipient_row").removeClass("message-fade");
|
||||||
|
|
||||||
normal_display = true;
|
normal_display = true;
|
||||||
|
@ -72,7 +73,7 @@ function fade_messages() {
|
||||||
// Update the visible messages first, before the compose box opens
|
// Update the visible messages first, before the compose box opens
|
||||||
for (i = 0; i < visible_groups.length; i += 1) {
|
for (i = 0; i < visible_groups.length; i += 1) {
|
||||||
first_row = rows.first_message_in_group(visible_groups[i]);
|
first_row = rows.first_message_in_group(visible_groups[i]);
|
||||||
first_message = current_msg_list.get(rows.id(first_row));
|
first_message = message_lists.current.get(rows.id(first_row));
|
||||||
should_fade_group = compose_fade_helper.should_fade_message(first_message);
|
should_fade_group = compose_fade_helper.should_fade_message(first_message);
|
||||||
|
|
||||||
change_fade_state($(visible_groups[i]), should_fade_group);
|
change_fade_state($(visible_groups[i]), should_fade_group);
|
||||||
|
@ -81,10 +82,12 @@ function fade_messages() {
|
||||||
// Defer updating all message groups so that the compose box can open sooner
|
// Defer updating all message groups so that the compose box can open sooner
|
||||||
setTimeout(
|
setTimeout(
|
||||||
(expected_msg_list, expected_recipient) => {
|
(expected_msg_list, expected_recipient) => {
|
||||||
const all_groups = rows.get_table(current_msg_list.table_name).find(".recipient_row");
|
const all_groups = rows
|
||||||
|
.get_table(message_lists.current.table_name)
|
||||||
|
.find(".recipient_row");
|
||||||
|
|
||||||
if (
|
if (
|
||||||
current_msg_list !== expected_msg_list ||
|
message_lists.current !== expected_msg_list ||
|
||||||
!compose_state.composing() ||
|
!compose_state.composing() ||
|
||||||
compose_state.private_message_recipient() !== expected_recipient
|
compose_state.private_message_recipient() !== expected_recipient
|
||||||
) {
|
) {
|
||||||
|
@ -106,7 +109,7 @@ function fade_messages() {
|
||||||
floating_recipient_bar.update();
|
floating_recipient_bar.update();
|
||||||
},
|
},
|
||||||
0,
|
0,
|
||||||
current_msg_list,
|
message_lists.current,
|
||||||
compose_state.private_message_recipient(),
|
compose_state.private_message_recipient(),
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
|
|
||||||
import * as message_flags from "./message_flags";
|
import * as message_flags from "./message_flags";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as rows from "./rows";
|
import * as rows from "./rows";
|
||||||
|
|
||||||
|
@ -43,7 +44,7 @@ function uncondense_row(row) {
|
||||||
export function uncollapse(row) {
|
export function uncollapse(row) {
|
||||||
// Uncollapse a message, restoring the condensed message [More] or
|
// Uncollapse a message, restoring the condensed message [More] or
|
||||||
// [Condense] link if necessary.
|
// [Condense] link if necessary.
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
message.collapsed = false;
|
message.collapsed = false;
|
||||||
message_flags.save_uncollapsed(message);
|
message_flags.save_uncollapsed(message);
|
||||||
|
|
||||||
|
@ -69,7 +70,7 @@ export function uncollapse(row) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// We also need to collapse this message in the home view
|
// We also need to collapse this message in the home view
|
||||||
const home_row = home_msg_list.get_row(rows.id(row));
|
const home_row = message_lists.home.get_row(rows.id(row));
|
||||||
|
|
||||||
process_row(row);
|
process_row(row);
|
||||||
process_row(home_row);
|
process_row(home_row);
|
||||||
|
@ -78,7 +79,7 @@ export function uncollapse(row) {
|
||||||
export function collapse(row) {
|
export function collapse(row) {
|
||||||
// Collapse a message, hiding the condensed message [More] or
|
// Collapse a message, hiding the condensed message [More] or
|
||||||
// [Condense] link if necessary.
|
// [Condense] link if necessary.
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
message.collapsed = true;
|
message.collapsed = true;
|
||||||
|
|
||||||
if (message.locally_echoed) {
|
if (message.locally_echoed) {
|
||||||
|
@ -97,7 +98,7 @@ export function collapse(row) {
|
||||||
};
|
};
|
||||||
|
|
||||||
// We also need to collapse this message in the home view
|
// We also need to collapse this message in the home view
|
||||||
const home_row = home_msg_list.get_row(rows.id(row));
|
const home_row = message_lists.home.get_row(rows.id(row));
|
||||||
|
|
||||||
process_row(row);
|
process_row(row);
|
||||||
process_row(home_row);
|
process_row(home_row);
|
||||||
|
@ -119,7 +120,7 @@ export function toggle_collapse(message) {
|
||||||
// * If the message is fully visible, either because it's too short to
|
// * If the message is fully visible, either because it's too short to
|
||||||
// condense or because it's already uncondensed, collapse it
|
// condense or because it's already uncondensed, collapse it
|
||||||
|
|
||||||
const row = current_msg_list.get_row(message.id);
|
const row = message_lists.current.get_row(message.id);
|
||||||
if (!row) {
|
if (!row) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -208,7 +209,7 @@ export function condense_and_collapse(elems) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = current_msg_list.get(message_id);
|
const message = message_lists.current.get(message_id);
|
||||||
if (message === undefined) {
|
if (message === undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -256,7 +257,7 @@ export function initialize() {
|
||||||
// Expanding a message can mean either uncollapsing or
|
// Expanding a message can mean either uncollapsing or
|
||||||
// uncondensing it.
|
// uncondensing it.
|
||||||
const row = $(this).closest(".message_row");
|
const row = $(this).closest(".message_row");
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
const content = row.find(".message_content");
|
const content = row.find(".message_content");
|
||||||
if (message.collapsed) {
|
if (message.collapsed) {
|
||||||
// Uncollapse.
|
// Uncollapse.
|
||||||
|
@ -274,7 +275,7 @@ export function initialize() {
|
||||||
|
|
||||||
$("#message_feed_container").on("click", ".message_condenser", function (e) {
|
$("#message_feed_container").on("click", ".message_condenser", function (e) {
|
||||||
const row = $(this).closest(".message_row");
|
const row = $(this).closest(".message_row");
|
||||||
current_msg_list.get(rows.id(row)).condensed = true;
|
message_lists.current.get(rows.id(row)).condensed = true;
|
||||||
condense_row(row);
|
condense_row(row);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -2,6 +2,7 @@ import $ from "jquery";
|
||||||
import TurndownService from "turndown/lib/turndown.cjs";
|
import TurndownService from "turndown/lib/turndown.cjs";
|
||||||
|
|
||||||
import * as compose_ui from "./compose_ui";
|
import * as compose_ui from "./compose_ui";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as rows from "./rows";
|
import * as rows from "./rows";
|
||||||
|
|
||||||
|
@ -83,7 +84,7 @@ function construct_copy_div(div, start_id, end_id) {
|
||||||
last_recipient_row_id = recipient_row_id;
|
last_recipient_row_id = recipient_row_id;
|
||||||
should_include_start_recipient_header = true;
|
should_include_start_recipient_header = true;
|
||||||
}
|
}
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
const message_firstp = $(message.content).slice(0, 1);
|
const message_firstp = $(message.content).slice(0, 1);
|
||||||
message_firstp.prepend(message.sender_full_name + ": ");
|
message_firstp.prepend(message.sender_full_name + ": ");
|
||||||
div.append(message_firstp);
|
div.append(message_firstp);
|
||||||
|
|
|
@ -7,6 +7,7 @@ import * as local_message from "./local_message";
|
||||||
import * as markdown from "./markdown";
|
import * as markdown from "./markdown";
|
||||||
import * as message_events from "./message_events";
|
import * as message_events from "./message_events";
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as notifications from "./notifications";
|
import * as notifications from "./notifications";
|
||||||
|
@ -188,7 +189,7 @@ export function try_deliver_locally(message_request) {
|
||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!current_msg_list.data.fetch_status.has_found_newest()) {
|
if (!message_lists.current.data.fetch_status.has_found_newest()) {
|
||||||
// If the current message list doesn't yet have the latest
|
// If the current message list doesn't yet have the latest
|
||||||
// messages before the one we just sent, local echo would make
|
// messages before the one we just sent, local echo would make
|
||||||
// it appear as though there were no messages between what we
|
// it appear as though there were no messages between what we
|
||||||
|
@ -282,8 +283,8 @@ export function edit_locally(message, request) {
|
||||||
// reaching this code path must either have been sent by us or the
|
// reaching this code path must either have been sent by us or the
|
||||||
// topic isn't being edited, so unread counts can't have changed.
|
// topic isn't being edited, so unread counts can't have changed.
|
||||||
|
|
||||||
home_msg_list.view.rerender_messages([message]);
|
message_lists.home.view.rerender_messages([message]);
|
||||||
if (current_msg_list === message_list.narrowed) {
|
if (message_lists.current === message_list.narrowed) {
|
||||||
message_list.narrowed.view.rerender_messages([message]);
|
message_list.narrowed.view.rerender_messages([message]);
|
||||||
}
|
}
|
||||||
stream_list.update_streams_sidebar();
|
stream_list.update_streams_sidebar();
|
||||||
|
@ -313,7 +314,7 @@ export function reify_message_id(local_id, server_id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function update_message_lists({old_id, new_id}) {
|
export function update_message_lists({old_id, new_id}) {
|
||||||
for (const msg_list of [message_list.all, home_msg_list, message_list.narrowed]) {
|
for (const msg_list of [message_list.all, message_lists.home, message_list.narrowed]) {
|
||||||
if (msg_list !== undefined) {
|
if (msg_list !== undefined) {
|
||||||
msg_list.change_message_id(old_id, new_id);
|
msg_list.change_message_id(old_id, new_id);
|
||||||
|
|
||||||
|
@ -380,8 +381,8 @@ export function process_from_server(messages) {
|
||||||
// changes in either the rounded timestamp we display or the
|
// changes in either the rounded timestamp we display or the
|
||||||
// message content, but in practice, there's no harm to just
|
// message content, but in practice, there's no harm to just
|
||||||
// doing it unconditionally.
|
// doing it unconditionally.
|
||||||
home_msg_list.view.rerender_messages(msgs_to_rerender);
|
message_lists.home.view.rerender_messages(msgs_to_rerender);
|
||||||
if (current_msg_list === message_list.narrowed) {
|
if (message_lists.current === message_list.narrowed) {
|
||||||
message_list.narrowed.view.rerender_messages(msgs_to_rerender);
|
message_list.narrowed.view.rerender_messages(msgs_to_rerender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -402,7 +403,7 @@ export function message_send_error(message_id, error_response) {
|
||||||
|
|
||||||
function abort_message(message) {
|
function abort_message(message) {
|
||||||
// Remove in all lists in which it exists
|
// Remove in all lists in which it exists
|
||||||
for (const msg_list of [message_list.all, home_msg_list, current_msg_list]) {
|
for (const msg_list of [message_list.all, message_lists.home, message_lists.current]) {
|
||||||
msg_list.remove_and_rerender([message.id]);
|
msg_list.remove_and_rerender([message.id]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,6 +11,7 @@ import render_emoji_showcase from "../templates/emoji_showcase.hbs";
|
||||||
import * as blueslip from "./blueslip";
|
import * as blueslip from "./blueslip";
|
||||||
import * as compose_ui from "./compose_ui";
|
import * as compose_ui from "./compose_ui";
|
||||||
import {i18n} from "./i18n";
|
import {i18n} from "./i18n";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as popovers from "./popovers";
|
import * as popovers from "./popovers";
|
||||||
import * as reactions from "./reactions";
|
import * as reactions from "./reactions";
|
||||||
|
@ -253,7 +254,7 @@ function filter_emojis() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function toggle_reaction(emoji_name, event) {
|
function toggle_reaction(emoji_name, event) {
|
||||||
const message_id = current_msg_list.selected_id();
|
const message_id = message_lists.current.selected_id();
|
||||||
const message = message_store.get(message_id);
|
const message = message_store.get(message_id);
|
||||||
if (!message) {
|
if (!message) {
|
||||||
blueslip.error("reactions: Bad message id: " + message_id);
|
blueslip.error("reactions: Bad message id: " + message_id);
|
||||||
|
@ -658,7 +659,7 @@ export function toggle_emoji_popover(element, id) {
|
||||||
$(element).closest(".message_row").toggleClass("has_popover has_emoji_popover");
|
$(element).closest(".message_row").toggleClass("has_popover has_emoji_popover");
|
||||||
const elt = $(element);
|
const elt = $(element);
|
||||||
if (id !== undefined) {
|
if (id !== undefined) {
|
||||||
current_msg_list.select_id(id);
|
message_lists.current.select_id(id);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (elt.data("popover") === undefined) {
|
if (elt.data("popover") === undefined) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
|
|
||||||
import * as blueslip from "./blueslip";
|
import * as blueslip from "./blueslip";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as rows from "./rows";
|
import * as rows from "./rows";
|
||||||
import * as timerender from "./timerender";
|
import * as timerender from "./timerender";
|
||||||
|
@ -238,7 +239,7 @@ export function candidate_recipient_bar() {
|
||||||
// bars that is still above the fold.
|
// bars that is still above the fold.
|
||||||
|
|
||||||
// Start with the pointer's current location.
|
// Start with the pointer's current location.
|
||||||
const selected_row = current_msg_list.selected_row();
|
const selected_row = message_lists.current.selected_row();
|
||||||
|
|
||||||
if (selected_row === undefined || selected_row.length === 0) {
|
if (selected_row === undefined || selected_row.length === 0) {
|
||||||
return undefined;
|
return undefined;
|
||||||
|
|
|
@ -3,8 +3,6 @@
|
||||||
// remove each declaration when the corresponding module is migrated
|
// remove each declaration when the corresponding module is migrated
|
||||||
// to TS.
|
// to TS.
|
||||||
|
|
||||||
declare let current_msg_list: any;
|
|
||||||
declare let home_msg_list: any;
|
|
||||||
declare let zulip_test: any;
|
declare let zulip_test: any;
|
||||||
|
|
||||||
interface JQuery {
|
interface JQuery {
|
||||||
|
|
|
@ -8,6 +8,7 @@ import * as floating_recipient_bar from "./floating_recipient_bar";
|
||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import * as info_overlay from "./info_overlay";
|
import * as info_overlay from "./info_overlay";
|
||||||
import * as invite from "./invite";
|
import * as invite from "./invite";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as narrow from "./narrow";
|
import * as narrow from "./narrow";
|
||||||
import * as navigate from "./navigate";
|
import * as navigate from "./navigate";
|
||||||
|
@ -126,7 +127,7 @@ function do_hashchange_normal(from_reload) {
|
||||||
if (from_reload) {
|
if (from_reload) {
|
||||||
blueslip.debug("We are narrowing as part of a reload.");
|
blueslip.debug("We are narrowing as part of a reload.");
|
||||||
if (page_params.initial_narrow_pointer !== undefined) {
|
if (page_params.initial_narrow_pointer !== undefined) {
|
||||||
home_msg_list.pre_narrow_offset = page_params.initial_offset;
|
message_lists.home.pre_narrow_offset = page_params.initial_offset;
|
||||||
narrow_opts.then_select_id = page_params.initial_narrow_pointer;
|
narrow_opts.then_select_id = page_params.initial_narrow_pointer;
|
||||||
narrow_opts.then_select_offset = page_params.initial_narrow_offset;
|
narrow_opts.then_select_offset = page_params.initial_narrow_offset;
|
||||||
}
|
}
|
||||||
|
|
|
@ -20,6 +20,7 @@ import * as lightbox from "./lightbox";
|
||||||
import * as list_util from "./list_util";
|
import * as list_util from "./list_util";
|
||||||
import * as message_edit from "./message_edit";
|
import * as message_edit from "./message_edit";
|
||||||
import * as message_flags from "./message_flags";
|
import * as message_flags from "./message_flags";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_view_header from "./message_view_header";
|
import * as message_view_header from "./message_view_header";
|
||||||
import * as muting_ui from "./muting_ui";
|
import * as muting_ui from "./muting_ui";
|
||||||
import * as narrow from "./narrow";
|
import * as narrow from "./narrow";
|
||||||
|
@ -37,7 +38,7 @@ import * as topic_zoom from "./topic_zoom";
|
||||||
import * as ui from "./ui";
|
import * as ui from "./ui";
|
||||||
|
|
||||||
function do_narrow_action(action) {
|
function do_narrow_action(action) {
|
||||||
action(current_msg_list.selected_id(), {trigger: "hotkey"});
|
action(message_lists.current.selected_id(), {trigger: "hotkey"});
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -792,7 +793,7 @@ export function process_hotkey(e, hotkey) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (current_msg_list.empty()) {
|
if (message_lists.current.empty()) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -825,7 +826,7 @@ export function process_hotkey(e, hotkey) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
const msg = current_msg_list.selected_message();
|
const msg = message_lists.current.selected_message();
|
||||||
// Shortcuts that operate on a message
|
// Shortcuts that operate on a message
|
||||||
switch (event_name) {
|
switch (event_name) {
|
||||||
case "message_actions":
|
case "message_actions":
|
||||||
|
@ -870,7 +871,7 @@ export function process_hotkey(e, hotkey) {
|
||||||
compose_actions.quote_and_reply({trigger: "hotkey"});
|
compose_actions.quote_and_reply({trigger: "hotkey"});
|
||||||
return true;
|
return true;
|
||||||
case "edit_message": {
|
case "edit_message": {
|
||||||
const row = current_msg_list.get_row(msg.id);
|
const row = message_lists.current.get_row(msg.id);
|
||||||
message_edit.start(row);
|
message_edit.start(row);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -14,6 +14,7 @@ import * as echo from "./echo";
|
||||||
import {i18n} from "./i18n";
|
import {i18n} from "./i18n";
|
||||||
import * as loading from "./loading";
|
import * as loading from "./loading";
|
||||||
import * as markdown from "./markdown";
|
import * as markdown from "./markdown";
|
||||||
|
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 {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
|
@ -300,7 +301,7 @@ function edit_message(row, raw_content) {
|
||||||
condense.hide_message_condenser(row);
|
condense.hide_message_condenser(row);
|
||||||
const content_top = row.find(".message_top_line")[0].getBoundingClientRect().top;
|
const content_top = row.find(".message_top_line")[0].getBoundingClientRect().top;
|
||||||
|
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
|
|
||||||
// We potentially got to this function by clicking a button that implied the
|
// We potentially got to this function by clicking a button that implied the
|
||||||
// user would be able to edit their message. Give a little bit of buffer in
|
// user would be able to edit their message. Give a little bit of buffer in
|
||||||
|
@ -352,7 +353,7 @@ function edit_message(row, raw_content) {
|
||||||
|
|
||||||
const edit_obj = {form, raw_content};
|
const edit_obj = {form, raw_content};
|
||||||
currently_editing_messages.set(message.id, edit_obj);
|
currently_editing_messages.set(message.id, edit_obj);
|
||||||
current_msg_list.show_edit_message(row, edit_obj);
|
message_lists.current.show_edit_message(row, edit_obj);
|
||||||
|
|
||||||
form.on("keydown", handle_message_row_edit_keydown);
|
form.on("keydown", handle_message_row_edit_keydown);
|
||||||
|
|
||||||
|
@ -532,7 +533,7 @@ function start_edit_with_content(row, content, edit_box_open_callback) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function start(row, edit_box_open_callback) {
|
export function start(row, edit_box_open_callback) {
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
if (message === undefined) {
|
if (message === undefined) {
|
||||||
blueslip.error("Couldn't find message ID for edit " + rows.id(row));
|
blueslip.error("Couldn't find message ID for edit " + rows.id(row));
|
||||||
return;
|
return;
|
||||||
|
@ -543,12 +544,12 @@ export function start(row, edit_box_open_callback) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const msg_list = current_msg_list;
|
const msg_list = message_lists.current;
|
||||||
channel.get({
|
channel.get({
|
||||||
url: "/json/messages/" + message.id,
|
url: "/json/messages/" + message.id,
|
||||||
idempotent: true,
|
idempotent: true,
|
||||||
success(data) {
|
success(data) {
|
||||||
if (current_msg_list === msg_list) {
|
if (message_lists.current === msg_list) {
|
||||||
message.raw_content = data.raw_content;
|
message.raw_content = data.raw_content;
|
||||||
start_edit_with_content(row, message.raw_content, edit_box_open_callback);
|
start_edit_with_content(row, message.raw_content, edit_box_open_callback);
|
||||||
}
|
}
|
||||||
|
@ -558,11 +559,11 @@ export function start(row, edit_box_open_callback) {
|
||||||
|
|
||||||
export function start_inline_topic_edit(recipient_row) {
|
export function start_inline_topic_edit(recipient_row) {
|
||||||
const form = $(render_topic_edit_form());
|
const form = $(render_topic_edit_form());
|
||||||
current_msg_list.show_edit_topic_on_recipient_row(recipient_row, form);
|
message_lists.current.show_edit_topic_on_recipient_row(recipient_row, form);
|
||||||
form.on("keydown", handle_inline_topic_edit_keydown);
|
form.on("keydown", handle_inline_topic_edit_keydown);
|
||||||
$(".topic_edit_spinner").hide();
|
$(".topic_edit_spinner").hide();
|
||||||
const msg_id = rows.id_for_recipient_row(recipient_row);
|
const msg_id = rows.id_for_recipient_row(recipient_row);
|
||||||
const message = current_msg_list.get(msg_id);
|
const message = message_lists.current.get(msg_id);
|
||||||
let topic = message.topic;
|
let topic = message.topic;
|
||||||
if (topic === compose.empty_topic_placeholder()) {
|
if (topic === compose.empty_topic_placeholder()) {
|
||||||
topic = "";
|
topic = "";
|
||||||
|
@ -575,11 +576,11 @@ export function is_editing(id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function end_inline_topic_edit(row) {
|
export function end_inline_topic_edit(row) {
|
||||||
current_msg_list.hide_edit_topic_on_recipient_row(row);
|
message_lists.current.hide_edit_topic_on_recipient_row(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function end_message_row_edit(row) {
|
export function end_message_row_edit(row) {
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
if (message !== undefined && currently_editing_messages.has(message.id)) {
|
if (message !== undefined && currently_editing_messages.has(message.id)) {
|
||||||
const scroll_by = currently_editing_messages.get(message.id).scrolled_by;
|
const scroll_by = currently_editing_messages.get(message.id).scrolled_by;
|
||||||
message_viewport.scrollTop(message_viewport.scrollTop() - scroll_by);
|
message_viewport.scrollTop(message_viewport.scrollTop() - scroll_by);
|
||||||
|
@ -594,7 +595,7 @@ export function end_message_row_edit(row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
currently_editing_messages.delete(message.id);
|
currently_editing_messages.delete(message.id);
|
||||||
current_msg_list.hide_edit_message(row);
|
message_lists.current.hide_edit_message(row);
|
||||||
|
|
||||||
compose.abort_video_callbacks(message.id);
|
compose.abort_video_callbacks(message.id);
|
||||||
}
|
}
|
||||||
|
@ -611,9 +612,9 @@ export function end_message_row_edit(row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function save_inline_topic_edit(row) {
|
export function save_inline_topic_edit(row) {
|
||||||
const msg_list = current_msg_list;
|
const msg_list = message_lists.current;
|
||||||
let message_id = rows.id_for_recipient_row(row);
|
let message_id = rows.id_for_recipient_row(row);
|
||||||
const message = current_msg_list.get(message_id);
|
const message = message_lists.current.get(message_id);
|
||||||
|
|
||||||
const old_topic = message.topic;
|
const old_topic = message.topic;
|
||||||
const new_topic = row.find(".inline_topic_edit").val();
|
const new_topic = row.find(".inline_topic_edit").val();
|
||||||
|
@ -631,7 +632,7 @@ export function save_inline_topic_edit(row) {
|
||||||
if (message.locally_echoed) {
|
if (message.locally_echoed) {
|
||||||
if (topic_changed) {
|
if (topic_changed) {
|
||||||
echo.edit_locally(message, {new_topic});
|
echo.edit_locally(message, {new_topic});
|
||||||
row = current_msg_list.get_row(message_id);
|
row = message_lists.current.get_row(message_id);
|
||||||
}
|
}
|
||||||
end_inline_topic_edit(row);
|
end_inline_topic_edit(row);
|
||||||
return;
|
return;
|
||||||
|
@ -653,7 +654,7 @@ export function save_inline_topic_edit(row) {
|
||||||
error(xhr) {
|
error(xhr) {
|
||||||
const spinner = row.find(".topic_edit_spinner");
|
const spinner = row.find(".topic_edit_spinner");
|
||||||
loading.destroy_indicator(spinner);
|
loading.destroy_indicator(spinner);
|
||||||
if (msg_list === current_msg_list) {
|
if (msg_list === message_lists.current) {
|
||||||
message_id = rows.id_for_recipient_row(row);
|
message_id = rows.id_for_recipient_row(row);
|
||||||
const message = channel.xhr_error_message(i18n.t("Error saving edit"), xhr);
|
const message = channel.xhr_error_message(i18n.t("Error saving edit"), xhr);
|
||||||
row.find(".edit_error").text(message).css("display", "inline-block");
|
row.find(".edit_error").text(message).css("display", "inline-block");
|
||||||
|
@ -663,9 +664,9 @@ export function save_inline_topic_edit(row) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function save_message_row_edit(row) {
|
export function save_message_row_edit(row) {
|
||||||
const msg_list = current_msg_list;
|
const msg_list = message_lists.current;
|
||||||
let message_id = rows.id(row);
|
let message_id = rows.id(row);
|
||||||
const message = current_msg_list.get(message_id);
|
const message = message_lists.current.get(message_id);
|
||||||
let changed = false;
|
let changed = false;
|
||||||
let edit_locally_echoed = false;
|
let edit_locally_echoed = false;
|
||||||
|
|
||||||
|
@ -697,7 +698,7 @@ export function save_message_row_edit(row) {
|
||||||
new_topic,
|
new_topic,
|
||||||
new_stream_id,
|
new_stream_id,
|
||||||
});
|
});
|
||||||
row = current_msg_list.get_row(message_id);
|
row = message_lists.current.get_row(message_id);
|
||||||
}
|
}
|
||||||
end_message_row_edit(row);
|
end_message_row_edit(row);
|
||||||
return;
|
return;
|
||||||
|
@ -776,7 +777,7 @@ export function save_message_row_edit(row) {
|
||||||
|
|
||||||
echo.edit_locally(message, currently_echoing_messages.get(message_id));
|
echo.edit_locally(message, currently_echoing_messages.get(message_id));
|
||||||
|
|
||||||
row = current_msg_list.get_row(message_id);
|
row = message_lists.current.get_row(message_id);
|
||||||
end_message_row_edit(row);
|
end_message_row_edit(row);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -791,7 +792,7 @@ export function save_message_row_edit(row) {
|
||||||
hide_message_edit_spinner(row);
|
hide_message_edit_spinner(row);
|
||||||
},
|
},
|
||||||
error(xhr) {
|
error(xhr) {
|
||||||
if (msg_list === current_msg_list) {
|
if (msg_list === message_lists.current) {
|
||||||
message_id = rows.id(row);
|
message_id = rows.id(row);
|
||||||
|
|
||||||
if (edit_locally_echoed) {
|
if (edit_locally_echoed) {
|
||||||
|
@ -810,7 +811,7 @@ export function save_message_row_edit(row) {
|
||||||
alerted: echo_data.alerted,
|
alerted: echo_data.alerted,
|
||||||
});
|
});
|
||||||
|
|
||||||
row = current_msg_list.get_row(message_id);
|
row = message_lists.current.get_row(message_id);
|
||||||
if (!is_editing(message_id)) {
|
if (!is_editing(message_id)) {
|
||||||
// Return to the message editing open UI state.
|
// Return to the message editing open UI state.
|
||||||
start_edit_maintaining_scroll(row, echo_data.orig_raw_content);
|
start_edit_maintaining_scroll(row, echo_data.orig_raw_content);
|
||||||
|
@ -828,12 +829,12 @@ export function save_message_row_edit(row) {
|
||||||
|
|
||||||
export function maybe_show_edit(row, id) {
|
export function maybe_show_edit(row, id) {
|
||||||
if (currently_editing_messages.has(id)) {
|
if (currently_editing_messages.has(id)) {
|
||||||
current_msg_list.show_edit_message(row, currently_editing_messages.get(id));
|
message_lists.current.show_edit_message(row, currently_editing_messages.get(id));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function edit_last_sent_message() {
|
export function edit_last_sent_message() {
|
||||||
const msg = current_msg_list.get_last_message_sent_by_me();
|
const msg = message_lists.current.get_last_message_sent_by_me();
|
||||||
|
|
||||||
if (!msg) {
|
if (!msg) {
|
||||||
return;
|
return;
|
||||||
|
@ -849,15 +850,15 @@ export function edit_last_sent_message() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const msg_row = current_msg_list.get_row(msg.id);
|
const msg_row = message_lists.current.get_row(msg.id);
|
||||||
if (!msg_row) {
|
if (!msg_row) {
|
||||||
// This should never happen, since we got the message above
|
// This should never happen, since we got the message above
|
||||||
// from current_msg_list.
|
// from message_lists.current.
|
||||||
blueslip.error("Could not find row for id " + msg.id);
|
blueslip.error("Could not find row for id " + msg.id);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
current_msg_list.select_id(msg.id, {then_scroll: true, from_scroll: true});
|
message_lists.current.select_id(msg.id, {then_scroll: true, from_scroll: true});
|
||||||
|
|
||||||
// Finally do the real work!
|
// Finally do the real work!
|
||||||
compose_actions.cancel();
|
compose_actions.cancel();
|
||||||
|
@ -932,9 +933,9 @@ export function delete_topic(stream_id, topic_name) {
|
||||||
|
|
||||||
export function handle_narrow_deactivated() {
|
export function handle_narrow_deactivated() {
|
||||||
for (const [idx, elem] of currently_editing_messages) {
|
for (const [idx, elem] of currently_editing_messages) {
|
||||||
if (current_msg_list.get(idx) !== undefined) {
|
if (message_lists.current.get(idx) !== undefined) {
|
||||||
const row = current_msg_list.get_row(idx);
|
const row = message_lists.current.get_row(idx);
|
||||||
current_msg_list.show_edit_message(row, elem);
|
message_lists.current.show_edit_message(row, elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -10,6 +10,7 @@ import * as message_edit from "./message_edit";
|
||||||
import * as message_edit_history from "./message_edit_history";
|
import * as message_edit_history from "./message_edit_history";
|
||||||
import * as message_helper from "./message_helper";
|
import * as message_helper from "./message_helper";
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
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 narrow from "./narrow";
|
import * as narrow from "./narrow";
|
||||||
|
@ -43,7 +44,7 @@ function maybe_add_narrowed_messages(messages, msg_list) {
|
||||||
},
|
},
|
||||||
timeout: 5000,
|
timeout: 5000,
|
||||||
success(data) {
|
success(data) {
|
||||||
if (msg_list !== current_msg_list) {
|
if (msg_list !== message_lists.current) {
|
||||||
// We unnarrowed in the mean time
|
// We unnarrowed in the mean time
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -77,7 +78,7 @@ function maybe_add_narrowed_messages(messages, msg_list) {
|
||||||
error() {
|
error() {
|
||||||
// We might want to be more clever here
|
// We might want to be more clever here
|
||||||
setTimeout(() => {
|
setTimeout(() => {
|
||||||
if (msg_list === current_msg_list) {
|
if (msg_list === message_lists.current) {
|
||||||
// Don't actually try again if we unnarrowed
|
// Don't actually try again if we unnarrowed
|
||||||
// while waiting
|
// while waiting
|
||||||
maybe_add_narrowed_messages(messages, msg_list);
|
maybe_add_narrowed_messages(messages, msg_list);
|
||||||
|
@ -102,7 +103,7 @@ export function insert_new_messages(messages, sent_by_this_client) {
|
||||||
if (narrow_state.active()) {
|
if (narrow_state.active()) {
|
||||||
// We do this NOW even though the home view is not active,
|
// We do this NOW even though the home view is not active,
|
||||||
// because we want the home view to load fast later.
|
// because we want the home view to load fast later.
|
||||||
message_util.add_new_messages(messages, home_msg_list);
|
message_util.add_new_messages(messages, message_lists.home);
|
||||||
|
|
||||||
if (narrow_state.filter().can_apply_locally()) {
|
if (narrow_state.filter().can_apply_locally()) {
|
||||||
render_info = message_util.add_new_messages(messages, message_list.narrowed);
|
render_info = message_util.add_new_messages(messages, message_list.narrowed);
|
||||||
|
@ -112,7 +113,7 @@ export function insert_new_messages(messages, sent_by_this_client) {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// we're in the home view, so update its list
|
// we're in the home view, so update its list
|
||||||
render_info = message_util.add_new_messages(messages, home_msg_list);
|
render_info = message_util.add_new_messages(messages, message_lists.home);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sent_by_this_client) {
|
if (sent_by_this_client) {
|
||||||
|
@ -165,7 +166,7 @@ export function update_messages(events) {
|
||||||
msg.is_me_message = event.is_me_message;
|
msg.is_me_message = event.is_me_message;
|
||||||
}
|
}
|
||||||
|
|
||||||
const row = current_msg_list.get_row(event.message_id);
|
const row = message_lists.current.get_row(event.message_id);
|
||||||
if (row.length > 0) {
|
if (row.length > 0) {
|
||||||
message_edit.end_message_row_edit(row);
|
message_edit.end_message_row_edit(row);
|
||||||
}
|
}
|
||||||
|
@ -189,7 +190,7 @@ export function update_messages(events) {
|
||||||
const orig_topic = util.get_edit_event_orig_topic(event);
|
const orig_topic = util.get_edit_event_orig_topic(event);
|
||||||
|
|
||||||
const current_filter = narrow_state.filter();
|
const current_filter = narrow_state.filter();
|
||||||
const current_selected_id = current_msg_list.selected_id();
|
const current_selected_id = message_lists.current.selected_id();
|
||||||
const selection_changed_topic = event.message_ids.includes(current_selected_id);
|
const selection_changed_topic = event.message_ids.includes(current_selected_id);
|
||||||
const event_messages = event.message_ids.map((id) => message_store.get(id));
|
const event_messages = event.message_ids.map((id) => message_store.get(id));
|
||||||
// The event.message_ids received from the server are not in sorted order.
|
// The event.message_ids received from the server are not in sorted order.
|
||||||
|
@ -331,8 +332,8 @@ export function update_messages(events) {
|
||||||
// list and then pass these to the remove messages codepath.
|
// list and then pass these to the remove messages codepath.
|
||||||
// While we can pass all our messages to the add messages
|
// While we can pass all our messages to the add messages
|
||||||
// codepath as the filtering is done within the method.
|
// codepath as the filtering is done within the method.
|
||||||
current_msg_list.remove_and_rerender(message_ids_to_remove);
|
message_lists.current.remove_and_rerender(message_ids_to_remove);
|
||||||
current_msg_list.add_messages(event_messages);
|
message_lists.current.add_messages(event_messages);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -395,17 +396,17 @@ export function update_messages(events) {
|
||||||
// propagated edits to be updated (since the topic edits can have
|
// propagated edits to be updated (since the topic edits can have
|
||||||
// changed the correct grouping of messages).
|
// changed the correct grouping of messages).
|
||||||
if (topic_edited || stream_changed) {
|
if (topic_edited || stream_changed) {
|
||||||
home_msg_list.update_muting_and_rerender();
|
message_lists.home.update_muting_and_rerender();
|
||||||
// However, we don't need to rerender message_list.narrowed if
|
// However, we don't need to rerender message_list.narrowed if
|
||||||
// we just changed the narrow earlier in this function.
|
// we just changed the narrow earlier in this function.
|
||||||
if (!changed_narrow && current_msg_list === message_list.narrowed) {
|
if (!changed_narrow && message_lists.current === message_list.narrowed) {
|
||||||
message_list.narrowed.update_muting_and_rerender();
|
message_list.narrowed.update_muting_and_rerender();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// If the content of the message was edited, we do a special animation.
|
// If the content of the message was edited, we do a special animation.
|
||||||
current_msg_list.view.rerender_messages(msgs_to_rerender, message_content_edited);
|
message_lists.current.view.rerender_messages(msgs_to_rerender, message_content_edited);
|
||||||
if (current_msg_list === message_list.narrowed) {
|
if (message_lists.current === message_list.narrowed) {
|
||||||
home_msg_list.view.rerender_messages(msgs_to_rerender);
|
message_lists.home.view.rerender_messages(msgs_to_rerender);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -421,7 +422,7 @@ export function update_messages(events) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function remove_messages(message_ids) {
|
export function remove_messages(message_ids) {
|
||||||
for (const list of [message_list.all, home_msg_list, message_list.narrowed]) {
|
for (const list of [message_list.all, message_lists.home, message_list.narrowed]) {
|
||||||
if (list === undefined) {
|
if (list === undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import {Filter} from "./filter";
|
||||||
import * as huddle_data from "./huddle_data";
|
import * as huddle_data from "./huddle_data";
|
||||||
import * as message_helper from "./message_helper";
|
import * as message_helper from "./message_helper";
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_scroll from "./message_scroll";
|
import * as message_scroll from "./message_scroll";
|
||||||
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";
|
||||||
|
@ -40,7 +41,7 @@ function process_result(data, opts) {
|
||||||
|
|
||||||
if (
|
if (
|
||||||
messages.length === 0 &&
|
messages.length === 0 &&
|
||||||
current_msg_list === message_list.narrowed &&
|
message_lists.current === message_list.narrowed &&
|
||||||
message_list.narrowed.empty()
|
message_list.narrowed.empty()
|
||||||
) {
|
) {
|
||||||
// Even after trying to load more messages, we have no
|
// Even after trying to load more messages, we have no
|
||||||
|
@ -61,9 +62,9 @@ function process_result(data, opts) {
|
||||||
message_util.do_unread_count_updates(messages);
|
message_util.do_unread_count_updates(messages);
|
||||||
|
|
||||||
// If we're loading more messages into the home view, save them to
|
// If we're loading more messages into the home view, save them to
|
||||||
// the message_list.all as well, as the home_msg_list is reconstructed
|
// the message_list.all as well, as the message_lists.home is reconstructed
|
||||||
// from message_list.all.
|
// from message_list.all.
|
||||||
if (opts.msg_list === home_msg_list) {
|
if (opts.msg_list === message_lists.home) {
|
||||||
message_util.add_old_messages(messages, message_list.all);
|
message_util.add_old_messages(messages, message_list.all);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -84,15 +85,15 @@ function process_result(data, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function get_messages_success(data, opts) {
|
function get_messages_success(data, opts) {
|
||||||
const update_loading_indicator = opts.msg_list === current_msg_list;
|
const update_loading_indicator = opts.msg_list === message_lists.current;
|
||||||
if (opts.num_before > 0) {
|
if (opts.num_before > 0) {
|
||||||
opts.msg_list.data.fetch_status.finish_older_batch({
|
opts.msg_list.data.fetch_status.finish_older_batch({
|
||||||
update_loading_indicator,
|
update_loading_indicator,
|
||||||
found_oldest: data.found_oldest,
|
found_oldest: data.found_oldest,
|
||||||
history_limited: data.history_limited,
|
history_limited: data.history_limited,
|
||||||
});
|
});
|
||||||
if (opts.msg_list === home_msg_list) {
|
if (opts.msg_list === message_lists.home) {
|
||||||
// When we update home_msg_list, we need to also update
|
// When we update message_lists.home, we need to also update
|
||||||
// the fetch_status data structure for message_list.all,
|
// the fetch_status data structure for message_list.all,
|
||||||
// which is never rendered (and just used for
|
// which is never rendered (and just used for
|
||||||
// prepopulating narrowed views).
|
// prepopulating narrowed views).
|
||||||
|
@ -110,8 +111,8 @@ function get_messages_success(data, opts) {
|
||||||
update_loading_indicator,
|
update_loading_indicator,
|
||||||
found_newest: data.found_newest,
|
found_newest: data.found_newest,
|
||||||
});
|
});
|
||||||
if (opts.msg_list === home_msg_list) {
|
if (opts.msg_list === message_lists.home) {
|
||||||
// When we update home_msg_list, we need to also update
|
// When we update message_lists.home, we need to also update
|
||||||
// the fetch_status data structure for message_list.all,
|
// the fetch_status data structure for message_list.all,
|
||||||
// which is never rendered (and just used for
|
// which is never rendered (and just used for
|
||||||
// prepopulating narrowed views).
|
// prepopulating narrowed views).
|
||||||
|
@ -125,7 +126,7 @@ function get_messages_success(data, opts) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opts.msg_list.narrowed && opts.msg_list !== current_msg_list) {
|
if (opts.msg_list.narrowed && opts.msg_list !== message_lists.current) {
|
||||||
// We unnarrowed before receiving new messages so
|
// We unnarrowed before receiving new messages so
|
||||||
// don't bother processing the newly arrived messages.
|
// don't bother processing the newly arrived messages.
|
||||||
return;
|
return;
|
||||||
|
@ -198,16 +199,16 @@ export function load_messages(opts) {
|
||||||
// data.narrow = opts.msg_list.data.filter.public_operators()
|
// data.narrow = opts.msg_list.data.filter.public_operators()
|
||||||
//
|
//
|
||||||
// But support for the message_list.all sharing of data with
|
// But support for the message_list.all sharing of data with
|
||||||
// home_msg_list and the (hacky) page_params.narrow feature
|
// message_lists.home and the (hacky) page_params.narrow feature
|
||||||
// requires a somewhat ugly bundle of conditionals.
|
// requires a somewhat ugly bundle of conditionals.
|
||||||
if (opts.msg_list === home_msg_list) {
|
if (opts.msg_list === message_lists.home) {
|
||||||
if (page_params.narrow_stream !== undefined) {
|
if (page_params.narrow_stream !== undefined) {
|
||||||
data.narrow = JSON.stringify(page_params.narrow);
|
data.narrow = JSON.stringify(page_params.narrow);
|
||||||
}
|
}
|
||||||
// Otherwise, we don't pass narrow for home_msg_list; this is
|
// Otherwise, we don't pass narrow for message_lists.home; this is
|
||||||
// required because it shares its data with all_msg_list, and
|
// required because it shares its data with all_msg_list, and
|
||||||
// so we need the server to send us message history from muted
|
// so we need the server to send us message history from muted
|
||||||
// streams and topics even though home_msg_list's in:home
|
// streams and topics even though message_lists.home's in:home
|
||||||
// operators will filter those.
|
// operators will filter those.
|
||||||
} else {
|
} else {
|
||||||
let operators = opts.msg_list.data.filter.public_operators();
|
let operators = opts.msg_list.data.filter.public_operators();
|
||||||
|
@ -217,12 +218,12 @@ export function load_messages(opts) {
|
||||||
data.narrow = JSON.stringify(operators);
|
data.narrow = JSON.stringify(operators);
|
||||||
}
|
}
|
||||||
|
|
||||||
let update_loading_indicator = opts.msg_list === current_msg_list;
|
let update_loading_indicator = opts.msg_list === message_lists.current;
|
||||||
if (opts.num_before > 0) {
|
if (opts.num_before > 0) {
|
||||||
opts.msg_list.data.fetch_status.start_older_batch({
|
opts.msg_list.data.fetch_status.start_older_batch({
|
||||||
update_loading_indicator,
|
update_loading_indicator,
|
||||||
});
|
});
|
||||||
if (opts.msg_list === home_msg_list) {
|
if (opts.msg_list === message_lists.home) {
|
||||||
message_list.all.data.fetch_status.start_older_batch({
|
message_list.all.data.fetch_status.start_older_batch({
|
||||||
update_loading_indicator,
|
update_loading_indicator,
|
||||||
});
|
});
|
||||||
|
@ -235,7 +236,7 @@ export function load_messages(opts) {
|
||||||
opts.msg_list.data.fetch_status.start_newer_batch({
|
opts.msg_list.data.fetch_status.start_newer_batch({
|
||||||
update_loading_indicator,
|
update_loading_indicator,
|
||||||
});
|
});
|
||||||
if (opts.msg_list === home_msg_list) {
|
if (opts.msg_list === message_lists.home) {
|
||||||
message_list.all.data.fetch_status.start_newer_batch({
|
message_list.all.data.fetch_status.start_newer_batch({
|
||||||
update_loading_indicator,
|
update_loading_indicator,
|
||||||
});
|
});
|
||||||
|
@ -253,7 +254,7 @@ export function load_messages(opts) {
|
||||||
get_messages_success(data, opts);
|
get_messages_success(data, opts);
|
||||||
},
|
},
|
||||||
error(xhr) {
|
error(xhr) {
|
||||||
if (opts.msg_list.narrowed && opts.msg_list !== current_msg_list) {
|
if (opts.msg_list.narrowed && opts.msg_list !== message_lists.current) {
|
||||||
// We unnarrowed before getting an error so don't
|
// We unnarrowed before getting an error so don't
|
||||||
// bother trying again or doing further processing.
|
// bother trying again or doing further processing.
|
||||||
return;
|
return;
|
||||||
|
@ -294,7 +295,7 @@ export function load_messages_for_narrow(opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get_backfill_anchor(msg_list) {
|
export function get_backfill_anchor(msg_list) {
|
||||||
if (msg_list === home_msg_list) {
|
if (msg_list === message_lists.home) {
|
||||||
msg_list = message_list.all;
|
msg_list = message_list.all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -309,7 +310,7 @@ export function get_backfill_anchor(msg_list) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get_frontfill_anchor(msg_list) {
|
export function get_frontfill_anchor(msg_list) {
|
||||||
if (msg_list === home_msg_list) {
|
if (msg_list === message_lists.home) {
|
||||||
msg_list = message_list.all;
|
msg_list = message_list.all;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -376,8 +377,8 @@ export function maybe_load_newer_messages(opts) {
|
||||||
const anchor = get_frontfill_anchor(msg_list);
|
const anchor = get_frontfill_anchor(msg_list);
|
||||||
|
|
||||||
function load_more(data, args) {
|
function load_more(data, args) {
|
||||||
if (args.fetch_again && args.msg_list === current_msg_list) {
|
if (args.fetch_again && args.msg_list === message_lists.current) {
|
||||||
maybe_load_newer_messages({msg_list: current_msg_list});
|
maybe_load_newer_messages({msg_list: message_lists.current});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -397,7 +398,7 @@ export function start_backfilling_messages() {
|
||||||
onIdle() {
|
onIdle() {
|
||||||
do_backfill({
|
do_backfill({
|
||||||
num_before: consts.backfill_batch_size,
|
num_before: consts.backfill_batch_size,
|
||||||
msg_list: home_msg_list,
|
msg_list: message_lists.home,
|
||||||
});
|
});
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
@ -408,11 +409,11 @@ export function initialize(home_view_loaded) {
|
||||||
function load_more(data) {
|
function load_more(data) {
|
||||||
// If we haven't selected a message in the home view yet, and
|
// If we haven't selected a message in the home view yet, and
|
||||||
// the home view isn't empty, we select the anchor message here.
|
// the home view isn't empty, we select the anchor message here.
|
||||||
if (home_msg_list.selected_id() === -1 && !home_msg_list.empty()) {
|
if (message_lists.home.selected_id() === -1 && !message_lists.home.empty()) {
|
||||||
// We fall back to the closest selected id, as the user
|
// We fall back to the closest selected id, as the user
|
||||||
// may have removed a stream from the home view while we
|
// may have removed a stream from the home view while we
|
||||||
// were loading data.
|
// were loading data.
|
||||||
home_msg_list.select_id(data.anchor, {
|
message_lists.home.select_id(data.anchor, {
|
||||||
then_scroll: true,
|
then_scroll: true,
|
||||||
use_closest: true,
|
use_closest: true,
|
||||||
target_scroll_offset: page_params.initial_offset,
|
target_scroll_offset: page_params.initial_offset,
|
||||||
|
@ -435,7 +436,7 @@ export function initialize(home_view_loaded) {
|
||||||
anchor: latest_id,
|
anchor: latest_id,
|
||||||
num_before: 0,
|
num_before: 0,
|
||||||
num_after: consts.catch_up_batch_size,
|
num_after: consts.catch_up_batch_size,
|
||||||
msg_list: home_msg_list,
|
msg_list: message_lists.home,
|
||||||
cont: load_more,
|
cont: load_more,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -454,7 +455,7 @@ export function initialize(home_view_loaded) {
|
||||||
anchor,
|
anchor,
|
||||||
num_before: consts.num_before_home_anchor,
|
num_before: consts.num_before_home_anchor,
|
||||||
num_after: consts.num_after_home_anchor,
|
num_after: consts.num_after_home_anchor,
|
||||||
msg_list: home_msg_list,
|
msg_list: message_lists.home,
|
||||||
cont: load_more,
|
cont: load_more,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
@ -16,6 +16,7 @@ import * as condense from "./condense";
|
||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import {i18n} from "./i18n";
|
import {i18n} from "./i18n";
|
||||||
import * as message_edit from "./message_edit";
|
import * as message_edit from "./message_edit";
|
||||||
|
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 narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
|
@ -326,11 +327,11 @@ export class MessageListView {
|
||||||
message_container.subscribed = false;
|
message_container.subscribed = false;
|
||||||
message_container.unsubscribed = false;
|
message_container.unsubscribed = false;
|
||||||
|
|
||||||
// This home_msg_list condition can be removed
|
// This message_lists.home condition can be removed
|
||||||
// once we filter historical messages from the
|
// once we filter historical messages from the
|
||||||
// home view on the server side (which requires
|
// home view on the server side (which requires
|
||||||
// having an index on UserMessage.flags)
|
// having an index on UserMessage.flags)
|
||||||
if (this.list !== home_msg_list) {
|
if (this.list !== message_lists.home) {
|
||||||
this.add_subscription_marker(current_group, prev, message_container);
|
this.add_subscription_marker(current_group, prev, message_container);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -412,7 +413,7 @@ export class MessageListView {
|
||||||
return true;
|
return true;
|
||||||
// Add a subscription marker
|
// Add a subscription marker
|
||||||
} else if (
|
} else if (
|
||||||
this.list !== home_msg_list &&
|
this.list !== message_lists.home &&
|
||||||
last_msg_container.msg.historical !== first_msg_container.msg.historical
|
last_msg_container.msg.historical !== first_msg_container.msg.historical
|
||||||
) {
|
) {
|
||||||
second_group.bookend_top = true;
|
second_group.bookend_top = true;
|
||||||
|
@ -631,7 +632,7 @@ export class MessageListView {
|
||||||
const restore_scroll_position = () => {
|
const restore_scroll_position = () => {
|
||||||
if (
|
if (
|
||||||
!recent_topics.is_visible() &&
|
!recent_topics.is_visible() &&
|
||||||
list === current_msg_list &&
|
list === message_lists.current &&
|
||||||
orig_scrolltop_offset !== undefined
|
orig_scrolltop_offset !== undefined
|
||||||
) {
|
) {
|
||||||
list.view.set_message_offset(orig_scrolltop_offset);
|
list.view.set_message_offset(orig_scrolltop_offset);
|
||||||
|
@ -789,7 +790,7 @@ export class MessageListView {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list === current_msg_list) {
|
if (list === message_lists.current) {
|
||||||
// Update the fade.
|
// Update the fade.
|
||||||
|
|
||||||
const get_element = (message_group) => {
|
const get_element = (message_group) => {
|
||||||
|
@ -804,7 +805,7 @@ export class MessageListView {
|
||||||
compose_fade.update_rendered_message_groups(new_message_groups, get_element);
|
compose_fade.update_rendered_message_groups(new_message_groups, get_element);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (list === current_msg_list && messages_are_new) {
|
if (list === message_lists.current && messages_are_new) {
|
||||||
// First, in single-recipient narrows, potentially
|
// First, in single-recipient narrows, potentially
|
||||||
// auto-scroll to the latest message if it was sent by us.
|
// auto-scroll to the latest message if it was sent by us.
|
||||||
if (narrow_state.narrowed_by_reply()) {
|
if (narrow_state.narrowed_by_reply()) {
|
||||||
|
|
|
@ -0,0 +1,18 @@
|
||||||
|
import {Filter} from "./filter";
|
||||||
|
import * as message_list from "./message_list";
|
||||||
|
|
||||||
|
export let home;
|
||||||
|
export let current;
|
||||||
|
|
||||||
|
export function set_current(msg_list) {
|
||||||
|
current = msg_list;
|
||||||
|
}
|
||||||
|
|
||||||
|
export function initialize() {
|
||||||
|
home = new message_list.MessageList({
|
||||||
|
table_name: "zhome",
|
||||||
|
filter: new Filter([{operator: "in", operand: "home"}]),
|
||||||
|
excludes_muted_topics: true,
|
||||||
|
});
|
||||||
|
current = home;
|
||||||
|
}
|
|
@ -1,9 +1,10 @@
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
|
|
||||||
function rerender_messages_view() {
|
function rerender_messages_view() {
|
||||||
for (const list of [home_msg_list, message_list.narrowed, message_list.all]) {
|
for (const list of [message_lists.home, message_list.narrowed, message_list.all]) {
|
||||||
if (list === undefined) {
|
if (list === undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -5,6 +5,7 @@ import * as floating_recipient_bar from "./floating_recipient_bar";
|
||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import * as loading from "./loading";
|
import * as loading from "./loading";
|
||||||
import * as message_fetch from "./message_fetch";
|
import * as message_fetch from "./message_fetch";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as narrow_banner from "./narrow_banner";
|
import * as narrow_banner from "./narrow_banner";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
|
@ -90,11 +91,14 @@ export function show_end_of_results_notice() {
|
||||||
export function update_top_of_narrow_notices(msg_list) {
|
export function update_top_of_narrow_notices(msg_list) {
|
||||||
// Assumes that the current state is all notices hidden (i.e. this
|
// Assumes that the current state is all notices hidden (i.e. this
|
||||||
// will not hide a notice that should not be there)
|
// will not hide a notice that should not be there)
|
||||||
if (msg_list !== current_msg_list) {
|
if (msg_list !== message_lists.current) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg_list.data.fetch_status.has_found_oldest() && current_msg_list !== home_msg_list) {
|
if (
|
||||||
|
msg_list.data.fetch_status.has_found_oldest() &&
|
||||||
|
message_lists.current !== message_lists.home
|
||||||
|
) {
|
||||||
const filter = narrow_state.filter();
|
const filter = narrow_state.filter();
|
||||||
if (filter === undefined && recent_topics.is_visible()) {
|
if (filter === undefined && recent_topics.is_visible()) {
|
||||||
// user moved away from the narrow / filter to recent topics.
|
// user moved away from the narrow / filter to recent topics.
|
||||||
|
@ -146,13 +150,13 @@ export function scroll_finished() {
|
||||||
|
|
||||||
if (message_viewport.at_top()) {
|
if (message_viewport.at_top()) {
|
||||||
message_fetch.maybe_load_older_messages({
|
message_fetch.maybe_load_older_messages({
|
||||||
msg_list: current_msg_list,
|
msg_list: message_lists.current,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message_viewport.at_bottom()) {
|
if (message_viewport.at_bottom()) {
|
||||||
message_fetch.maybe_load_newer_messages({
|
message_fetch.maybe_load_newer_messages({
|
||||||
msg_list: current_msg_list,
|
msg_list: message_lists.current,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -2,6 +2,7 @@ import $ from "jquery";
|
||||||
|
|
||||||
import * as blueslip from "./blueslip";
|
import * as blueslip from "./blueslip";
|
||||||
import {media_breakpoints} from "./css_variables";
|
import {media_breakpoints} from "./css_variables";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_scroll from "./message_scroll";
|
import * as message_scroll from "./message_scroll";
|
||||||
import * as rows from "./rows";
|
import * as rows from "./rows";
|
||||||
import * as util from "./util";
|
import * as util from "./util";
|
||||||
|
@ -237,7 +238,7 @@ function _visible_divs(
|
||||||
}
|
}
|
||||||
|
|
||||||
export function visible_groups(require_fully_visible) {
|
export function visible_groups(require_fully_visible) {
|
||||||
const selected_row = current_msg_list.selected_row();
|
const selected_row = message_lists.current.selected_row();
|
||||||
if (selected_row === undefined || selected_row.length === 0) {
|
if (selected_row === undefined || selected_row.length === 0) {
|
||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
|
@ -253,10 +254,10 @@ export function visible_groups(require_fully_visible) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function visible_messages(require_fully_visible) {
|
export function visible_messages(require_fully_visible) {
|
||||||
const selected_row = current_msg_list.selected_row();
|
const selected_row = message_lists.current.selected_row();
|
||||||
|
|
||||||
function row_to_id(row) {
|
function row_to_id(row) {
|
||||||
return current_msg_list.get(rows.id($(row)));
|
return message_lists.current.get(rows.id($(row)));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Being simplistic about this, the smallest message is 25 px high.
|
// Being simplistic about this, the smallest message is 25 px high.
|
||||||
|
@ -387,7 +388,7 @@ export function keep_pointer_in_view() {
|
||||||
// users will occasionally do big mouse scrolls, so this gives them
|
// users will occasionally do big mouse scrolls, so this gives them
|
||||||
// a pointer reasonably close to the middle of the screen.
|
// a pointer reasonably close to the middle of the screen.
|
||||||
let candidate;
|
let candidate;
|
||||||
let next_row = current_msg_list.selected_row();
|
let next_row = message_lists.current.selected_row();
|
||||||
|
|
||||||
if (next_row.length === 0) {
|
if (next_row.length === 0) {
|
||||||
return;
|
return;
|
||||||
|
@ -446,7 +447,7 @@ export function keep_pointer_in_view() {
|
||||||
adjust(message_is_far_enough_up, rows.prev_visible);
|
adjust(message_is_far_enough_up, rows.prev_visible);
|
||||||
}
|
}
|
||||||
|
|
||||||
current_msg_list.select_id(rows.id(next_row), {from_scroll: true});
|
message_lists.current.select_id(rows.id(next_row), {from_scroll: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function initialize() {
|
export function initialize() {
|
||||||
|
|
|
@ -7,6 +7,7 @@ import * as channel from "./channel";
|
||||||
import * as feedback_widget from "./feedback_widget";
|
import * as feedback_widget from "./feedback_widget";
|
||||||
import {i18n} from "./i18n";
|
import {i18n} from "./i18n";
|
||||||
import * as ListWidget from "./list_widget";
|
import * as ListWidget from "./list_widget";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as muting from "./muting";
|
import * as muting from "./muting";
|
||||||
import * as overlays from "./overlays";
|
import * as overlays from "./overlays";
|
||||||
import * as recent_topics from "./recent_topics";
|
import * as recent_topics from "./recent_topics";
|
||||||
|
@ -30,11 +31,11 @@ export function rerender_on_topic_update() {
|
||||||
// re-doing a mute or unmute is a pretty recoverable thing.
|
// re-doing a mute or unmute is a pretty recoverable thing.
|
||||||
|
|
||||||
stream_list.update_streams_sidebar();
|
stream_list.update_streams_sidebar();
|
||||||
if (current_msg_list.excludes_muted_topics) {
|
if (message_lists.current.excludes_muted_topics) {
|
||||||
current_msg_list.update_muting_and_rerender();
|
message_lists.current.update_muting_and_rerender();
|
||||||
}
|
}
|
||||||
if (current_msg_list !== home_msg_list) {
|
if (message_lists.current !== message_lists.home) {
|
||||||
home_msg_list.update_muting_and_rerender();
|
message_lists.home.update_muting_and_rerender();
|
||||||
}
|
}
|
||||||
if (overlays.settings_open() && settings_muting.loaded) {
|
if (overlays.settings_open() && settings_muting.loaded) {
|
||||||
set_up_muted_topics_ui();
|
set_up_muted_topics_ui();
|
||||||
|
|
|
@ -13,6 +13,7 @@ import * as message_edit from "./message_edit";
|
||||||
import * as message_fetch from "./message_fetch";
|
import * as message_fetch from "./message_fetch";
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
import {MessageListData} from "./message_list_data";
|
import {MessageListData} from "./message_list_data";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_scroll from "./message_scroll";
|
import * as message_scroll from "./message_scroll";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as message_view_header from "./message_view_header";
|
import * as message_view_header from "./message_view_header";
|
||||||
|
@ -93,19 +94,19 @@ function report_unnarrow_time() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function save_pre_narrow_offset_for_reload() {
|
export function save_pre_narrow_offset_for_reload() {
|
||||||
if (current_msg_list.selected_id() !== -1) {
|
if (message_lists.current.selected_id() !== -1) {
|
||||||
if (current_msg_list.selected_row().length === 0) {
|
if (message_lists.current.selected_row().length === 0) {
|
||||||
blueslip.debug("narrow.activate missing selected row", {
|
blueslip.debug("narrow.activate missing selected row", {
|
||||||
selected_id: current_msg_list.selected_id(),
|
selected_id: message_lists.current.selected_id(),
|
||||||
selected_idx: current_msg_list.selected_idx(),
|
selected_idx: message_lists.current.selected_idx(),
|
||||||
selected_idx_exact: current_msg_list
|
selected_idx_exact: message_lists.current
|
||||||
.all_messages()
|
.all_messages()
|
||||||
.indexOf(current_msg_list.get(current_msg_list.selected_id())),
|
.indexOf(message_lists.current.get(message_lists.current.selected_id())),
|
||||||
render_start: current_msg_list.view._render_win_start,
|
render_start: message_lists.current.view._render_win_start,
|
||||||
render_end: current_msg_list.view._render_win_end,
|
render_end: message_lists.current.view._render_win_end,
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
current_msg_list.pre_narrow_offset = current_msg_list.selected_row().offset().top;
|
message_lists.current.pre_narrow_offset = message_lists.current.selected_row().offset().top;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -152,7 +153,7 @@ function update_narrow_title(filter) {
|
||||||
export function activate(raw_operators, opts) {
|
export function activate(raw_operators, opts) {
|
||||||
/* Main entrypoint for switching to a new view / message list.
|
/* Main entrypoint for switching to a new view / message list.
|
||||||
Note that for historical reasons related to the current
|
Note that for historical reasons related to the current
|
||||||
client-side caching structure, the "All messages"/home_msg_list
|
client-side caching structure, the "All messages"/message_lists.home
|
||||||
view is reached via `narrow.deactivate()`.
|
view is reached via `narrow.deactivate()`.
|
||||||
|
|
||||||
The name is based on "narrowing to a subset of the user's
|
The name is based on "narrowing to a subset of the user's
|
||||||
|
@ -160,7 +161,7 @@ export function activate(raw_operators, opts) {
|
||||||
|
|
||||||
raw_operators: Narrowing/search operators; used to construct
|
raw_operators: Narrowing/search operators; used to construct
|
||||||
a Filter object that decides which messages belong in the
|
a Filter object that decides which messages belong in the
|
||||||
view. Required (See the above note on how `home_msg_list` works)
|
view. Required (See the above note on how `message_lists.home` works)
|
||||||
|
|
||||||
All other options are encoded via the `opts` dictionary:
|
All other options are encoded via the `opts` dictionary:
|
||||||
|
|
||||||
|
@ -213,7 +214,7 @@ export function activate(raw_operators, opts) {
|
||||||
blueslip.debug("Narrowed", {
|
blueslip.debug("Narrowed", {
|
||||||
operators: operators.map((e) => e.operator),
|
operators: operators.map((e) => e.operator),
|
||||||
trigger: opts ? opts.trigger : undefined,
|
trigger: opts ? opts.trigger : undefined,
|
||||||
previous_id: current_msg_list.selected_id(),
|
previous_id: message_lists.current.selected_id(),
|
||||||
});
|
});
|
||||||
|
|
||||||
opts = {
|
opts = {
|
||||||
|
@ -244,7 +245,7 @@ export function activate(raw_operators, opts) {
|
||||||
// having a near: narrow auto-reloaded.
|
// having a near: narrow auto-reloaded.
|
||||||
id_info.target_id = opts.then_select_id;
|
id_info.target_id = opts.then_select_id;
|
||||||
if (opts.then_select_offset === undefined) {
|
if (opts.then_select_offset === undefined) {
|
||||||
const row = current_msg_list.get_row(opts.then_select_id);
|
const row = message_lists.current.get_row(opts.then_select_id);
|
||||||
if (row.length > 0) {
|
if (row.length > 0) {
|
||||||
opts.then_select_offset = row.offset().top;
|
opts.then_select_offset = row.offset().top;
|
||||||
}
|
}
|
||||||
|
@ -301,8 +302,8 @@ export function activate(raw_operators, opts) {
|
||||||
|
|
||||||
msg_list.start_time = start_time;
|
msg_list.start_time = start_time;
|
||||||
|
|
||||||
// Show the new set of messages. It is important to set current_msg_list to
|
// Show the new set of messages. It is important to set message_lists.current to
|
||||||
// the view right as it's being shown, because we rely on current_msg_list
|
// the view right as it's being shown, because we rely on message_lists.current
|
||||||
// being shown for deciding when to condense messages.
|
// being shown for deciding when to condense messages.
|
||||||
$("body").addClass("narrowed_view");
|
$("body").addClass("narrowed_view");
|
||||||
$("#zfilt").addClass("focused_table");
|
$("#zfilt").addClass("focused_table");
|
||||||
|
@ -310,7 +311,7 @@ export function activate(raw_operators, opts) {
|
||||||
|
|
||||||
ui_util.change_tab_to("#message_feed_container");
|
ui_util.change_tab_to("#message_feed_container");
|
||||||
message_list.set_narrowed(msg_list);
|
message_list.set_narrowed(msg_list);
|
||||||
current_msg_list = message_list.narrowed;
|
message_lists.set_current(message_list.narrowed);
|
||||||
|
|
||||||
let then_select_offset;
|
let then_select_offset;
|
||||||
if (id_info.target_id === id_info.final_select_id) {
|
if (id_info.target_id === id_info.final_select_id) {
|
||||||
|
@ -701,7 +702,7 @@ export function by(operator, operand, opts) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function by_topic(target_id, opts) {
|
export function by_topic(target_id, opts) {
|
||||||
// don't use current_msg_list as it won't work for muted messages or for out-of-narrow links
|
// don't use message_lists.current as it won't work for muted messages or for out-of-narrow links
|
||||||
const original = message_store.get(target_id);
|
const original = message_store.get(target_id);
|
||||||
if (original.type !== "stream") {
|
if (original.type !== "stream") {
|
||||||
// Only stream messages have topics, but the
|
// Only stream messages have topics, but the
|
||||||
|
@ -726,7 +727,7 @@ export function by_topic(target_id, opts) {
|
||||||
// Called for the 'narrow by stream' hotkey.
|
// Called for the 'narrow by stream' hotkey.
|
||||||
export function by_recipient(target_id, opts) {
|
export function by_recipient(target_id, opts) {
|
||||||
opts = {then_select_id: target_id, ...opts};
|
opts = {then_select_id: target_id, ...opts};
|
||||||
// don't use current_msg_list as it won't work for muted messages or for out-of-narrow links
|
// don't use message_lists.current as it won't work for muted messages or for out-of-narrow links
|
||||||
const message = message_store.get(target_id);
|
const message = message_store.get(target_id);
|
||||||
|
|
||||||
// We don't check msg_list.can_mark_messages_read here only because
|
// We don't check msg_list.can_mark_messages_read here only because
|
||||||
|
@ -805,7 +806,7 @@ function handle_post_narrow_deactivate_processes() {
|
||||||
narrow_title = "All messages";
|
narrow_title = "All messages";
|
||||||
notifications.redraw_title();
|
notifications.redraw_title();
|
||||||
message_scroll.hide_top_of_narrow_notices();
|
message_scroll.hide_top_of_narrow_notices();
|
||||||
message_scroll.update_top_of_narrow_notices(home_msg_list);
|
message_scroll.update_top_of_narrow_notices(message_lists.home);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function deactivate(coming_from_recent_topics = false) {
|
export function deactivate(coming_from_recent_topics = false) {
|
||||||
|
@ -813,16 +814,16 @@ export function deactivate(coming_from_recent_topics = false) {
|
||||||
// always use browser_history.go_to_location("#all_messages") to
|
// always use browser_history.go_to_location("#all_messages") to
|
||||||
// activate All message narrow.
|
// activate All message narrow.
|
||||||
/*
|
/*
|
||||||
Switches current_msg_list from narrowed_msg_list to
|
Switches message_lists.current from narrowed_msg_list to
|
||||||
home_msg_list ("All messages"), ending the current narrow. This
|
message_lists.home ("All messages"), ending the current narrow. This
|
||||||
is a very fast operation, because we keep home_msg_list's data
|
is a very fast operation, because we keep message_lists.home's data
|
||||||
cached and updated in the DOM at all times, making it suitable
|
cached and updated in the DOM at all times, making it suitable
|
||||||
for rapid access via keyboard shortcuts.
|
for rapid access via keyboard shortcuts.
|
||||||
|
|
||||||
Long-term, we will likely want to make `home_msg_list` not
|
Long-term, we will likely want to make `message_lists.home` not
|
||||||
special in any way, and instead just have a generic
|
special in any way, and instead just have a generic
|
||||||
message_list_data structure caching system that happens to have
|
message_list_data structure caching system that happens to have
|
||||||
home_msg_list in it.
|
message_lists.home in it.
|
||||||
*/
|
*/
|
||||||
search.clear_search_form();
|
search.clear_search_form();
|
||||||
// Both All messages and Recent Topics have `undefined` filter.
|
// Both All messages and Recent Topics have `undefined` filter.
|
||||||
|
@ -852,16 +853,16 @@ export function deactivate(coming_from_recent_topics = false) {
|
||||||
$("body").removeClass("narrowed_view");
|
$("body").removeClass("narrowed_view");
|
||||||
$("#zfilt").removeClass("focused_table");
|
$("#zfilt").removeClass("focused_table");
|
||||||
$("#zhome").addClass("focused_table");
|
$("#zhome").addClass("focused_table");
|
||||||
current_msg_list = home_msg_list;
|
message_lists.set_current(message_lists.home);
|
||||||
condense.condense_and_collapse($("#zhome div.message_row"));
|
condense.condense_and_collapse($("#zhome div.message_row"));
|
||||||
|
|
||||||
message_scroll.hide_indicators();
|
message_scroll.hide_indicators();
|
||||||
hashchange.save_narrow();
|
hashchange.save_narrow();
|
||||||
|
|
||||||
if (current_msg_list.selected_id() !== -1) {
|
if (message_lists.current.selected_id() !== -1) {
|
||||||
const preserve_pre_narrowing_screen_position =
|
const preserve_pre_narrowing_screen_position =
|
||||||
current_msg_list.selected_row().length > 0 &&
|
message_lists.current.selected_row().length > 0 &&
|
||||||
current_msg_list.pre_narrow_offset !== undefined;
|
message_lists.current.pre_narrow_offset !== undefined;
|
||||||
let message_id_to_select;
|
let message_id_to_select;
|
||||||
const select_opts = {
|
const select_opts = {
|
||||||
then_scroll: true,
|
then_scroll: true,
|
||||||
|
@ -878,7 +879,7 @@ export function deactivate(coming_from_recent_topics = false) {
|
||||||
// We read some unread messages in a narrow. Instead of going back to
|
// We read some unread messages in a narrow. Instead of going back to
|
||||||
// where we were before the narrow, go to our first unread message (or
|
// where we were before the narrow, go to our first unread message (or
|
||||||
// the bottom of the feed, if there are no unread messages).
|
// the bottom of the feed, if there are no unread messages).
|
||||||
message_id_to_select = current_msg_list.first_unread_message_id();
|
message_id_to_select = message_lists.current.first_unread_message_id();
|
||||||
} else {
|
} else {
|
||||||
// We narrowed, but only backwards in time (ie no unread were read). Try
|
// We narrowed, but only backwards in time (ie no unread were read). Try
|
||||||
// to go back to exactly where we were before narrowing.
|
// to go back to exactly where we were before narrowing.
|
||||||
|
@ -886,11 +887,11 @@ export function deactivate(coming_from_recent_topics = false) {
|
||||||
// We scroll the user back to exactly the offset from the selected
|
// We scroll the user back to exactly the offset from the selected
|
||||||
// message that they were at the time that they narrowed.
|
// message that they were at the time that they narrowed.
|
||||||
// TODO: Make this correctly handle the case of resizing while narrowed.
|
// TODO: Make this correctly handle the case of resizing while narrowed.
|
||||||
select_opts.target_scroll_offset = current_msg_list.pre_narrow_offset;
|
select_opts.target_scroll_offset = message_lists.current.pre_narrow_offset;
|
||||||
}
|
}
|
||||||
message_id_to_select = current_msg_list.selected_id();
|
message_id_to_select = message_lists.current.selected_id();
|
||||||
}
|
}
|
||||||
current_msg_list.select_id(message_id_to_select, select_opts);
|
message_lists.current.select_id(message_id_to_select, select_opts);
|
||||||
}
|
}
|
||||||
|
|
||||||
handle_post_narrow_deactivate_processes();
|
handle_post_narrow_deactivate_processes();
|
||||||
|
|
|
@ -1,14 +1,15 @@
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as rows from "./rows";
|
import * as rows from "./rows";
|
||||||
import * as unread_ops from "./unread_ops";
|
import * as unread_ops from "./unread_ops";
|
||||||
|
|
||||||
function go_to_row(msg_id) {
|
function go_to_row(msg_id) {
|
||||||
current_msg_list.select_id(msg_id, {then_scroll: true, from_scroll: true});
|
message_lists.current.select_id(msg_id, {then_scroll: true, from_scroll: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function up() {
|
export function up() {
|
||||||
message_viewport.set_last_movement_direction(-1);
|
message_viewport.set_last_movement_direction(-1);
|
||||||
const msg_id = current_msg_list.prev();
|
const msg_id = message_lists.current.prev();
|
||||||
if (msg_id === undefined) {
|
if (msg_id === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -18,15 +19,15 @@ export function up() {
|
||||||
export function down(with_centering) {
|
export function down(with_centering) {
|
||||||
message_viewport.set_last_movement_direction(1);
|
message_viewport.set_last_movement_direction(1);
|
||||||
|
|
||||||
if (current_msg_list.is_at_end()) {
|
if (message_lists.current.is_at_end()) {
|
||||||
if (with_centering) {
|
if (with_centering) {
|
||||||
// At the last message, scroll to the bottom so we have
|
// At the last message, scroll to the bottom so we have
|
||||||
// lots of nice whitespace for new messages coming in.
|
// lots of nice whitespace for new messages coming in.
|
||||||
const current_msg_table = rows.get_table(current_msg_list.table_name);
|
const current_msg_table = rows.get_table(message_lists.current.table_name);
|
||||||
message_viewport.scrollTop(
|
message_viewport.scrollTop(
|
||||||
current_msg_table.safeOuterHeight(true) - message_viewport.height() * 0.1,
|
current_msg_table.safeOuterHeight(true) - message_viewport.height() * 0.1,
|
||||||
);
|
);
|
||||||
if (current_msg_list.can_mark_messages_read()) {
|
if (message_lists.current.can_mark_messages_read()) {
|
||||||
unread_ops.mark_current_list_as_read();
|
unread_ops.mark_current_list_as_read();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,7 +36,7 @@ export function down(with_centering) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Normal path starts here.
|
// Normal path starts here.
|
||||||
const msg_id = current_msg_list.next();
|
const msg_id = message_lists.current.next();
|
||||||
if (msg_id === undefined) {
|
if (msg_id === undefined) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -44,15 +45,15 @@ export function down(with_centering) {
|
||||||
|
|
||||||
export function to_home() {
|
export function to_home() {
|
||||||
message_viewport.set_last_movement_direction(-1);
|
message_viewport.set_last_movement_direction(-1);
|
||||||
const first_id = current_msg_list.first().id;
|
const first_id = message_lists.current.first().id;
|
||||||
current_msg_list.select_id(first_id, {then_scroll: true, from_scroll: true});
|
message_lists.current.select_id(first_id, {then_scroll: true, from_scroll: true});
|
||||||
}
|
}
|
||||||
|
|
||||||
export function to_end() {
|
export function to_end() {
|
||||||
const next_id = current_msg_list.last().id;
|
const next_id = message_lists.current.last().id;
|
||||||
message_viewport.set_last_movement_direction(1);
|
message_viewport.set_last_movement_direction(1);
|
||||||
current_msg_list.select_id(next_id, {then_scroll: true, from_scroll: true});
|
message_lists.current.select_id(next_id, {then_scroll: true, from_scroll: true});
|
||||||
if (current_msg_list.can_mark_messages_read()) {
|
if (message_lists.current.can_mark_messages_read()) {
|
||||||
unread_ops.mark_current_list_as_read();
|
unread_ops.mark_current_list_as_read();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -104,17 +105,17 @@ export function page_down_the_right_amount() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function page_up() {
|
export function page_up() {
|
||||||
if (message_viewport.at_top() && !current_msg_list.empty()) {
|
if (message_viewport.at_top() && !message_lists.current.empty()) {
|
||||||
current_msg_list.select_id(current_msg_list.first().id, {then_scroll: false});
|
message_lists.current.select_id(message_lists.current.first().id, {then_scroll: false});
|
||||||
} else {
|
} else {
|
||||||
page_up_the_right_amount();
|
page_up_the_right_amount();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function page_down() {
|
export function page_down() {
|
||||||
if (message_viewport.at_bottom() && !current_msg_list.empty()) {
|
if (message_viewport.at_bottom() && !message_lists.current.empty()) {
|
||||||
current_msg_list.select_id(current_msg_list.last().id, {then_scroll: false});
|
message_lists.current.select_id(message_lists.current.last().id, {then_scroll: false});
|
||||||
if (current_msg_list.can_mark_messages_read()) {
|
if (message_lists.current.can_mark_messages_read()) {
|
||||||
unread_ops.mark_current_list_as_read();
|
unread_ops.mark_current_list_as_read();
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -123,7 +124,7 @@ export function page_down() {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function scroll_to_selected() {
|
export function scroll_to_selected() {
|
||||||
const selected_row = current_msg_list.selected_row();
|
const selected_row = message_lists.current.selected_row();
|
||||||
if (selected_row && selected_row.length !== 0) {
|
if (selected_row && selected_row.length !== 0) {
|
||||||
message_viewport.recenter_view(selected_row);
|
message_viewport.recenter_view(selected_row);
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,6 +8,7 @@ import * as blueslip from "./blueslip";
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as favicon from "./favicon";
|
import * as favicon from "./favicon";
|
||||||
import {i18n} from "./i18n";
|
import {i18n} from "./i18n";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import * as muting from "./muting";
|
import * as muting from "./muting";
|
||||||
import * as narrow from "./narrow";
|
import * as narrow from "./narrow";
|
||||||
|
@ -519,7 +520,7 @@ function get_message_header(message) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function get_local_notify_mix_reason(message) {
|
export function get_local_notify_mix_reason(message) {
|
||||||
const row = current_msg_list.get_row(message.id);
|
const row = message_lists.current.get_row(message.id);
|
||||||
if (row.length > 0) {
|
if (row.length > 0) {
|
||||||
// If our message is in the current message list, we do
|
// If our message is in the current message list, we do
|
||||||
// not have a mix, so we are happy.
|
// not have a mix, so we are happy.
|
||||||
|
@ -605,7 +606,7 @@ export function notify_local_mixes(messages, need_user_to_scroll) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// for callback when we have to check with the server if a message should be in
|
// for callback when we have to check with the server if a message should be in
|
||||||
// the current_msg_list (!can_apply_locally; a.k.a. "a search").
|
// the message_lists.current (!can_apply_locally; a.k.a. "a search").
|
||||||
export function notify_messages_outside_current_search(messages) {
|
export function notify_messages_outside_current_search(messages) {
|
||||||
for (const message of messages) {
|
for (const message of messages) {
|
||||||
if (!people.is_current_user(message.sender_email)) {
|
if (!people.is_current_user(message.sender_email)) {
|
||||||
|
@ -654,7 +655,7 @@ export function register_click_handlers() {
|
||||||
});
|
});
|
||||||
$("#out-of-view-notification").on("click", ".compose_notification_scroll_to_message", (e) => {
|
$("#out-of-view-notification").on("click", ".compose_notification_scroll_to_message", (e) => {
|
||||||
const message_id = $(e.currentTarget).data("message-id");
|
const message_id = $(e.currentTarget).data("message-id");
|
||||||
current_msg_list.select_id(message_id);
|
message_lists.current.select_id(message_id);
|
||||||
navigate.scroll_to_selected();
|
navigate.scroll_to_selected();
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
e.preventDefault();
|
e.preventDefault();
|
||||||
|
|
|
@ -27,6 +27,7 @@ import * as hash_util from "./hash_util";
|
||||||
import {i18n} from "./i18n";
|
import {i18n} from "./i18n";
|
||||||
import * as message_edit from "./message_edit";
|
import * as message_edit from "./message_edit";
|
||||||
import * as message_edit_history from "./message_edit_history";
|
import * as message_edit_history from "./message_edit_history";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as muting from "./muting";
|
import * as muting from "./muting";
|
||||||
import * as muting_ui from "./muting_ui";
|
import * as muting_ui from "./muting_ui";
|
||||||
|
@ -309,7 +310,7 @@ function show_user_info_popover_for_message(element, user, message) {
|
||||||
// by clicking on the same element that caused the popover.
|
// by clicking on the same element that caused the popover.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
current_msg_list.select_id(message.id);
|
message_lists.current.select_id(message.id);
|
||||||
const elt = $(element);
|
const elt = $(element);
|
||||||
if (elt.data("popover") === undefined) {
|
if (elt.data("popover") === undefined) {
|
||||||
if (user === undefined) {
|
if (user === undefined) {
|
||||||
|
@ -487,7 +488,7 @@ function show_user_group_info_popover(element, group, message) {
|
||||||
// by clicking on the same element that caused the popover.
|
// by clicking on the same element that caused the popover.
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
current_msg_list.select_id(message.id);
|
message_lists.current.select_id(message.id);
|
||||||
const elt = $(element);
|
const elt = $(element);
|
||||||
if (elt.data("popover") === undefined) {
|
if (elt.data("popover") === undefined) {
|
||||||
const args = {
|
const args = {
|
||||||
|
@ -517,10 +518,10 @@ export function toggle_actions_popover(element, id) {
|
||||||
}
|
}
|
||||||
|
|
||||||
$(element).closest(".message_row").toggleClass("has_popover has_actions_popover");
|
$(element).closest(".message_row").toggleClass("has_popover has_actions_popover");
|
||||||
current_msg_list.select_id(id);
|
message_lists.current.select_id(id);
|
||||||
const elt = $(element);
|
const elt = $(element);
|
||||||
if (elt.data("popover") === undefined) {
|
if (elt.data("popover") === undefined) {
|
||||||
const message = current_msg_list.get(id);
|
const message = message_lists.current.get(id);
|
||||||
const editability = message_edit.get_editability(message);
|
const editability = message_edit.get_editability(message);
|
||||||
let use_edit_icon;
|
let use_edit_icon;
|
||||||
let editability_menu_item;
|
let editability_menu_item;
|
||||||
|
@ -604,10 +605,10 @@ export function toggle_actions_popover(element, id) {
|
||||||
export function render_actions_remind_popover(element, id) {
|
export function render_actions_remind_popover(element, id) {
|
||||||
hide_all();
|
hide_all();
|
||||||
$(element).closest(".message_row").toggleClass("has_popover has_actions_popover");
|
$(element).closest(".message_row").toggleClass("has_popover has_actions_popover");
|
||||||
current_msg_list.select_id(id);
|
message_lists.current.select_id(id);
|
||||||
const elt = $(element);
|
const elt = $(element);
|
||||||
if (elt.data("popover") === undefined) {
|
if (elt.data("popover") === undefined) {
|
||||||
const message = current_msg_list.get(id);
|
const message = message_lists.current.get(id);
|
||||||
const args = {
|
const args = {
|
||||||
message,
|
message,
|
||||||
};
|
};
|
||||||
|
@ -818,7 +819,7 @@ export function show_sender_info() {
|
||||||
const $message = $(".selected_message");
|
const $message = $(".selected_message");
|
||||||
const $sender = $message.find(".sender_info_hover");
|
const $sender = $message.find(".sender_info_hover");
|
||||||
|
|
||||||
const message = current_msg_list.get(rows.id($message));
|
const message = message_lists.current.get(rows.id($message));
|
||||||
const user = people.get_by_user_id(message.sender_id);
|
const user = people.get_by_user_id(message.sender_id);
|
||||||
show_user_info_popover_for_message($sender[0], user, message);
|
show_user_info_popover_for_message($sender[0], user, message);
|
||||||
if (current_message_info_popover_elem) {
|
if (current_message_info_popover_elem) {
|
||||||
|
@ -885,7 +886,7 @@ export function register_click_handlers() {
|
||||||
function (e) {
|
function (e) {
|
||||||
const row = $(this).closest(".message_row");
|
const row = $(this).closest(".message_row");
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
const user = people.get_by_user_id(message.sender_id);
|
const user = people.get_by_user_id(message.sender_id);
|
||||||
show_user_info_popover_for_message(this, user, message);
|
show_user_info_popover_for_message(this, user, message);
|
||||||
},
|
},
|
||||||
|
@ -901,7 +902,7 @@ export function register_click_handlers() {
|
||||||
}
|
}
|
||||||
const row = $(this).closest(".message_row");
|
const row = $(this).closest(".message_row");
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
let user;
|
let user;
|
||||||
if (id_string) {
|
if (id_string) {
|
||||||
const user_id = Number.parseInt(id_string, 10);
|
const user_id = Number.parseInt(id_string, 10);
|
||||||
|
@ -916,7 +917,7 @@ export function register_click_handlers() {
|
||||||
const user_group_id = Number.parseInt($(this).attr("data-user-group-id"), 10);
|
const user_group_id = Number.parseInt($(this).attr("data-user-group-id"), 10);
|
||||||
const row = $(this).closest(".message_row");
|
const row = $(this).closest(".message_row");
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
const group = user_groups.get_user_group_from_id(user_group_id, true);
|
const group = user_groups.get_user_group_from_id(user_group_id, true);
|
||||||
if (group === undefined) {
|
if (group === undefined) {
|
||||||
// This user group has likely been deleted.
|
// This user group has likely been deleted.
|
||||||
|
@ -1204,8 +1205,8 @@ export function register_click_handlers() {
|
||||||
});
|
});
|
||||||
$("body").on("click", ".popover_toggle_collapse", (e) => {
|
$("body").on("click", ".popover_toggle_collapse", (e) => {
|
||||||
const message_id = $(e.currentTarget).data("message-id");
|
const message_id = $(e.currentTarget).data("message-id");
|
||||||
const row = current_msg_list.get_row(message_id);
|
const row = message_lists.current.get_row(message_id);
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
|
|
||||||
hide_actions_popover();
|
hide_actions_popover();
|
||||||
|
|
||||||
|
@ -1222,7 +1223,7 @@ export function register_click_handlers() {
|
||||||
});
|
});
|
||||||
$("body").on("click", ".popover_edit_message", (e) => {
|
$("body").on("click", ".popover_edit_message", (e) => {
|
||||||
const message_id = $(e.currentTarget).data("message-id");
|
const message_id = $(e.currentTarget).data("message-id");
|
||||||
const row = current_msg_list.get_row(message_id);
|
const row = message_lists.current.get_row(message_id);
|
||||||
hide_actions_popover();
|
hide_actions_popover();
|
||||||
message_edit.start(row);
|
message_edit.start(row);
|
||||||
e.stopPropagation();
|
e.stopPropagation();
|
||||||
|
@ -1230,8 +1231,8 @@ export function register_click_handlers() {
|
||||||
});
|
});
|
||||||
$("body").on("click", ".view_edit_history", (e) => {
|
$("body").on("click", ".view_edit_history", (e) => {
|
||||||
const message_id = $(e.currentTarget).data("message-id");
|
const message_id = $(e.currentTarget).data("message-id");
|
||||||
const row = current_msg_list.get_row(message_id);
|
const row = message_lists.current.get_row(message_id);
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
const message_history_cancel_btn = $("#message-history-cancel");
|
const message_history_cancel_btn = $("#message-history-cancel");
|
||||||
|
|
||||||
hide_actions_popover();
|
hide_actions_popover();
|
||||||
|
|
|
@ -8,6 +8,7 @@ import * as blueslip from "./blueslip";
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as emoji_picker from "./emoji_picker";
|
import * as emoji_picker from "./emoji_picker";
|
||||||
import {i18n} from "./i18n";
|
import {i18n} from "./i18n";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
|
@ -19,17 +20,17 @@ export function get_local_reaction_id(reaction_info) {
|
||||||
}
|
}
|
||||||
|
|
||||||
export function open_reactions_popover() {
|
export function open_reactions_popover() {
|
||||||
const message = current_msg_list.selected_message();
|
const message = message_lists.current.selected_message();
|
||||||
let target;
|
let target;
|
||||||
|
|
||||||
// Use verbose style to ensure we test both sides of the condition.
|
// Use verbose style to ensure we test both sides of the condition.
|
||||||
if (message.sent_by_me) {
|
if (message.sent_by_me) {
|
||||||
target = $(current_msg_list.selected_row()).find(".actions_hover")[0];
|
target = $(message_lists.current.selected_row()).find(".actions_hover")[0];
|
||||||
} else {
|
} else {
|
||||||
target = $(current_msg_list.selected_row()).find(".reaction_button")[0];
|
target = $(message_lists.current.selected_row()).find(".reaction_button")[0];
|
||||||
}
|
}
|
||||||
|
|
||||||
emoji_picker.toggle_emoji_popover(target, current_msg_list.selected_id());
|
emoji_picker.toggle_emoji_popover(target, message_lists.current.selected_id());
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,6 +9,7 @@ import {csrf_token} from "./csrf";
|
||||||
import * as hashchange from "./hashchange";
|
import * as hashchange from "./hashchange";
|
||||||
import {localstorage} from "./localstorage";
|
import {localstorage} from "./localstorage";
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
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";
|
||||||
import * as reload_state from "./reload_state";
|
import * as reload_state from "./reload_state";
|
||||||
|
@ -51,20 +52,20 @@ function preserve_state(send_after_reload, save_pointer, save_narrow, save_compo
|
||||||
}
|
}
|
||||||
|
|
||||||
if (save_pointer) {
|
if (save_pointer) {
|
||||||
const pointer = home_msg_list.selected_id();
|
const pointer = message_lists.home.selected_id();
|
||||||
if (pointer !== -1) {
|
if (pointer !== -1) {
|
||||||
url += "+pointer=" + pointer;
|
url += "+pointer=" + pointer;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (save_narrow) {
|
if (save_narrow) {
|
||||||
const row = home_msg_list.selected_row();
|
const row = message_lists.home.selected_row();
|
||||||
if (!narrow_state.active()) {
|
if (!narrow_state.active()) {
|
||||||
if (row.length > 0) {
|
if (row.length > 0) {
|
||||||
url += "+offset=" + row.offset().top;
|
url += "+offset=" + row.offset().top;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
url += "+offset=" + home_msg_list.pre_narrow_offset;
|
url += "+offset=" + message_lists.home.pre_narrow_offset;
|
||||||
|
|
||||||
const narrow_pointer = message_list.narrowed.selected_id();
|
const narrow_pointer = message_list.narrowed.selected_id();
|
||||||
if (narrow_pointer !== -1) {
|
if (narrow_pointer !== -1) {
|
||||||
|
|
|
@ -4,6 +4,7 @@ import * as channel from "./channel";
|
||||||
import * as compose from "./compose";
|
import * as compose from "./compose";
|
||||||
import * as hash_util from "./hash_util";
|
import * as hash_util from "./hash_util";
|
||||||
import {i18n} from "./i18n";
|
import {i18n} from "./i18n";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as notifications from "./notifications";
|
import * as notifications from "./notifications";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as people from "./people";
|
import * as people from "./people";
|
||||||
|
@ -117,15 +118,15 @@ export function do_set_reminder_for_message(message_id, timestamp) {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = current_msg_list.get(message_id);
|
const message = message_lists.current.get(message_id);
|
||||||
|
|
||||||
if (!message.raw_content) {
|
if (!message.raw_content) {
|
||||||
const msg_list = current_msg_list;
|
const msg_list = message_lists.current;
|
||||||
channel.get({
|
channel.get({
|
||||||
url: "/json/messages/" + message.id,
|
url: "/json/messages/" + message.id,
|
||||||
idempotent: true,
|
idempotent: true,
|
||||||
success(data) {
|
success(data) {
|
||||||
if (current_msg_list === msg_list) {
|
if (message_lists.current === msg_list) {
|
||||||
message.raw_content = data.raw_content;
|
message.raw_content = data.raw_content;
|
||||||
do_set_reminder_for_message(message_id, timestamp);
|
do_set_reminder_for_message(message_id, timestamp);
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import $ from "jquery";
|
||||||
|
|
||||||
import * as blueslip from "./blueslip";
|
import * as blueslip from "./blueslip";
|
||||||
import * as condense from "./condense";
|
import * as condense from "./condense";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
import * as navigate from "./navigate";
|
import * as navigate from "./navigate";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
|
@ -243,7 +244,7 @@ export function handler() {
|
||||||
// This function might run onReady (if we're in a narrow window),
|
// This function might run onReady (if we're in a narrow window),
|
||||||
// but before we've loaded in the messages; in that case, don't
|
// but before we've loaded in the messages; in that case, don't
|
||||||
// try to scroll to one.
|
// try to scroll to one.
|
||||||
if (current_msg_list.selected_id() !== -1) {
|
if (message_lists.current.selected_id() !== -1) {
|
||||||
if (mobile) {
|
if (mobile) {
|
||||||
popovers.set_suppress_scroll_hide();
|
popovers.set_suppress_scroll_hide();
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
|
|
||||||
import * as blueslip from "./blueslip";
|
import * as blueslip from "./blueslip";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
// We don't need an andSelf() here because we already know
|
// We don't need an andSelf() here because we already know
|
||||||
// that our next element is *not* a message_row, so this
|
// that our next element is *not* a message_row, so this
|
||||||
|
@ -53,7 +54,7 @@ export function visible_range(start_id, end_id) {
|
||||||
|
|
||||||
const rows = [];
|
const rows = [];
|
||||||
|
|
||||||
let row = current_msg_list.get_row(start_id);
|
let row = message_lists.current.get_row(start_id);
|
||||||
let msg_id = id(row);
|
let msg_id = id(row);
|
||||||
|
|
||||||
while (msg_id <= end_id) {
|
while (msg_id <= end_id) {
|
||||||
|
|
|
@ -5,6 +5,7 @@ import * as blueslip from "./blueslip";
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as echo from "./echo";
|
import * as echo from "./echo";
|
||||||
import * as message_events from "./message_events";
|
import * as message_events from "./message_events";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_store from "./message_store";
|
import * as message_store from "./message_store";
|
||||||
import {page_params} from "./page_params";
|
import {page_params} from "./page_params";
|
||||||
import * as reload from "./reload";
|
import * as reload from "./reload";
|
||||||
|
@ -135,8 +136,8 @@ function get_events_success(events) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (home_msg_list.selected_id() === -1 && !home_msg_list.empty()) {
|
if (message_lists.home.selected_id() === -1 && !message_lists.home.empty()) {
|
||||||
home_msg_list.select_id(home_msg_list.first().id, {then_scroll: false});
|
message_lists.home.select_id(message_lists.home.first().id, {then_scroll: false});
|
||||||
}
|
}
|
||||||
|
|
||||||
if (update_message_events.length !== 0) {
|
if (update_message_events.length !== 0) {
|
||||||
|
|
|
@ -18,6 +18,7 @@ import * as message_edit from "./message_edit";
|
||||||
import * as message_events from "./message_events";
|
import * as message_events from "./message_events";
|
||||||
import * as message_flags from "./message_flags";
|
import * as message_flags from "./message_flags";
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as muting_ui from "./muting_ui";
|
import * as muting_ui from "./muting_ui";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as night_mode from "./night_mode";
|
import * as night_mode from "./night_mode";
|
||||||
|
@ -426,7 +427,7 @@ export function dispatch_normal_event(event) {
|
||||||
settings_streams.update_default_streams_table();
|
settings_streams.update_default_streams_table();
|
||||||
stream_data.remove_default_stream(stream.stream_id);
|
stream_data.remove_default_stream(stream.stream_id);
|
||||||
if (is_narrowed_to_stream) {
|
if (is_narrowed_to_stream) {
|
||||||
current_msg_list.update_trailing_bookend();
|
message_lists.current.update_trailing_bookend();
|
||||||
}
|
}
|
||||||
if (page_params.realm_notifications_stream_id === stream.stream_id) {
|
if (page_params.realm_notifications_stream_id === stream.stream_id) {
|
||||||
page_params.realm_notifications_stream_id = -1;
|
page_params.realm_notifications_stream_id = -1;
|
||||||
|
@ -560,8 +561,8 @@ export function dispatch_normal_event(event) {
|
||||||
}
|
}
|
||||||
if (event.setting_name === "twenty_four_hour_time") {
|
if (event.setting_name === "twenty_four_hour_time") {
|
||||||
// Rerender the whole message list UI
|
// Rerender the whole message list UI
|
||||||
home_msg_list.rerender();
|
message_lists.home.rerender();
|
||||||
if (current_msg_list === message_list.narrowed) {
|
if (message_lists.current === message_list.narrowed) {
|
||||||
message_list.narrowed.rerender();
|
message_list.narrowed.rerender();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -613,8 +614,8 @@ export function dispatch_normal_event(event) {
|
||||||
settings_display.report_emojiset_change();
|
settings_display.report_emojiset_change();
|
||||||
|
|
||||||
// Rerender the whole message list UI
|
// Rerender the whole message list UI
|
||||||
home_msg_list.rerender();
|
message_lists.home.rerender();
|
||||||
if (current_msg_list === message_list.narrowed) {
|
if (message_lists.current === message_list.narrowed) {
|
||||||
message_list.narrowed.rerender();
|
message_list.narrowed.rerender();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,6 +3,7 @@ import $ from "jquery";
|
||||||
import * as blueslip from "./blueslip";
|
import * as blueslip from "./blueslip";
|
||||||
import * as color_data from "./color_data";
|
import * as color_data from "./color_data";
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
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 narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
|
@ -126,7 +127,7 @@ export function mark_subscribed(sub, subscribers, color) {
|
||||||
message_view_header.maybe_rerender_title_area_for_stream(sub);
|
message_view_header.maybe_rerender_title_area_for_stream(sub);
|
||||||
|
|
||||||
if (narrow_state.is_for_stream_id(sub.stream_id)) {
|
if (narrow_state.is_for_stream_id(sub.stream_id)) {
|
||||||
current_msg_list.update_trailing_bookend();
|
message_lists.current.update_trailing_bookend();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update unread counts as the new stream in sidebar might
|
// Update unread counts as the new stream in sidebar might
|
||||||
|
@ -154,7 +155,7 @@ export function mark_unsubscribed(sub) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (narrow_state.is_for_stream_id(sub.stream_id)) {
|
if (narrow_state.is_for_stream_id(sub.stream_id)) {
|
||||||
current_msg_list.update_trailing_bookend();
|
message_lists.current.update_trailing_bookend();
|
||||||
}
|
}
|
||||||
|
|
||||||
stream_list.remove_sidebar_row(sub.stream_id);
|
stream_list.remove_sidebar_row(sub.stream_id);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
|
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as message_scroll from "./message_scroll";
|
import * as message_scroll from "./message_scroll";
|
||||||
import * as message_util from "./message_util";
|
import * as message_util from "./message_util";
|
||||||
import * as message_viewport from "./message_viewport";
|
import * as message_viewport from "./message_viewport";
|
||||||
|
@ -18,30 +19,30 @@ export function update_is_muted(sub, value) {
|
||||||
if (overlays.is_active()) {
|
if (overlays.is_active()) {
|
||||||
saved_ypos = message_viewport.scrollTop();
|
saved_ypos = message_viewport.scrollTop();
|
||||||
} else if (
|
} else if (
|
||||||
home_msg_list === current_msg_list &&
|
message_lists.home === message_lists.current &&
|
||||||
current_msg_list.selected_row().offset() !== null
|
message_lists.current.selected_row().offset() !== null
|
||||||
) {
|
) {
|
||||||
msg_offset = current_msg_list.selected_row().offset().top;
|
msg_offset = message_lists.current.selected_row().offset().top;
|
||||||
}
|
}
|
||||||
|
|
||||||
home_msg_list.clear({clear_selected_id: false});
|
message_lists.home.clear({clear_selected_id: false});
|
||||||
|
|
||||||
// Recreate the home_msg_list with the newly filtered message_list.all
|
// Recreate the message_lists.home with the newly filtered message_list.all
|
||||||
message_util.add_old_messages(message_list.all.all_messages(), home_msg_list);
|
message_util.add_old_messages(message_list.all.all_messages(), message_lists.home);
|
||||||
|
|
||||||
// Ensure we're still at the same scroll position
|
// Ensure we're still at the same scroll position
|
||||||
if (overlays.is_active()) {
|
if (overlays.is_active()) {
|
||||||
message_viewport.scrollTop(saved_ypos);
|
message_viewport.scrollTop(saved_ypos);
|
||||||
} else if (home_msg_list === current_msg_list) {
|
} else if (message_lists.home === message_lists.current) {
|
||||||
// We pass use_closest to handle the case where the
|
// We pass use_closest to handle the case where the
|
||||||
// currently selected message is being hidden from the
|
// currently selected message is being hidden from the
|
||||||
// home view
|
// home view
|
||||||
home_msg_list.select_id(home_msg_list.selected_id(), {
|
message_lists.home.select_id(message_lists.home.selected_id(), {
|
||||||
use_closest: true,
|
use_closest: true,
|
||||||
empty_ok: true,
|
empty_ok: true,
|
||||||
});
|
});
|
||||||
if (current_msg_list.selected_id() !== -1) {
|
if (message_lists.current.selected_id() !== -1) {
|
||||||
current_msg_list.view.set_message_offset(msg_offset);
|
message_lists.current.view.set_message_offset(msg_offset);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -53,8 +54,8 @@ export function update_is_muted(sub, value) {
|
||||||
navigate.plan_scroll_to_selected();
|
navigate.plan_scroll_to_selected();
|
||||||
message_scroll.suppress_selection_update_on_next_scroll();
|
message_scroll.suppress_selection_update_on_next_scroll();
|
||||||
|
|
||||||
if (!home_msg_list.empty()) {
|
if (!message_lists.home.empty()) {
|
||||||
message_util.do_unread_count_updates(home_msg_list.all_messages());
|
message_util.do_unread_count_updates(message_lists.home.all_messages());
|
||||||
}
|
}
|
||||||
}, 0);
|
}, 0);
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import * as common from "./common";
|
||||||
import {i18n} from "./i18n";
|
import {i18n} from "./i18n";
|
||||||
import {localstorage} from "./localstorage";
|
import {localstorage} from "./localstorage";
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
|
|
||||||
// What, if anything, obscures the home tab?
|
// What, if anything, obscures the home tab?
|
||||||
|
|
||||||
|
@ -51,7 +52,7 @@ export function reset_scrollbar(element_selector) {
|
||||||
}
|
}
|
||||||
|
|
||||||
function update_message_in_all_views(message_id, callback) {
|
function update_message_in_all_views(message_id, callback) {
|
||||||
for (const list of [message_list.all, home_msg_list, message_list.narrowed]) {
|
for (const list of [message_list.all, message_lists.home, message_list.narrowed]) {
|
||||||
if (list === undefined) {
|
if (list === undefined) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -31,6 +31,7 @@ import * as markdown from "./markdown";
|
||||||
import * as markdown_config from "./markdown_config";
|
import * as markdown_config from "./markdown_config";
|
||||||
import * as message_edit from "./message_edit";
|
import * as message_edit from "./message_edit";
|
||||||
import * as message_fetch from "./message_fetch";
|
import * as message_fetch from "./message_fetch";
|
||||||
|
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";
|
||||||
|
@ -97,7 +98,7 @@ function message_hover(message_row) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
const message = current_msg_list.get(rows.id(message_row));
|
const message = message_lists.current.get(rows.id(message_row));
|
||||||
message_unhover();
|
message_unhover();
|
||||||
current_message_hover = message_row;
|
current_message_hover = message_row;
|
||||||
|
|
||||||
|
@ -266,7 +267,7 @@ export function initialize_kitchen_sink_stuff() {
|
||||||
});
|
});
|
||||||
|
|
||||||
$(document).on("message_selected.zulip", (event) => {
|
$(document).on("message_selected.zulip", (event) => {
|
||||||
if (current_msg_list !== event.msg_list) {
|
if (message_lists.current !== event.msg_list) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (event.id === -1) {
|
if (event.id === -1) {
|
||||||
|
@ -279,7 +280,7 @@ export function initialize_kitchen_sink_stuff() {
|
||||||
|
|
||||||
if (event.then_scroll) {
|
if (event.then_scroll) {
|
||||||
if (row.length === 0) {
|
if (row.length === 0) {
|
||||||
const row_from_dom = current_msg_list.get_row(event.id);
|
const row_from_dom = message_lists.current.get_row(event.id);
|
||||||
const messages = event.msg_list.all_messages();
|
const messages = event.msg_list.all_messages();
|
||||||
blueslip.debug("message_selected missing selected row", {
|
blueslip.debug("message_selected missing selected row", {
|
||||||
previously_selected_id: event.previously_selected_id,
|
previously_selected_id: event.previously_selected_id,
|
||||||
|
@ -291,7 +292,7 @@ export function initialize_kitchen_sink_stuff() {
|
||||||
selected_id_from_idx: messages[event.msg_list.selected_idx()].id,
|
selected_id_from_idx: messages[event.msg_list.selected_idx()].id,
|
||||||
msg_list_sorted: _.isEqual(
|
msg_list_sorted: _.isEqual(
|
||||||
messages.map((message) => message.id),
|
messages.map((message) => message.id),
|
||||||
current_msg_list
|
message_lists.current
|
||||||
.all_messages()
|
.all_messages()
|
||||||
.map((message) => message.id)
|
.map((message) => message.id)
|
||||||
.sort(),
|
.sort(),
|
||||||
|
@ -300,7 +301,7 @@ export function initialize_kitchen_sink_stuff() {
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
if (event.target_scroll_offset !== undefined) {
|
if (event.target_scroll_offset !== undefined) {
|
||||||
current_msg_list.view.set_message_offset(event.target_scroll_offset);
|
message_lists.current.view.set_message_offset(event.target_scroll_offset);
|
||||||
} else {
|
} else {
|
||||||
// Scroll to place the message within the current view;
|
// Scroll to place the message within the current view;
|
||||||
// but if this is the initial placement of the pointer,
|
// but if this is the initial placement of the pointer,
|
||||||
|
@ -316,7 +317,7 @@ export function initialize_kitchen_sink_stuff() {
|
||||||
$("#main_div").on("mouseenter", ".message_time", (e) => {
|
$("#main_div").on("mouseenter", ".message_time", (e) => {
|
||||||
const time_elem = $(e.target);
|
const time_elem = $(e.target);
|
||||||
const row = time_elem.closest(".message_row");
|
const row = time_elem.closest(".message_row");
|
||||||
const message = current_msg_list.get(rows.id(row));
|
const message = message_lists.current.get(rows.id(row));
|
||||||
timerender.set_full_datetime(message, time_elem);
|
timerender.set_full_datetime(message, time_elem);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -475,6 +476,7 @@ export function initialize_everything() {
|
||||||
|
|
||||||
const user_status_params = pop_fields("user_status");
|
const user_status_params = pop_fields("user_status");
|
||||||
|
|
||||||
|
message_lists.initialize();
|
||||||
alert_popup.initialize();
|
alert_popup.initialize();
|
||||||
alert_words.initialize(alert_words_params);
|
alert_words.initialize(alert_words_params);
|
||||||
emojisets.initialize();
|
emojisets.initialize();
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import * as channel from "./channel";
|
import * as channel from "./channel";
|
||||||
import * as message_flags from "./message_flags";
|
import * as message_flags from "./message_flags";
|
||||||
import * as message_list from "./message_list";
|
import * as message_list from "./message_list";
|
||||||
|
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 notifications from "./notifications";
|
import * as notifications from "./notifications";
|
||||||
|
@ -31,7 +32,7 @@ export function mark_all_as_read() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function process_newly_read_message(message, options) {
|
function process_newly_read_message(message, options) {
|
||||||
home_msg_list.show_message_as_read(message, options);
|
message_lists.home.show_message_as_read(message, options);
|
||||||
message_list.all.show_message_as_read(message, options);
|
message_list.all.show_message_as_read(message, options);
|
||||||
if (message_list.narrowed) {
|
if (message_list.narrowed) {
|
||||||
message_list.narrowed.show_message_as_read(message, options);
|
message_list.narrowed.show_message_as_read(message, options);
|
||||||
|
@ -56,7 +57,7 @@ export function process_read_messages_event(message_ids) {
|
||||||
}
|
}
|
||||||
|
|
||||||
for (const message_id of message_ids) {
|
for (const message_id of message_ids) {
|
||||||
if (current_msg_list === message_list.narrowed) {
|
if (message_lists.current === message_list.narrowed) {
|
||||||
// I'm not sure this entirely makes sense for all server
|
// I'm not sure this entirely makes sense for all server
|
||||||
// notifications.
|
// notifications.
|
||||||
unread.set_messages_read_in_narrow(true);
|
unread.set_messages_read_in_narrow(true);
|
||||||
|
@ -86,7 +87,7 @@ export function notify_server_messages_read(messages, options) {
|
||||||
message_flags.send_read(messages);
|
message_flags.send_read(messages);
|
||||||
|
|
||||||
for (const message of messages) {
|
for (const message of messages) {
|
||||||
if (current_msg_list === message_list.narrowed) {
|
if (message_lists.current === message_list.narrowed) {
|
||||||
unread.set_messages_read_in_narrow(true);
|
unread.set_messages_read_in_narrow(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -108,13 +109,16 @@ export function process_visible() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (message_viewport.bottom_message_visible() && current_msg_list.can_mark_messages_read()) {
|
if (
|
||||||
|
message_viewport.bottom_message_visible() &&
|
||||||
|
message_lists.current.can_mark_messages_read()
|
||||||
|
) {
|
||||||
mark_current_list_as_read();
|
mark_current_list_as_read();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mark_current_list_as_read(options) {
|
export function mark_current_list_as_read(options) {
|
||||||
notify_server_messages_read(current_msg_list.all_messages(), options);
|
notify_server_messages_read(message_lists.current.all_messages(), options);
|
||||||
}
|
}
|
||||||
|
|
||||||
export function mark_stream_as_read(stream_id, cont) {
|
export function mark_stream_as_read(stream_id, cont) {
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
import $ from "jquery";
|
import $ from "jquery";
|
||||||
|
|
||||||
import * as blueslip from "./blueslip";
|
import * as blueslip from "./blueslip";
|
||||||
|
import * as message_lists from "./message_lists";
|
||||||
import * as narrow_state from "./narrow_state";
|
import * as narrow_state from "./narrow_state";
|
||||||
import * as poll_widget from "./poll_widget";
|
import * as poll_widget from "./poll_widget";
|
||||||
import * as todo_widget from "./todo_widget";
|
import * as todo_widget from "./todo_widget";
|
||||||
|
@ -84,8 +85,8 @@ export function activate(in_opts) {
|
||||||
|
|
||||||
export function set_widgets_for_list() {
|
export function set_widgets_for_list() {
|
||||||
for (const [idx, widget_elem] of widget_contents) {
|
for (const [idx, widget_elem] of widget_contents) {
|
||||||
if (current_msg_list.get(idx) !== undefined) {
|
if (message_lists.current.get(idx) !== undefined) {
|
||||||
const row = current_msg_list.get_row(idx);
|
const row = message_lists.current.get_row(idx);
|
||||||
set_widget_in_message(row, widget_elem);
|
set_widget_in_message(row, widget_elem);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,19 +0,0 @@
|
||||||
/* eslint-env commonjs */
|
|
||||||
|
|
||||||
"use strict";
|
|
||||||
|
|
||||||
const {Filter} = require("./filter");
|
|
||||||
const message_list = require("./message_list");
|
|
||||||
|
|
||||||
// This file is being eliminated as part of the general purge of
|
|
||||||
// global variables from Zulip (everything is being moved into
|
|
||||||
// modules). Please don't add things here.
|
|
||||||
|
|
||||||
const home_msg_list = new message_list.MessageList({
|
|
||||||
table_name: "zhome",
|
|
||||||
filter: new Filter([{operator: "in", operand: "home"}]),
|
|
||||||
excludes_muted_topics: true,
|
|
||||||
});
|
|
||||||
|
|
||||||
window.home_msg_list = home_msg_list;
|
|
||||||
window.current_msg_list = home_msg_list;
|
|
|
@ -7,6 +7,7 @@ export {
|
||||||
wildcard_mention_large_stream_threshold,
|
wildcard_mention_large_stream_threshold,
|
||||||
} from "./compose";
|
} from "./compose";
|
||||||
export {private_message_recipient} from "./compose_state";
|
export {private_message_recipient} from "./compose_state";
|
||||||
|
export {current as current_msg_list} from "./message_lists";
|
||||||
export {get_stream_id, get_sub, get_subscriber_count} from "./stream_data";
|
export {get_stream_id, get_sub, get_subscriber_count} from "./stream_data";
|
||||||
export {get_by_user_id as get_person_by_user_id, get_user_id_from_name} from "./people";
|
export {get_by_user_id as get_person_by_user_id, get_user_id_from_name} from "./people";
|
||||||
export {last_visible as last_visible_row, id as row_id} from "./rows";
|
export {last_visible as last_visible_row, id as row_id} from "./rows";
|
||||||
|
|
|
@ -84,6 +84,7 @@ EXEMPT_FILES = {
|
||||||
"static/js/message_list_data.js",
|
"static/js/message_list_data.js",
|
||||||
"static/js/message_list.js",
|
"static/js/message_list.js",
|
||||||
"static/js/message_list_view.js",
|
"static/js/message_list_view.js",
|
||||||
|
"static/js/message_lists.js",
|
||||||
"static/js/message_live_update.js",
|
"static/js/message_live_update.js",
|
||||||
"static/js/message_scroll.js",
|
"static/js/message_scroll.js",
|
||||||
"static/js/message_util.js",
|
"static/js/message_util.js",
|
||||||
|
|
Loading…
Reference in New Issue