mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-07 14:35:47 +01:00
closes #2146
first tab (recent) shows last 50 messages instead of just last 24 hours
This commit is contained in:
@@ -295,7 +295,7 @@ define('chat', ['taskbar', 'string', 'sounds', 'forum/chats'], function(taskbar,
|
||||
};
|
||||
|
||||
function getChatMessages(chatModal, callback) {
|
||||
socket.emit('modules.chats.get', {touid: chatModal.attr('touid'), since: 'day'}, function(err, messages) {
|
||||
socket.emit('modules.chats.get', {touid: chatModal.attr('touid'), since: 'recent'}, function(err, messages) {
|
||||
module.appendChatMessage(chatModal, messages, callback);
|
||||
});
|
||||
}
|
||||
|
||||
@@ -553,7 +553,7 @@ accountsController.getChats = function(req, res, next) {
|
||||
function(toUid, next) {
|
||||
async.parallel({
|
||||
toUser: async.apply(user.getUserFields, toUid, ['uid', 'username']),
|
||||
messages: async.apply(messaging.getMessages, req.user.uid, toUid, 'day', false)
|
||||
messages: async.apply(messaging.getMessages, req.user.uid, toUid, 'recent', false)
|
||||
}, next);
|
||||
}
|
||||
], function(err, data) {
|
||||
|
||||
@@ -16,6 +16,13 @@ var db = require('./database'),
|
||||
(function(Messaging) {
|
||||
Messaging.notifyQueue = {}; // Only used to notify a user of a new chat message, see Messaging.notifyUser
|
||||
|
||||
var terms = {
|
||||
day: 86400000,
|
||||
week: 604800000,
|
||||
month: 2592000000,
|
||||
threemonths: 7776000000
|
||||
};
|
||||
|
||||
function sortUids(fromuid, touid) {
|
||||
return [fromuid, touid].sort();
|
||||
}
|
||||
@@ -80,15 +87,14 @@ var db = require('./database'),
|
||||
Messaging.getMessages = function(fromuid, touid, since, isNew, callback) {
|
||||
var uids = sortUids(fromuid, touid);
|
||||
|
||||
var terms = {
|
||||
day: 86400000,
|
||||
week: 604800000,
|
||||
month: 2592000000,
|
||||
threemonths: 7776000000
|
||||
};
|
||||
since = terms[since] || terms.day;
|
||||
var count = parseInt(meta.config.chatMessageInboxSize, 10) || 250;
|
||||
db.getSortedSetRevRangeByScore('messages:uid:' + uids[0] + ':to:' + uids[1], 0, count, Infinity, Date.now() - since, function(err, mids) {
|
||||
var min = Date.now() - (terms[since] || terms.day);
|
||||
if (since === 'recent') {
|
||||
count = 49;
|
||||
min = 0;
|
||||
}
|
||||
|
||||
db.getSortedSetRevRangeByScore('messages:uid:' + uids[0] + ':to:' + uids[1], 0, count, Infinity, min, function(err, mids) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user