From f0f5fbf13273d247df0b08c66b8ee58d1941457c Mon Sep 17 00:00:00 2001 From: Robin Ward Date: Tue, 20 Dec 2016 13:13:46 -0500 Subject: [PATCH] FIX: Never show the last read marker within 1 post of the last --- .../discourse/components/topic-progress.js.es6 | 8 +++++--- .../discourse/widgets/topic-timeline.js.es6 | 1 + app/assets/stylesheets/desktop/topic.scss | 13 +++++++++++++ app/assets/stylesheets/mobile/topic.scss | 13 ------------- 4 files changed, 19 insertions(+), 16 deletions(-) diff --git a/app/assets/javascripts/discourse/components/topic-progress.js.es6 b/app/assets/javascripts/discourse/components/topic-progress.js.es6 index 8321d70148c..f20f47426d7 100644 --- a/app/assets/javascripts/discourse/components/topic-progress.js.es6 +++ b/app/assets/javascripts/discourse/components/topic-progress.js.es6 @@ -39,9 +39,11 @@ export default Ember.Component.extend({ @computed('progressPosition', 'topic.last_read_post_id') showBackButton(position, lastReadId) { - if (!this.site.mobileView || !lastReadId) { return; } - const readPos = this.get('postStream.stream').indexOf(lastReadId) || 0; - return readPos > position; + if (!lastReadId) { return; } + + const stream = this.get('postStream.stream'); + const readPos = stream.indexOf(lastReadId) || 0; + return (readPos < (stream.length - 1)) && (readPos > position); }, @observes('postStream.stream.[]') diff --git a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 index 8ef9ad0e2de..8add163c85b 100644 --- a/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 +++ b/app/assets/javascripts/discourse/widgets/topic-timeline.js.es6 @@ -165,6 +165,7 @@ createWidget('timeline-scrollarea', { const hasBackPosition = position.lastRead > 3 && Math.abs(position.lastRead - position.current) > 3 && + Math.abs(position.lastRead - position.total) > 1 && (position.lastRead && position.lastRead !== position.total); if (hasBackPosition) { diff --git a/app/assets/stylesheets/desktop/topic.scss b/app/assets/stylesheets/desktop/topic.scss index 571649f60a7..7d56ff403d0 100644 --- a/app/assets/stylesheets/desktop/topic.scss +++ b/app/assets/stylesheets/desktop/topic.scss @@ -87,6 +87,19 @@ width: 757px; } +.progress-back-container { + position: fixed; + width: 0; + right: 0; + bottom: 40px; + z-index: 950; + margin-right: 105px; + + .btn { + margin: 0; + } +} + #topic-progress-wrapper { position: fixed; right: 50%; diff --git a/app/assets/stylesheets/mobile/topic.scss b/app/assets/stylesheets/mobile/topic.scss index 56eedbf56e2..5e296d889d5 100644 --- a/app/assets/stylesheets/mobile/topic.scss +++ b/app/assets/stylesheets/mobile/topic.scss @@ -61,19 +61,6 @@ margin-right: 148px; } -.progress-back-container { - position: fixed; - width: 0; - right: 0; - bottom: 40px; - z-index: 950; - margin-right: 105px; - - .btn { - margin: 0; - } -} - #topic-progress-expanded { border: 1px solid dark-light-diff($primary, $secondary, 90%, -60%); padding: 5px;