From 76254942b2251eed478bda140b6bcfe2f4f0b4af Mon Sep 17 00:00:00 2001 From: barisusakli Date: Fri, 3 Feb 2017 16:24:58 +0300 Subject: [PATCH] closes #5190 --- public/src/client/topic/posts.js | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index e6ed0f6bd7..4103864c0b 100644 --- a/public/src/client/topic/posts.js +++ b/public/src/client/topic/posts.js @@ -99,6 +99,11 @@ define('forum/topic/posts', [ function onNewPostInfiniteScroll(data) { var direction = config.topicPostSort === 'oldest_to_newest' || config.topicPostSort === 'most_votes' ? 1 : -1; + var isPreviousPostAdded = $('[component="post"][data-index="' + (data.posts[0].index - 1) + '"]').length; + if (!isPreviousPostAdded && (!data.posts[0].selfPost || !ajaxify.data.scrollToMyPost)) { + return; + } + createNewPosts(data, components.get('post').not('[data-index=0]'), direction, function (html) { if (html) { html.addClass('new'); @@ -109,11 +114,7 @@ define('forum/topic/posts', [ } function scrollToPostIfSelf(post) { - if (!ajaxify.data.scrollToMyPost) { - return; - } - var isSelfPost = parseInt(post.uid, 10) === parseInt(app.user.uid, 10); - if (isSelfPost) { + if (post.selfPost && ajaxify.data.scrollToMyPost) { navigator.scrollBottom(post.index); } }