FIX: correctly hides timeline scroller for short posts (#9581)

* FIX: correctly hides timeline scroller for short posts

* fix linting
This commit is contained in:
Joffrey JAFFEUX 2020-04-29 16:24:53 +02:00 committed by GitHub
parent 7ccfc73edb
commit db337b10ee
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 42 additions and 27 deletions

View File

@ -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() {

View File

@ -518,6 +518,19 @@ export default createWidget("topic-timeline", {
result.push(this.attach("timeline-controls", attrs));
let displayTimeLineScrollArea = true;
if (!attrs.mobileView) {
const streamLength = attrs.topic.get("postStream.stream.length");
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
@ -544,6 +557,7 @@ export default createWidget("topic-timeline", {
result.push(h("div.timeline-scrollarea-wrapper", scroller));
result.push(this.attach("timeline-footer-controls", attrs));
}
return result;
}