mirror of
				https://github.com/NodeBB/NodeBB.git
				synced 2025-10-31 02:55:58 +01:00 
			
		
		
		
	closes #2773
This commit is contained in:
		| @@ -12,6 +12,8 @@ var async = require('async'), | |||||||
|  |  | ||||||
| module.exports = function(Topics) { | module.exports = function(Topics) { | ||||||
|  |  | ||||||
|  | 	var unreadCutoff = 86400000; | ||||||
|  |  | ||||||
| 	Topics.getTotalUnread = function(uid, callback) { | 	Topics.getTotalUnread = function(uid, callback) { | ||||||
| 		Topics.getUnreadTids(uid, 0, 20, function(err, tids) { | 		Topics.getUnreadTids(uid, 0, 20, function(err, tids) { | ||||||
| 			callback(err, tids ? tids.length : 0); | 			callback(err, tids ? tids.length : 0); | ||||||
| @@ -54,17 +56,17 @@ module.exports = function(Topics) { | |||||||
| 			return callback(null, []); | 			return callback(null, []); | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		var yesterday = Date.now() - 86400000; | 		var cutoff = Date.now() - unreadCutoff; | ||||||
|  |  | ||||||
| 		async.parallel({ | 		async.parallel({ | ||||||
| 			ignoredCids: function(next) { | 			ignoredCids: function(next) { | ||||||
| 				user.getIgnoredCategories(uid, next); | 				user.getIgnoredCategories(uid, next); | ||||||
| 			}, | 			}, | ||||||
| 			recentTids: function(next) { | 			recentTids: function(next) { | ||||||
| 				db.getSortedSetRevRangeByScoreWithScores('topics:recent', 0, -1, '+inf', yesterday, next); | 				db.getSortedSetRevRangeByScoreWithScores('topics:recent', 0, -1, '+inf', cutoff, next); | ||||||
| 			}, | 			}, | ||||||
| 			userScores: function(next) { | 			userScores: function(next) { | ||||||
| 				db.getSortedSetRevRangeByScoreWithScores('uid:' + uid + ':tids_read', 0, -1, '+inf', yesterday, next); | 				db.getSortedSetRevRangeByScoreWithScores('uid:' + uid + ':tids_read', 0, -1, '+inf', cutoff, next); | ||||||
| 			} | 			} | ||||||
| 		}, function(err, results) { | 		}, function(err, results) { | ||||||
| 			if (err) { | 			if (err) { | ||||||
| @@ -247,8 +249,9 @@ module.exports = function(Topics) { | |||||||
| 			if (err) { | 			if (err) { | ||||||
| 				return callback(err); | 				return callback(err); | ||||||
| 			} | 			} | ||||||
|  | 			var cutoff = Date.now() - unreadCutoff; | ||||||
| 			var result = tids.map(function(tid, index) { | 			var result = tids.map(function(tid, index) { | ||||||
| 				return !!(results.userScores[index] && results.userScores[index] >= results.recentScores[index]); | 				return results.recentScores[index] < cutoff || !!(results.userScores[index] && results.userScores[index] >= results.recentScores[index]); | ||||||
| 			}); | 			}); | ||||||
|  |  | ||||||
| 			callback(null, result); | 			callback(null, result); | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user