mirror of
https://github.com/zulip/zulip.git
synced 2025-11-11 09:27:43 +00:00
compose_fade: Change would_receive_message to use user_id.
This commit changes the would_receive_message to use user_id instead of emails. This change is done because user_ids are immutable and using user_ids is the correct way of uniquely identifying user. The change in 'would_receive_message' also leads to change in util.is_pm_recipient to use a string of user_ids instead of emails. We also know that user_ids passed to 'would_receive_message' are active user_ids, since we get them from buddy_list. So we don't need to check whether the user is active, which was previously being checked by get_active_user_for_email.
This commit is contained in:
@@ -92,22 +92,21 @@ function fade_messages() {
|
||||
}, 0, current_msg_list, compose_state.private_message_recipient());
|
||||
}
|
||||
|
||||
exports.would_receive_message = function (email) {
|
||||
exports.would_receive_message = function (user_id) {
|
||||
if (focused_recipient.type === 'stream') {
|
||||
const user = people.get_active_user_for_email(email);
|
||||
const sub = stream_data.get_sub(focused_recipient.stream);
|
||||
if (!sub || !user) {
|
||||
// If the stream or user isn't valid, there is no risk of a mix
|
||||
if (!sub) {
|
||||
// If the stream isn't valid, there is no risk of a mix
|
||||
// yet, so we sort of "lie" and say they would receive a
|
||||
// message.
|
||||
return true;
|
||||
}
|
||||
|
||||
return stream_data.is_user_subscribed(focused_recipient.stream, user.user_id);
|
||||
return stream_data.is_user_subscribed(focused_recipient.stream, user_id);
|
||||
}
|
||||
|
||||
// PM, so check if the given email is in the recipients list.
|
||||
return util.is_pm_recipient(email, focused_recipient);
|
||||
return util.is_pm_recipient(user_id, focused_recipient);
|
||||
};
|
||||
|
||||
const user_fade_config = {
|
||||
@@ -124,8 +123,7 @@ const user_fade_config = {
|
||||
|
||||
function update_user_row_when_fading(li, conf) {
|
||||
const user_id = conf.get_user_id(li);
|
||||
const email = people.get_by_user_id(user_id).email;
|
||||
const would_receive = exports.would_receive_message(email);
|
||||
const would_receive = exports.would_receive_message(user_id);
|
||||
|
||||
if (would_receive || people.is_my_user_id(user_id)) {
|
||||
conf.unfade(li);
|
||||
|
||||
Reference in New Issue
Block a user