Browse Source

create a notification when a page is completely deleted

Shun Miyazawa 4 years ago
parent
commit
c4735d9202

+ 4 - 0
packages/app/src/components/InAppNotification/InAppNotificationElm.tsx

@@ -98,6 +98,10 @@ const InAppNotificationElm = (props: Props): JSX.Element => {
       actionMsg = 'deleted';
       actionIcon = 'icon-trash';
       break;
+    case 'PAGE_DELETE_COMPLETELY':
+      actionMsg = 'completely deleted';
+      actionIcon = 'icon-fire';
+      break;
     case 'COMMENT_CREATE':
       actionMsg = 'commented on';
       actionIcon = 'icon-bubble';

+ 11 - 1
packages/app/src/server/service/page.js

@@ -67,6 +67,16 @@ class PageService {
       }
     });
 
+    // delete completely
+    this.pageEvent.on('deleteCompletely', async(page, user) => {
+      try {
+        await this.createAndSendNotifications(page, user, ActivityDefine.ACTION_PAGE_DELETE_COMPLETELY);
+      }
+      catch (err) {
+        logger.error(err);
+      }
+    });
+
     // likes
     this.pageEvent.on('like', async(page, user) => {
       try {
@@ -611,7 +621,7 @@ class PageService {
       this.deleteCompletelyDescendantsWithStream(page, user, options);
     }
 
-    this.pageEvent.emit('delete', page, user); // update as renamed page
+    this.pageEvent.emit('deleteCompletely', page, user); // update as renamed page
 
     return;
   }