diff --git a/app/assets/javascripts/discourse/app/mixins/docking.js b/app/assets/javascripts/discourse/app/mixins/docking.js index 3df9f80edaa..63e40aa0321 100644 --- a/app/assets/javascripts/discourse/app/mixins/docking.js +++ b/app/assets/javascripts/discourse/app/mixins/docking.js @@ -1,5 +1,5 @@ import Mixin from "@ember/object/mixin"; -import { debounce } from "@ember/runloop"; +import { later, debounce } from "@ember/runloop"; const helper = { offset() { @@ -32,7 +32,8 @@ export default Mixin.create({ $(window).bind("scroll.discourse-dock", this.queueDockCheck); $(document).bind("touchmove.discourse-dock", this.queueDockCheck); - this.dockCheck(helper); + // dockCheck might happen too early on full page refresh + later(this, this.safeDockCheck, 50); }, willDestroyElement() { diff --git a/app/assets/javascripts/discourse/app/widgets/topic-timeline.js b/app/assets/javascripts/discourse/app/widgets/topic-timeline.js index 5f3cabfb8e8..b74f691bfbb 100644 --- a/app/assets/javascripts/discourse/app/widgets/topic-timeline.js +++ b/app/assets/javascripts/discourse/app/widgets/topic-timeline.js @@ -518,32 +518,46 @@ export default createWidget("topic-timeline", { result.push(this.attach("timeline-controls", attrs)); - const bottomAge = relativeAge(new Date(topic.last_posted_at), { - addAgo: true, - defaultFormat: timelineDate - }); - let scroller = [ - h( - "div.timeline-date-wrapper", - this.attach("link", { - className: "start-date", - rawLabel: timelineDate(createdAt), - action: "jumpTop" - }) - ), - this.attach("timeline-scrollarea", attrs), - h( - "div.timeline-date-wrapper", - this.attach("link", { - className: "now-date", - rawLabel: bottomAge, - action: "jumpBottom" - }) - ) - ]; + let displayTimeLineScrollArea = true; + if (!attrs.mobileView) { + const streamLength = attrs.topic.get("postStream.stream.length"); - result.push(h("div.timeline-scrollarea-wrapper", scroller)); - result.push(this.attach("timeline-footer-controls", attrs)); + if (streamLength < 2) { + const postsWrapper = document.querySelector(".posts-wrapper"); + if (postsWrapper && postsWrapper.offsetHeight < 1000) { + displayTimeLineScrollArea = false; + } + } + } + + if (displayTimeLineScrollArea) { + const bottomAge = relativeAge(new Date(topic.last_posted_at), { + addAgo: true, + defaultFormat: timelineDate + }); + let scroller = [ + h( + "div.timeline-date-wrapper", + this.attach("link", { + className: "start-date", + rawLabel: timelineDate(createdAt), + action: "jumpTop" + }) + ), + this.attach("timeline-scrollarea", attrs), + h( + "div.timeline-date-wrapper", + this.attach("link", { + className: "now-date", + rawLabel: bottomAge, + action: "jumpBottom" + }) + ) + ]; + + result.push(h("div.timeline-scrollarea-wrapper", scroller)); + result.push(this.attach("timeline-footer-controls", attrs)); + } return result; }