A platform for community discussion. Free, open, simple.
FIX: Latest post created_at on topic-timeline not updating (#20665)
Isaac Janzendfd6d6b99981
diff --git a/app/assets/javascripts/discourse/app/components/topic-timeline/container.hbs b/app/assets/javascripts/discourse/app/components/topic-timeline/container.hbsindex d63b2e150af..1701e398f12 100644--- a/app/assets/javascripts/discourse/app/components/topic-timeline/container.hbs+++ b/app/assets/javascripts/discourse/app/components/topic-timeline/container.hbs@@ -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>diff --git a/app/assets/javascripts/discourse/app/components/topic-timeline/container.js b/app/assets/javascripts/discourse/app/components/topic-timeline/container.jsindex f96b681201e..82cf2e84cc4 100644--- a/app/assets/javascripts/discourse/app/components/topic-timeline/container.js+++ b/app/assets/javascripts/discourse/app/components/topic-timeline/container.js@@ -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() {diff --git a/app/assets/javascripts/discourse/app/helpers/application.js b/app/assets/javascripts/discourse/app/helpers/application.jsindex 629a20648af..d3392c99f96 100644--- a/app/assets/javascripts/discourse/app/helpers/application.js+++ b/app/assets/javascripts/discourse/app/helpers/application.js@@ -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) => {