ui: Move update_message_lists related functions to other related modules.

This commit moves mainly two functions from `ui.js` to `message_live_update`,
`update_message_in_all_views` and `update_starred_view`. This is done in favor of
eliminating `ui.js` and also these functions are more closely related to
`message_live_update` module than to `ui` module.

We also move `show_message_failed` and `show_failed_message_success` to `echo.js`
for cleaner seperation of responsibilities.
This commit is contained in:
Lalit
2023-04-25 09:06:10 +05:30
committed by Tim Abbott
parent aad2f7c7c5
commit 7e52509ee7
7 changed files with 65 additions and 78 deletions

View File

@@ -70,7 +70,6 @@ mock_esm("../src/top_left_corner", {
update_starred_count() {},
});
const typing_events = mock_esm("../src/typing_events");
const ui = mock_esm("../src/ui");
const unread_ops = mock_esm("../src/unread_ops");
const unread_ui = mock_esm("../src/unread_ui");
const user_events = mock_esm("../src/user_events");
@@ -84,12 +83,14 @@ const electron_bridge = set_global("electron_bridge", {});
message_lists.update_recipient_bar_background_color = noop;
message_lists.current = {
get_row: noop,
rerender_view: noop,
data: {
get_messages_sent_by_user: () => [],
},
};
message_lists.home = {
get_row: noop,
rerender_view: noop,
data: {
get_messages_sent_by_user: () => [],
@@ -996,28 +997,16 @@ run_test("update_message (unread)", ({override}) => {
});
});
run_test("update_message (add star)", ({override}) => {
run_test("update_message (add star)", () => {
const event = event_fixtures.update_message_flags__starred_add;
const stub = make_stub();
override(ui, "update_starred_view", stub.f);
dispatch(event);
assert.equal(stub.num_calls, 1);
const args = stub.get_args("message_id", "new_value");
assert_same(args.message_id, test_message.id);
assert_same(args.new_value, true); // for 'add'
const msg = message_store.get(test_message.id);
assert.equal(msg.starred, true);
});
run_test("update_message (remove star)", ({override}) => {
run_test("update_message (remove star)", () => {
const event = event_fixtures.update_message_flags__starred_remove;
const stub = make_stub();
override(ui, "update_starred_view", stub.f);
dispatch(event);
assert.equal(stub.num_calls, 1);
const args = stub.get_args("message_id", "new_value");
assert_same(args.message_id, test_message.id);
assert_same(args.new_value, false);
const msg = message_store.get(test_message.id);
assert.equal(msg.starred, false);
});