浏览代码

add comments for card comment reactions feature

Kai Lehmann 3 年之前
父节点
当前提交
104a6dd0b3
共有 2 个文件被更改,包括 6 次插入0 次删除
  1. 1 0
      client/components/activities/activities.js
  2. 5 0
      models/cardComments.js

+ 1 - 0
client/components/activities/activities.js

@@ -266,6 +266,7 @@ Template.addReactionPopup.events({
 
 Template.addReactionPopup.helpers({
   codepoints() {
+    // Starting set of unicode codepoints as comment reactions
     return [
       '👍',
       '👎',

+ 5 - 0
models/cardComments.js

@@ -106,9 +106,12 @@ CardComments.helpers({
     const userId = Meteor.userId();
     const reaction = reactions.find(r => r.reactionCodepoint === reactionCodepoint);
 
+    // If no reaction is set for the codepoint, add this
     if (!reaction) {
       reactions.push({ reactionCodepoint, userIds: [userId] });
     } else {
+
+      // toggle user reaction upon previous reaction state
       const userHasReacted = reaction.userIds.includes(userId);
       if (userHasReacted) {
         reaction.userIds.splice(reaction.userIds.indexOf(userId), 1);
@@ -119,6 +122,8 @@ CardComments.helpers({
         reaction.userIds.push(userId);
       }
     }
+
+    // If no reaction doc exists yet create otherwise update reaction set
     if (!!cardCommentReactions) {
       return CardCommentReactions.update({ _id: cardCommentReactions._id }, { $set: { reactions } });
     } else {