From ceb3b6ebe7cfa3958c74e4a1c1d4b2a4e4e02f8b Mon Sep 17 00:00:00 2001 From: boomzillawtf Date: Wed, 16 Mar 2016 17:55:58 -0400 Subject: [PATCH 1/2] Add setting to avoid showing a post after it is submitted to keep the user's place on the page to address issue #4363 --- public/language/en_GB/user.json | 2 ++ public/src/client/topic/posts.js | 2 +- src/user/settings.js | 4 +++- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/public/language/en_GB/user.json b/public/language/en_GB/user.json index 2de2819dad..d76e82b5b3 100644 --- a/public/language/en_GB/user.json +++ b/public/language/en_GB/user.json @@ -103,6 +103,8 @@ "enable_topic_searching": "Enable In-Topic Searching", "topic_search_help": "If enabled, in-topic searching will override the browser's default page search behaviour and allow you to search through the entire topic, instead of what is only shown on screen", + "scroll_to_my_post": "After posting a reply, show the new post", + "follow_topics_you_reply_to": "Follow topics that you reply to", "follow_topics_you_create": "Follow topics you create", diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index 8f8bf4ca7d..2eada17c17 100644 --- a/public/src/client/topic/posts.js +++ b/public/src/client/topic/posts.js @@ -79,7 +79,7 @@ define('forum/topic/posts', [ } function scrollToPostIfSelf(post) { - var isSelfPost = parseInt(post.uid, 10) === parseInt(app.user.uid, 10); + var isSelfPost = config.scrollToMyPost && parseInt(post.uid, 10) === parseInt(app.user.uid, 10); if (isSelfPost) { navigator.scrollBottom(post.index); } diff --git a/src/user/settings.js b/src/user/settings.js index f1c4081b50..fc72342bf9 100644 --- a/src/user/settings.js +++ b/src/user/settings.js @@ -76,6 +76,7 @@ module.exports = function(User) { settings.restrictChat = parseInt(getSetting(settings, 'restrictChat', 0), 10) === 1; settings.topicSearchEnabled = parseInt(getSetting(settings, 'topicSearchEnabled', 0), 10) === 1; settings.bootswatchSkin = settings.bootswatchSkin || 'default'; + settings.scrollToMyPost = parseInt(getSetting(settings, 'scrollToMyPost', 1), 10) ===1; callback(null, settings); }); @@ -120,7 +121,8 @@ module.exports = function(User) { restrictChat: data.restrictChat, topicSearchEnabled: data.topicSearchEnabled, groupTitle: data.groupTitle, - homePageRoute: data.homePageCustom || data.homePageRoute + homePageRoute: data.homePageCustom || data.homePageRoute, + scrollToMyPost: data.scrollToMyPost }; if (data.bootswatchSkin) { From eb7c2d5872b12d5b67b26d38cb5585780608c207 Mon Sep 17 00:00:00 2001 From: boomzillawtf Date: Wed, 16 Mar 2016 20:19:02 -0400 Subject: [PATCH 2/2] Use scrollToMyPost setting with both pagination and infinite scroll --- public/src/client/topic/posts.js | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/public/src/client/topic/posts.js b/public/src/client/topic/posts.js index 2eada17c17..3eff5a03b5 100644 --- a/public/src/client/topic/posts.js +++ b/public/src/client/topic/posts.js @@ -33,10 +33,12 @@ define('forum/topic/posts', [ ajaxify.data.postcount ++; postTools.updatePostCount(ajaxify.data.postcount); - if (config.usePagination) { - onNewPostPagination(data); - } else { - onNewPostInfiniteScroll(data); + if (config.scrollToMyPost) { + if (config.usePagination) { + onNewPostPagination(data); + } else { + onNewPostInfiniteScroll(data); + } } }; @@ -79,7 +81,7 @@ define('forum/topic/posts', [ } function scrollToPostIfSelf(post) { - var isSelfPost = config.scrollToMyPost && parseInt(post.uid, 10) === parseInt(app.user.uid, 10); + var isSelfPost = parseInt(post.uid, 10) === parseInt(app.user.uid, 10); if (isSelfPost) { navigator.scrollBottom(post.index); }