Skip to content

Node.js based forum software built for the modern web

closes #2894

Barış Soner Uşaklı36942125e629
diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js
index c2ea3940ff..85dfbbb6bb 100644
--- a/public/src/client/topic/posts.js
+++ b/public/src/client/topic/posts.js
@@ -56,9 +56,34 @@ define('forum/topic/posts', [
}
function removeAlreadyAddedPosts() {
- data.posts = data.posts.filter(function(post) {
- return components.get('post', 'pid', post.pid).length === 0;
- });
+ var newPosts = components.get('topic').find('[data-index][data-index!="0"].new');
+
+ if (newPosts.length === data.posts.length) {
+ var allSamePids = true;
+ newPosts.each(function(index, el) {
+ if (parseInt($(el).attr('data-pid'), 10) !== parseInt(data.posts[index].pid, 10)) {
+ allSamePids = false;
+ }
+ });
+
+ if (allSamePids) {
+ newPosts.each(function() {
+ $(this).removeClass('new');
+ });
+ data.posts.length = 0;
+ return;
+ }
+ }
+
+ if (data.posts.length > 1) {
+ data.posts.forEach(function(post) {
+ components.get('post', 'pid', post.pid).remove();
+ });
+ } else {
+ data.posts = data.posts.filter(function(post) {
+ return components.get('post', 'pid', post.pid).length === 0;
+ });
+ }
}
var after = null,
diff --git a/src/socket.io/posts.js b/src/socket.io/posts.js
index 94f6be7a37..2fdf4425b5 100644
--- a/src/socket.io/posts.js
+++ b/src/socket.io/posts.js
@@ -49,6 +49,8 @@ SocketPosts.reply = function(socket, data, callback) {
socket.emit('event:new_post', result);
+ user.updateOnlineUsers(socket.uid);
+
SocketPosts.notifyOnlineUsers(socket.uid, result);
if (data.lock) {