mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-11-01 19:46:01 +01:00
potential fix for duplicate chat results, started recent replies block
This commit is contained in:
@@ -126,5 +126,13 @@
|
||||
// jQuery('<div></div>').appendTo("#topics-container").hide().append(html).fadeIn('slow');
|
||||
// set_up_posts(uniqueid);
|
||||
});
|
||||
|
||||
|
||||
|
||||
//socket.emit('api:topics.getRecentReplies', tid);
|
||||
socket.on('api:topics.getRecentReplies', function(replies) {
|
||||
console.log(replies);
|
||||
});
|
||||
|
||||
})();
|
||||
</script>
|
||||
@@ -398,7 +398,7 @@
|
||||
'event:topic_deleted', 'event:topic_restored', 'event:topic:locked',
|
||||
'event:topic_unlocked', 'event:topic_pinned', 'event:topic_unpinned',
|
||||
'event:topic_moved', 'event:post_edited', 'event:post_deleted', 'event:post_restored',
|
||||
'api:posts.favourite'
|
||||
'api:posts.favourite', 'chatMessage'
|
||||
]);
|
||||
|
||||
|
||||
|
||||
@@ -140,6 +140,8 @@ marked.setOptions({
|
||||
RDB.del('cid:' + cid + ':read_by_uid');
|
||||
});
|
||||
|
||||
RDB.zadd('topics:recent_posts:tid:' + tid, (new Date()).getTime(), pid);
|
||||
|
||||
// Re-add the poster, so he/she does not get an "unread" flag on this topic
|
||||
topics.markAsRead(tid, uid);
|
||||
// this will duplicate once we enter the thread, which is where we should be going
|
||||
|
||||
@@ -274,6 +274,12 @@ marked.setOptions({
|
||||
});
|
||||
}
|
||||
|
||||
Topics.getRecentReplies = function(tid, callback) {
|
||||
RDB.zrange('topics:recent_posts:tid:' + tid, 0, -1, 'WITHSCORES', function(err, replies) {
|
||||
callback(replies);
|
||||
});
|
||||
}
|
||||
|
||||
Topics.post = function(socket, uid, title, content, category_id) {
|
||||
if (!category_id) throw new Error('Attempted to post without a category_id');
|
||||
|
||||
|
||||
@@ -263,6 +263,13 @@ var SocketIO = require('socket.io').listen(global.server, { log:false }),
|
||||
notifications.mark_read(nid, uid);
|
||||
});
|
||||
|
||||
socket.on('api:topics.getRecentReplies', function(tid) {
|
||||
console.log('test');
|
||||
topics.getRecentReplies(tid, function(replies) {
|
||||
socket.emit('api:topics.getRecentReplies', replies);
|
||||
});
|
||||
});
|
||||
|
||||
socket.on('sendChatMessage', function(data) {
|
||||
var touid = data.touid;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user