From 78fe1da00c576ec41e5e0ec126f04d19610275fc Mon Sep 17 00:00:00 2001 From: psychobunny Date: Thu, 8 Oct 2015 18:29:57 -0400 Subject: [PATCH] don't mark all chats as read when just reading the list from dropdown/slidemenu/chats page strangely enough it was doing it twice --- src/messaging.js | 21 ++++++++++++--------- 1 file changed, 12 insertions(+), 9 deletions(-) diff --git a/src/messaging.js b/src/messaging.js index 415ab5a12c..99b01fec2f 100644 --- a/src/messaging.js +++ b/src/messaging.js @@ -111,7 +111,8 @@ var db = require('./database'), touid = params.touid, since = params.since, isNew = params.isNew, - count = params.count || parseInt(meta.config.chatMessageInboxSize, 10) || 250; + count = params.count || parseInt(meta.config.chatMessageInboxSize, 10) || 250, + markRead = params.markRead || true; var uids = sortUids(fromuid, touid), min = params.count ? 0 : Date.now() - (terms[since] || terms.day); @@ -135,13 +136,15 @@ var db = require('./database'), getMessages(mids, fromuid, touid, isNew, callback); }); - notifications.markRead('chat_' + touid + '_' + fromuid, fromuid, function(err) { - if (err) { - winston.error('[messaging] Could not mark notifications related to this chat as read: ' + err.message); - } + if (markRead) { + notifications.markRead('chat_' + touid + '_' + fromuid, fromuid, function(err) { + if (err) { + winston.error('[messaging] Could not mark notifications related to this chat as read: ' + err.message); + } - userNotifications.pushCount(fromuid); - }); + userNotifications.pushCount(fromuid); + }); + } }; function getMessages(mids, fromuid, touid, isNew, callback) { @@ -271,7 +274,8 @@ var db = require('./database'), fromuid: fromuid, touid: uid, isNew: false, - count: 1 + count: 1, + markRead: false }, function(err, teaser) { var teaser = teaser[0]; teaser.content = S(teaser.content).stripTags().decodeHTMLEntities().s; @@ -286,7 +290,6 @@ var db = require('./database'), results.users.forEach(function(user, index) { if (user && parseInt(user.uid, 10)) { - Messaging.markRead(uid, uids[index]); user.unread = results.unread[index]; user.status = sockets.isUserOnline(user.uid) ? user.status : 'offline'; user.teaser = results.teasers[index];