From dc86ebe97ac4f8e0e0d861e719f86f65aef24f71 Mon Sep 17 00:00:00 2001 From: David Battersby Date: Fri, 7 Feb 2025 17:31:07 +0400 Subject: [PATCH] UX: omit date in user stream for small action posts (#31236) This change makes it possible to render the action code from small action posts (ie. close topic etc) without the relative date. This is applied in the user stream items to prevent duplication of dates. --- .../discourse/app/components/post-action-description.gjs | 2 +- .../javascripts/discourse/app/components/user-stream.gjs | 1 - .../discourse/app/widgets/post-small-action.js | 9 +++++---- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/app/assets/javascripts/discourse/app/components/post-action-description.gjs b/app/assets/javascripts/discourse/app/components/post-action-description.gjs index a433a565c32..94eabbe6479 100644 --- a/app/assets/javascripts/discourse/app/components/post-action-description.gjs +++ b/app/assets/javascripts/discourse/app/components/post-action-description.gjs @@ -3,7 +3,7 @@ import { actionDescriptionHtml } from "discourse/widgets/post-small-action"; export default class PostActionDescription extends Component { get description() { - if (this.args.actionCode && this.args.createdAt) { + if (this.args.actionCode) { return actionDescriptionHtml( this.args.actionCode, this.args.createdAt, diff --git a/app/assets/javascripts/discourse/app/components/user-stream.gjs b/app/assets/javascripts/discourse/app/components/user-stream.gjs index 7a385b84643..752259c2685 100644 --- a/app/assets/javascripts/discourse/app/components/user-stream.gjs +++ b/app/assets/javascripts/discourse/app/components/user-stream.gjs @@ -186,7 +186,6 @@ export default class UserStreamComponent extends Component { <:abovePostItemExcerpt as |post|> diff --git a/app/assets/javascripts/discourse/app/widgets/post-small-action.js b/app/assets/javascripts/discourse/app/widgets/post-small-action.js index 880c22050ba..5e6053fffc5 100644 --- a/app/assets/javascripts/discourse/app/widgets/post-small-action.js +++ b/app/assets/javascripts/discourse/app/widgets/post-small-action.js @@ -12,10 +12,11 @@ import { createWidget } from "discourse/widgets/widget"; import { i18n } from "discourse-i18n"; export function actionDescriptionHtml(actionCode, createdAt, username, path) { - const dt = new Date(createdAt); - const when = autoUpdatingRelativeAge(dt, { - format: "medium-with-ago-and-on", - }); + const when = createdAt + ? autoUpdatingRelativeAge(new Date(createdAt), { + format: "medium-with-ago-and-on", + }) + : ""; let who = ""; if (username) {