From 02dd9ac32a491e7ee41a012b11ff90666455066b Mon Sep 17 00:00:00 2001
From: Dessalines <tyhou13@gmx.com>
Date: Sat, 19 Oct 2019 17:46:29 -0700
Subject: Adding username mentions / tagging from comments.

- Fixes #293
---
 ui/src/components/comment-node.tsx | 30 ++++++++++++++++++++----------
 1 file changed, 20 insertions(+), 10 deletions(-)

(limited to 'ui/src/components/comment-node.tsx')

diff --git a/ui/src/components/comment-node.tsx b/ui/src/components/comment-node.tsx
index 7eb5d9d4..e3d82196 100644
--- a/ui/src/components/comment-node.tsx
+++ b/ui/src/components/comment-node.tsx
@@ -4,6 +4,7 @@ import {
   CommentNode as CommentNodeI,
   CommentLikeForm,
   CommentForm as CommentFormI,
+  EditUserMentionForm,
   SaveCommentForm,
   BanFromCommunityForm,
   BanUserForm,
@@ -686,16 +687,25 @@ export class CommentNode extends Component<CommentNodeProps, CommentNodeState> {
   }
 
   handleMarkRead(i: CommentNode) {
-    let form: CommentFormI = {
-      content: i.props.node.comment.content,
-      edit_id: i.props.node.comment.id,
-      creator_id: i.props.node.comment.creator_id,
-      post_id: i.props.node.comment.post_id,
-      parent_id: i.props.node.comment.parent_id,
-      read: !i.props.node.comment.read,
-      auth: null,
-    };
-    WebSocketService.Instance.editComment(form);
+    // if it has a user_mention_id field, then its a mention
+    if (i.props.node.comment.user_mention_id) {
+      let form: EditUserMentionForm = {
+        user_mention_id: i.props.node.comment.user_mention_id,
+        read: !i.props.node.comment.read,
+      };
+      WebSocketService.Instance.editUserMention(form);
+    } else {
+      let form: CommentFormI = {
+        content: i.props.node.comment.content,
+        edit_id: i.props.node.comment.id,
+        creator_id: i.props.node.comment.creator_id,
+        post_id: i.props.node.comment.post_id,
+        parent_id: i.props.node.comment.parent_id,
+        read: !i.props.node.comment.read,
+        auth: null,
+      };
+      WebSocketService.Instance.editComment(form);
+    }
   }
 
   handleModBanFromCommunityShow(i: CommentNode) {
-- 
cgit v1.2.3

