mirror of
https://github.com/discourse/discourse.git
synced 2025-06-07 10:18:48 +08:00
FIX: correctly hides timeline scroller for short posts (#9581)
* FIX: correctly hides timeline scroller for short posts * fix linting
This commit is contained in:
@ -1,5 +1,5 @@
|
|||||||
import Mixin from "@ember/object/mixin";
|
import Mixin from "@ember/object/mixin";
|
||||||
import { debounce } from "@ember/runloop";
|
import { later, debounce } from "@ember/runloop";
|
||||||
|
|
||||||
const helper = {
|
const helper = {
|
||||||
offset() {
|
offset() {
|
||||||
@ -32,7 +32,8 @@ export default Mixin.create({
|
|||||||
$(window).bind("scroll.discourse-dock", this.queueDockCheck);
|
$(window).bind("scroll.discourse-dock", this.queueDockCheck);
|
||||||
$(document).bind("touchmove.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() {
|
willDestroyElement() {
|
||||||
|
@ -518,32 +518,46 @@ export default createWidget("topic-timeline", {
|
|||||||
|
|
||||||
result.push(this.attach("timeline-controls", attrs));
|
result.push(this.attach("timeline-controls", attrs));
|
||||||
|
|
||||||
const bottomAge = relativeAge(new Date(topic.last_posted_at), {
|
let displayTimeLineScrollArea = true;
|
||||||
addAgo: true,
|
if (!attrs.mobileView) {
|
||||||
defaultFormat: timelineDate
|
const streamLength = attrs.topic.get("postStream.stream.length");
|
||||||
});
|
|
||||||
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));
|
if (streamLength < 2) {
|
||||||
result.push(this.attach("timeline-footer-controls", attrs));
|
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;
|
return result;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user