mirror of
https://github.com/zulip/zulip.git
synced 2025-11-09 16:37:23 +00:00
refactor: Extract message_helper.process_new_message.
We move the message_store.add_message_metadata function
(and all its dependencies) into a new module called
message_helper and rename the function to process_new_message.
(It does a bit more than adding message metadata, such
as updating our message store.)
We also have a "protected" interface now in message_store,
so that message_helper can access the message store:
update_message_cache
get_cached_message
Because update_message_cache is identical to
the former create_mock_message, we just renamed it
in the tests.
Most callers should use these functions:
message_helper.process_new_message (setting)
message_store.get (getting)
It's slightly annoying that the setter interface
is in a different module than the getter interface,
but that's how you break a bunch of dependencies.
We also extract the tiny message_user_ids class:
user_ids()
add_user_ids()
All the code moves here are pretty trivial, and
the code that was moved maintains 100% line
coverage.
The module name `message_helper` is not ideal, but it's a single
function and it'll save time to just do the topology change now and
leave thinking through the right name to later.
This commit is contained in:
@@ -3,6 +3,7 @@ import $ from "jquery";
|
||||
import * as channel from "./channel";
|
||||
import {Filter} from "./filter";
|
||||
import * as huddle_data from "./huddle_data";
|
||||
import * as message_helper from "./message_helper";
|
||||
import * as message_list from "./message_list";
|
||||
import * as message_scroll from "./message_scroll";
|
||||
import * as message_store from "./message_store";
|
||||
@@ -49,7 +50,7 @@ function process_result(data, opts) {
|
||||
|
||||
messages = messages.map((message) => {
|
||||
message_store.set_message_booleans(message);
|
||||
return message_store.add_message_metadata(message);
|
||||
return message_helper.process_new_message(message);
|
||||
});
|
||||
|
||||
// In case any of the newly fetched messages are new, add them to
|
||||
|
||||
Reference in New Issue
Block a user