mirror of
https://github.com/zulip/zulip.git
synced 2025-10-24 00:23:49 +00:00
We extract compose_fade_users and compose_fade_helper.
This is a pretty verbatim extraction of code, apart from adding a few
exports and changing the callers.
This change makes the buddy_data module no longer sit "above" these
files in the dependency graph (at least not via compose_fade):
* jquery
* lodash (not a big deal)
* compose_state
* floating_recipient_bar
* message_viewport
* rows
The new moules have dependencies that buddy_data already
had directly for other reasons:
* people
* util
And then buddy_data still depends on stream_data indirectly through
the compose-fade logic for stream_data. Even without compose-fade, it
would depend indirectly on stream_data via hash_util.
Note that we could have lifted the calls to compose_fade out of
buddy_data to move some dependencies around, but it's useful to have
buddy_data fully encapsulate what goes into the buddy list without
spreading responsibilities to things like activity.js and
buddy_list.js. We can now unit-test the logic at the level of
buddy_data, which is a lot easier than trying to do it via modules
that delegate drawing or do drawing (such as activity.js and
buddy_list.js).
Note that we still don't have 100% line coverage on the
compose_fade.js module, but all the code that we extracted now is
covered, mostly via buddy_data tests.
34 lines
843 B
JavaScript
34 lines
843 B
JavaScript
import * as compose_fade_helper from "./compose_fade_helper";
|
|
import * as people from "./people";
|
|
|
|
function update_user_row_when_fading(li, conf) {
|
|
const user_id = conf.get_user_id(li);
|
|
const would_receive = compose_fade_helper.would_receive_message(user_id);
|
|
|
|
if (would_receive || people.is_my_user_id(user_id)) {
|
|
conf.unfade(li);
|
|
} else {
|
|
conf.fade(li);
|
|
}
|
|
}
|
|
|
|
export function fade_users(items, conf) {
|
|
for (const li of items) {
|
|
update_user_row_when_fading(li, conf);
|
|
}
|
|
}
|
|
|
|
export function display_users_normally(items, conf) {
|
|
for (const li of items) {
|
|
conf.unfade(li);
|
|
}
|
|
}
|
|
|
|
export function update_user_info(items, conf) {
|
|
if (compose_fade_helper.want_normal_display()) {
|
|
display_users_normally(items, conf);
|
|
} else {
|
|
fade_users(items, conf);
|
|
}
|
|
}
|