Couldn’t help but notice:
After a refresh it’s updated. But it should be more logical if it matches the post timestamp, which is updated w/o refresh.
Timeline timestamp not updating: A discussion about an issue where the timeline timestamp is not updating in real-time, requiring a refresh to show the latest timestamp.
MarcP reported the issue and shared a screenshot. isaac investigated the old implementation and found that the bottomAge variable is not updated automatically as time passes. He proposed several solutions, but they had limitations.
david suggested using Glimmer’s reactivity to handle changes to the topic.last_posted_at value, rather than doing stuff on scroll. He provided an example of how to achieve this using a getter for bottomAge and the relative age helper.
isaac later mentioned that the issue will be fixed via a pull request (https://github.com/discourse/discourse/pull/20665#pullrequestreview-1339566167).
Couldn’t help but notice:
After a refresh it’s updated. But it should be more logical if it matches the post timestamp, which is updated w/o refresh.
Interesting one, could be related to our glimmer move @isaac
Digging in to the old implementation, I am wondering if this was a issue before as well…
const bottomAge = relativeAge(
new Date(topic.last_posted_at || topic.created_at),
{
addAgo: true,
defaultFormat: timelineDate,
}
);
const scroller = [
h(
"div.timeline-date-wrapper",
this.attach("link", {
className: "now-date",
rawLabel: bottomAge,
action: "jumpBottom",
})
),
];
This was called in the html() function of the widget, which it doesn’t look like we have any hooks for updating this as the time passes.
Obviously the desired functionality is to update the bottomAge with the newest date on post creation, and then continue to update it automatically as the time passes. What we can do right now is add a function to
and update bottomAge on scroll, but in practice feels a little odd. Another issue with this idea is that it is difficult to match the timing of the updating of the date on the latest post to the updating of the bottomAge date on the topic timeline. The relative created_at on a post lags behind by a 10 seconds or so… creating a miss match between
when you are scrolling.
Ideally we would track the relative post created_at date and just plug it in to the timeline, but I don’t know if this is possible atm.
@david, do you have any ideas?
Yeah that would be ideal ![]()
If we use the right HTML structure, the automatic updating over time can be handled automatically by our relative-date helper.
To handle changes to the topic.last_posted_at value, we should be able to lean on Glimmer’s reactivity, rather than doing stuff on scroll. e.g.
get bottomAge(){
return this.args.topic.get("last_posted_at") || this.args.topic.get("created_at");
}
And then in the hbs we can use our relative age helper to render it in the right structure for the auto-updating
{{age-with-tooltip this.bottomAge}}
Might need to make some improvements to the helper so that it can support the ‘addAgo’ and ‘defaultFormat’ parameters?
This will be fixed via
https://github.com/discourse/discourse/pull/20665#pullrequestreview-1339566167