mirror of
https://github.com/discourse/discourse.git
synced 2024-11-25 18:53:44 +08:00
FIX: Latest post created_at on topic-timeline not updating (#20665)
# Context https://meta.discourse.org/t/timeline-timestamp-not-updating/256447/1 During the upgrade of the topic-timeline to glimmer the "latest post" timestamp was not updating on the timeline in relation to the relative age of the post. It was only updating on a hard refresh. # Fix Use the `age-with-tooltip` helper to update the created_at date automatically as time passes. # Additional Add the ability to pass params to `age-with-tooltip` so that we can include options like `addAgo` and `defaultFormat`
This commit is contained in:
parent
22a7818399
commit
dfd6d6b999
|
@ -105,13 +105,9 @@
|
|||
</div>
|
||||
|
||||
<div class="timeline-date-wrapper">
|
||||
<a
|
||||
class="now-date"
|
||||
onClick={{this.updatePercentage}}
|
||||
title={{this.nowDate}}
|
||||
>
|
||||
<a class="now-date" onClick={{this.updatePercentage}}>
|
||||
<span>
|
||||
{{this.nowDate}}
|
||||
{{age-with-tooltip this.nowDate this.nowDateOptions}}
|
||||
</span>
|
||||
</a>
|
||||
</div>
|
||||
|
|
|
@ -1,7 +1,6 @@
|
|||
import Component from "@glimmer/component";
|
||||
import { tracked } from "@glimmer/tracking";
|
||||
import { action } from "@ember/object";
|
||||
import { relativeAge } from "discourse/lib/formatter";
|
||||
import I18n from "I18n";
|
||||
import { htmlSafe } from "@ember/template";
|
||||
import { inject as service } from "@ember/service";
|
||||
|
@ -153,22 +152,21 @@ export default class TopicTimelineScrollArea extends Component {
|
|||
return this.lastReadTop > bottom ? bottom : this.lastReadTop;
|
||||
}
|
||||
|
||||
get bottomAge() {
|
||||
return relativeAge(
|
||||
new Date(this.args.model.last_posted_at || this.args.model.created_at),
|
||||
{
|
||||
addAgo: true,
|
||||
defaultFormat: timelineDate,
|
||||
}
|
||||
);
|
||||
}
|
||||
|
||||
get startDate() {
|
||||
return timelineDate(this.args.model.createdAt);
|
||||
}
|
||||
|
||||
get nowDateOptions() {
|
||||
return {
|
||||
addAgo: true,
|
||||
defaultFormat: timelineDate,
|
||||
};
|
||||
}
|
||||
|
||||
get nowDate() {
|
||||
return this.bottomAge;
|
||||
return (
|
||||
this.args.model.get("last_posted_at") || this.args.model.get("created_at")
|
||||
);
|
||||
}
|
||||
|
||||
get lastReadHeight() {
|
||||
|
|
|
@ -10,8 +10,14 @@ import { registerUnbound } from "discourse-common/lib/helpers";
|
|||
|
||||
registerUnbound("raw-date", (dt) => htmlSafe(longDate(new Date(dt))));
|
||||
|
||||
registerUnbound("age-with-tooltip", (dt) =>
|
||||
htmlSafe(autoUpdatingRelativeAge(new Date(dt), { title: true }))
|
||||
registerUnbound("age-with-tooltip", (dt, params) =>
|
||||
htmlSafe(
|
||||
autoUpdatingRelativeAge(new Date(dt), {
|
||||
title: true,
|
||||
addAgo: params.addAgo || false,
|
||||
...(params.defaultFormat && { defaultFormat: params.defaultFormat }),
|
||||
})
|
||||
)
|
||||
);
|
||||
|
||||
registerUnbound("number", (orig, params) => {
|
||||
|
|
Loading…
Reference in New Issue
Block a user