mirror of
https://github.com/wekan/wekan.git
synced 2025-12-16 23:40:13 +01:00
add comments for card comment reactions feature
This commit is contained in:
parent
2977120129
commit
104a6dd0b3
2 changed files with 6 additions and 0 deletions
|
|
@ -266,6 +266,7 @@ Template.addReactionPopup.events({
|
||||||
|
|
||||||
Template.addReactionPopup.helpers({
|
Template.addReactionPopup.helpers({
|
||||||
codepoints() {
|
codepoints() {
|
||||||
|
// Starting set of unicode codepoints as comment reactions
|
||||||
return [
|
return [
|
||||||
'👍',
|
'👍',
|
||||||
'👎',
|
'👎',
|
||||||
|
|
|
||||||
|
|
@ -106,9 +106,12 @@ CardComments.helpers({
|
||||||
const userId = Meteor.userId();
|
const userId = Meteor.userId();
|
||||||
const reaction = reactions.find(r => r.reactionCodepoint === reactionCodepoint);
|
const reaction = reactions.find(r => r.reactionCodepoint === reactionCodepoint);
|
||||||
|
|
||||||
|
// If no reaction is set for the codepoint, add this
|
||||||
if (!reaction) {
|
if (!reaction) {
|
||||||
reactions.push({ reactionCodepoint, userIds: [userId] });
|
reactions.push({ reactionCodepoint, userIds: [userId] });
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
|
// toggle user reaction upon previous reaction state
|
||||||
const userHasReacted = reaction.userIds.includes(userId);
|
const userHasReacted = reaction.userIds.includes(userId);
|
||||||
if (userHasReacted) {
|
if (userHasReacted) {
|
||||||
reaction.userIds.splice(reaction.userIds.indexOf(userId), 1);
|
reaction.userIds.splice(reaction.userIds.indexOf(userId), 1);
|
||||||
|
|
@ -119,6 +122,8 @@ CardComments.helpers({
|
||||||
reaction.userIds.push(userId);
|
reaction.userIds.push(userId);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// If no reaction doc exists yet create otherwise update reaction set
|
||||||
if (!!cardCommentReactions) {
|
if (!!cardCommentReactions) {
|
||||||
return CardCommentReactions.update({ _id: cardCommentReactions._id }, { $set: { reactions } });
|
return CardCommentReactions.update({ _id: cardCommentReactions._id }, { $set: { reactions } });
|
||||||
} else {
|
} else {
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue