Browse Source

remove COMENT_HOGEHOGE

Shun Miyazawa 4 years ago
parent
commit
4948737fa5

+ 1 - 2
packages/app/src/components/InAppNotification/InAppNotification.tsx

@@ -66,8 +66,7 @@ export const InAppNotification = (props: Props): JSX.Element => {
       // TODO Is the naming of componentName too subtle?
       case 'Page:UPDATE':
         return <PageUpdateNotification {...propsNew} onClick={props.onClick(props.notification)} />;
-      case 'Page:COMMENT_CREATE':
-      case 'Page:COMMENT_UPDATE':
+      case 'Page:COMMENT':
         return <PageCommentNotification {...propsNew} onClick={props.onClick(props.notification)} />;
       default:
         return <></>;

+ 1 - 1
packages/app/src/server/models/comment.js

@@ -73,7 +73,7 @@ module.exports = function(crowi) {
       { $set: { comment, isMarkdown } },
     );
 
-    await commentEvent.emit('update', commentData);
+    await commentEvent.emit('update');
 
     return commentData;
   };

+ 4 - 7
packages/app/src/server/service/comment.ts

@@ -28,7 +28,6 @@ class CommentService {
     this.initCommentEventListeners();
   }
 
-
   initCommentEventListeners(): void {
     // create
     this.commentEvent.on('create', async(savedComment) => {
@@ -37,7 +36,7 @@ class CommentService {
         const Page = getModelSafely('Page') || require('../models/page')(this.crowi);
         await Page.updateCommentCount(savedComment.page);
 
-        await this.createAndSendNotifications(savedComment, ActivityDefine.ACTION_COMMENT_CREATE);
+        await this.createAndSendNotifications(savedComment);
       }
       catch (err) {
         logger.error('Error occurred while handling the comment create event:\n', err);
@@ -46,11 +45,9 @@ class CommentService {
     });
 
     // update
-    this.commentEvent.on('update', async(updatedComment) => {
+    this.commentEvent.on('update', async() => {
       try {
         this.commentEvent.onUpdate();
-
-        await this.createAndSendNotifications(updatedComment, ActivityDefine.ACTION_COMMENT_UPDATE);
       }
       catch (err) {
         logger.error('Error occurred while handling the comment update event:\n', err);
@@ -71,7 +68,7 @@ class CommentService {
     });
   }
 
-  private createAndSendNotifications = async function(comment, actionType) {
+  private createAndSendNotifications = async function(comment) {
 
     // Create activity
     const parameters = {
@@ -80,7 +77,7 @@ class CommentService {
       target: comment.page,
       eventModel: ActivityDefine.MODEL_COMMENT,
       event: comment._id,
-      action: actionType,
+      action: ActivityDefine.ACTION_COMMENT,
     };
     const activity = await this.activityService.createByParameters(parameters);