From 40f0076b77ad7298c6dd0e88cb5e73fe08603e87 Mon Sep 17 00:00:00 2001 From: Julian Lam Date: Wed, 16 Dec 2015 14:30:58 -0500 Subject: [PATCH] fixed bug with notif merging --- src/notifications.js | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/notifications.js b/src/notifications.js index cda7fae2fd..2340f50dba 100644 --- a/src/notifications.js +++ b/src/notifications.js @@ -340,7 +340,7 @@ var async = require('async'), 'notifications:user_posted_to', 'notifications:user_flagged_post_in' ], - isolated, modifyIndex; + isolated, differentiator, modifyIndex; notifications = mergeIds.reduce(function(notifications, mergeId) { isolated = notifications.filter(function(notifObj) { @@ -355,6 +355,8 @@ var async = require('async'), return notifications; // Nothing to merge } + differentiator = isolated[0].mergeId.split('|')[1]; + modifyIndex = notifications.indexOf(isolated[0]); switch(mergeId) { @@ -370,16 +372,16 @@ var async = require('async'), // Update bodyShort if (numUsers === 2) { - isolated[0].bodyShort = '[[' + mergeId.split('|') + '_dual, ' + usernames.join(', ') + ', ' + isolated[0].topicTitle + ']]' + isolated[0].bodyShort = '[[' + mergeId + '_dual, ' + usernames.join(', ') + ', ' + isolated[0].topicTitle + ']]' } else { - isolated[0].bodyShort = '[[' + mergeId.split('|') + '_multiple, ' + usernames[0] + ', ' + (numUsers-1) + ', ' + isolated[0].topicTitle + ']]' + isolated[0].bodyShort = '[[' + mergeId + '_multiple, ' + usernames[0] + ', ' + (numUsers-1) + ', ' + isolated[0].topicTitle + ']]' } break; } // Filter out duplicates return notifications.filter(function(notifObj, idx) { - return notifObj.mergeId !== mergeId || idx === modifyIndex; + return notifObj.mergeId !== mergeId + '|' + differentiator || idx === modifyIndex; }); }, notifications);