diff --git a/app/assets/javascripts/discourse/app/models/bookmark.js b/app/assets/javascripts/discourse/app/models/bookmark.js index 8926d121c0b..ecefa58e4b1 100644 --- a/app/assets/javascripts/discourse/app/models/bookmark.js +++ b/app/assets/javascripts/discourse/app/models/bookmark.js @@ -89,10 +89,17 @@ const Bookmark = RestModel.extend({ @discourseComputed("bumpedAt", "createdAt") bumpedAtTitle(bumpedAt, createdAt) { - return I18n.t("topic.bumped_at_title", { - createdAtDate: longDate(createdAt), - bumpedAtDate: longDate(bumpedAt), - }); + const BUMPED_FORMAT = "YYYY-MM-DDTHH:mm:ss"; + if (moment(bumpedAt).isValid() && moment(createdAt).isValid()) { + const bumpedAtStr = moment(bumpedAt).format(BUMPED_FORMAT); + const createdAtStr = moment(createdAt).format(BUMPED_FORMAT); + + return bumpedAtStr !== createdAtStr + ? `${I18n.t("topic.created_at", { + date: longDate(createdAt), + })}\n${I18n.t("topic.bumped_at", { date: longDate(bumpedAt) })}` + : I18n.t("topic.created_at", { date: longDate(createdAt) }); + } }, @discourseComputed("created_at") diff --git a/app/assets/javascripts/discourse/app/models/topic.js b/app/assets/javascripts/discourse/app/models/topic.js index 2c66fdb759b..d166e0373ad 100644 --- a/app/assets/javascripts/discourse/app/models/topic.js +++ b/app/assets/javascripts/discourse/app/models/topic.js @@ -127,10 +127,17 @@ const Topic = RestModel.extend({ @discourseComputed("bumpedAt", "createdAt") bumpedAtTitle(bumpedAt, createdAt) { - return I18n.t("topic.bumped_at_title", { - createdAtDate: longDate(createdAt), - bumpedAtDate: longDate(bumpedAt), - }); + const BUMPED_FORMAT = "YYYY-MM-DDTHH:mm:ss"; + if (moment(bumpedAt).isValid() && moment(createdAt).isValid()) { + const bumpedAtStr = moment(bumpedAt).format(BUMPED_FORMAT); + const createdAtStr = moment(createdAt).format(BUMPED_FORMAT); + + return bumpedAtStr !== createdAtStr + ? `${I18n.t("topic.created_at", { + date: longDate(createdAt), + })}\n${I18n.t("topic.bumped_at", { date: longDate(bumpedAt) })}` + : I18n.t("topic.created_at", { date: longDate(createdAt) }); + } }, @discourseComputed("created_at") diff --git a/config/locales/client.en.yml b/config/locales/client.en.yml index c5dbe5b15b5..78bde99d0b5 100644 --- a/config/locales/client.en.yml +++ b/config/locales/client.en.yml @@ -3013,9 +3013,8 @@ en: other {} } - bumped_at_title: | - First post: %{createdAtDate} - Posted: %{bumpedAtDate} + created_at: "Created: %{date}" + bumped_at: "Latest: %{date}" browse_all_categories_latest: "Browse all categories or view latest topics." browse_all_categories_latest_or_top: "Browse all categories, view latest topics or see top:"