Explorar o código

Merge pull request #5412 from e-gaulue/e-gaulue-patch-1

Remove notification while copying board
Lauri Ojansivu hai 1 ano
pai
achega
ae9963c1f7
Modificáronse 1 ficheiros con 14 adicións e 0 borrados
  1. 14 0
      models/boards.js

+ 14 - 0
models/boards.js

@@ -640,11 +640,19 @@ Boards.attachSchema(
 Boards.helpers({
   copy() {
     const oldId = this._id;
+    const oldWatchers = this.watchers ? this.watchers.slice() : [];
     delete this._id;
     delete this.slug;
     this.title = this.copyTitle();
     const _id = Boards.insert(this);
 
+    // Temporary remove watchers to disable notifications
+      Boards.update(_id, {
+        $set: {
+          watchers: []
+        },
+    });
+
     // Copy all swimlanes in board
     ReactiveCache.getSwimlanes({
       boardId: oldId,
@@ -695,6 +703,12 @@ Boards.helpers({
       rule.triggerId = triggersMap[rule.triggerId];
       Rules.insert(rule);
     });
+
+    // Re-set Watchers to reenable notification
+    Boards.update(_id, {
+      $set: { watchers: oldWatchers }
+    });
+
     return _id;
   },
   /**