mirror of
https://github.com/zulip/zulip.git
synced 2026-07-12 21:04:41 +08:00
reactions: Refactor add_clean_reactions to make_clear_reaction.
This is a pure code refactor for readability. Previously, we were relying on there being a side effect to add_clean_reaction which was necessitated by the presence of an output parameter, `message` (or more specifically `message.clean_reaction`). Output parameters are confusing. Hence, this commit changes to have a make_clean_reaction function that returns a reaction.
This commit is contained in:
parent
0b0637de78
commit
06d8e6dfd5
@ -253,14 +253,16 @@ export function add_reaction(event) {
|
||||
r.user_ids.push(user_id);
|
||||
update_user_fields(r);
|
||||
} else {
|
||||
add_clean_reaction({
|
||||
message,
|
||||
message.clean_reactions.set(
|
||||
local_id,
|
||||
user_ids: [user_id],
|
||||
reaction_type: event.reaction_type,
|
||||
emoji_name: event.emoji_name,
|
||||
emoji_code: event.emoji_code,
|
||||
});
|
||||
make_clean_reaction({
|
||||
local_id,
|
||||
user_ids: [user_id],
|
||||
reaction_type: event.reaction_type,
|
||||
emoji_name: event.emoji_name,
|
||||
emoji_code: event.emoji_code,
|
||||
}),
|
||||
);
|
||||
}
|
||||
|
||||
const opts = {
|
||||
@ -498,18 +500,20 @@ export function set_clean_reactions(message) {
|
||||
const reaction = distinct_reactions.get(local_id);
|
||||
const user_ids = user_map.get(local_id);
|
||||
|
||||
add_clean_reaction({
|
||||
message,
|
||||
message.clean_reactions.set(
|
||||
local_id,
|
||||
user_ids,
|
||||
reaction_type: reaction.reaction_type,
|
||||
emoji_name: reaction.emoji_name,
|
||||
emoji_code: reaction.emoji_code,
|
||||
});
|
||||
make_clean_reaction({
|
||||
local_id,
|
||||
user_ids,
|
||||
reaction_type: reaction.reaction_type,
|
||||
emoji_name: reaction.emoji_name,
|
||||
emoji_code: reaction.emoji_code,
|
||||
}),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
function add_clean_reaction(opts) {
|
||||
function make_clean_reaction(opts) {
|
||||
const r = emoji.get_emoji_details_for_rendering(opts);
|
||||
|
||||
r.local_id = opts.local_id;
|
||||
@ -520,7 +524,7 @@ function add_clean_reaction(opts) {
|
||||
r.emoji_alt_code = user_settings.emojiset === "text";
|
||||
r.is_realm_emoji = r.reaction_type === "realm_emoji" || r.reaction_type === "zulip_extra_emoji";
|
||||
|
||||
opts.message.clean_reactions.set(opts.local_id, r);
|
||||
return r;
|
||||
}
|
||||
|
||||
export function update_user_fields(r) {
|
||||
|
||||
Loading…
Reference in New Issue
Block a user