mirror of
https://github.com/zulip/zulip.git
synced 2025-11-08 07:52:19 +00:00
Extract reactions.view.insert_new_reaction().
This commit is contained in:
@@ -1,6 +1,8 @@
|
|||||||
var reactions = (function () {
|
var reactions = (function () {
|
||||||
var exports = {};
|
var exports = {};
|
||||||
|
|
||||||
|
exports.view = {}; // function namespace
|
||||||
|
|
||||||
function send_reaction_ajax(message_id, emoji_name, operation) {
|
function send_reaction_ajax(message_id, emoji_name, operation) {
|
||||||
if (!emoji.emojis_by_name[emoji_name] && !emoji.realm_emojis[emoji_name]) {
|
if (!emoji.emojis_by_name[emoji_name] && !emoji.realm_emojis[emoji_name]) {
|
||||||
// Emoji doesn't exist
|
// Emoji doesn't exist
|
||||||
@@ -137,7 +139,11 @@ exports.add_reaction = function (event) {
|
|||||||
if (user_list.length > 1) {
|
if (user_list.length > 1) {
|
||||||
exports.update_existing_reaction(event, user_list);
|
exports.update_existing_reaction(event, user_list);
|
||||||
} else {
|
} else {
|
||||||
exports.insert_new_reaction(event, user_list);
|
exports.view.insert_new_reaction({
|
||||||
|
message_id: event.message_id,
|
||||||
|
emoji_name: event.emoji_name,
|
||||||
|
user_id: event.user.id,
|
||||||
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -161,14 +167,16 @@ exports.update_existing_reaction = function (event, user_list) {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
exports.insert_new_reaction = function (event, user_list) {
|
exports.view.insert_new_reaction = function (opts) {
|
||||||
// Our caller ensures we are the first user to react to this
|
// Our caller ensures we are the first user to react to this
|
||||||
// message with this emoji, and it populates user_list for
|
// message with this emoji, and it populates user_list for
|
||||||
// us. We then render the emoji/title/count and insert it
|
// us. We then render the emoji/title/count and insert it
|
||||||
// before the add button.
|
// before the add button.
|
||||||
|
|
||||||
var message_id = event.message_id;
|
var message_id = opts.message_id;
|
||||||
var emoji_name = event.emoji_name;
|
var emoji_name = opts.emoji_name;
|
||||||
|
var user_id = opts.user_id;
|
||||||
|
var user_list = [user_id];
|
||||||
|
|
||||||
var context = {
|
var context = {
|
||||||
message_id: message_id,
|
message_id: message_id,
|
||||||
@@ -187,7 +195,7 @@ exports.insert_new_reaction = function (event, user_list) {
|
|||||||
context.emoji_alt_code = page_params.emoji_alt_code;
|
context.emoji_alt_code = page_params.emoji_alt_code;
|
||||||
context.emoji_name_css_class = emoji.emojis_name_to_css_class[emoji_name];
|
context.emoji_name_css_class = emoji.emojis_name_to_css_class[emoji_name];
|
||||||
|
|
||||||
if (event.user.id === page_params.user_id) {
|
if (opts.user_id === page_params.user_id) {
|
||||||
context.class = "message_reaction reacted";
|
context.class = "message_reaction reacted";
|
||||||
} else {
|
} else {
|
||||||
context.class = "message_reaction";
|
context.class = "message_reaction";
|
||||||
|
|||||||
Reference in New Issue
Block a user