v1.18.x
barisusakli 9 years ago
parent c10b2fdb60
commit eb57276980

@ -2,10 +2,8 @@
var async = require('async');
var db = require('../../database');
var user = require('../../user');
var topics = require('../../topics');
var utils = require('../../../public/src/utils');
module.exports = function(SocketTopics) {
@ -14,7 +12,17 @@ module.exports = function(SocketTopics) {
return callback(new Error('[[error:invalid-data]]'));
}
topics.markAsRead(tids, socket.uid, callback);
topics.markAsRead(tids, socket.uid, function(err) {
if (err) {
return callback(err);
}
Topics.pushUnreadCount(uid);
for (var i=0; i<tids.length; ++i) {
Topics.markTopicNotificationsRead(tids[i], uid);
}
});
};
SocketTopics.markTopicNotificationsRead = function(socket, tid, callback) {
@ -25,7 +33,15 @@ module.exports = function(SocketTopics) {
};
SocketTopics.markAllRead = function(socket, data, callback) {
topics.markAllRead(socket.uid, callback);
topics.markAllRead(socket.uid, function(err) {
if (err) {
return callback(err);
}
Topics.pushUnreadCount(uid);
callback();
});
};
SocketTopics.markCategoryTopicsRead = function(socket, cid, callback) {

@ -214,11 +214,6 @@ module.exports = function(Topics) {
categories.markAsRead(cids, uid, next);
},
function (next) {
Topics.pushUnreadCount(uid);
for (var i=0; i<tids.length; ++i) {
Topics.markTopicNotificationsRead(tids[i], uid);
}
next(null, true);
}
], callback);
@ -230,6 +225,9 @@ module.exports = function(Topics) {
db.getSortedSetRevRangeByScore('topics:recent', 0, -1, '+inf', Topics.unreadCutoff(), next);
},
function (tids, next) {
for (var i=0; i<tids.length; ++i) {
Topics.markTopicNotificationsRead(tids[i], uid);
}
Topics.markAsRead(uid, tids, next);
},
function (markedRead, next) {

Loading…
Cancel
Save