A platform for community discussion. Free, open, simple.
DEV: Small fixes and tweaks in the Glimmer Post Stream (#33112)
Sérgio Saquetim66564434330e
diff --git a/app/assets/javascripts/discourse/app/components/post-stream.gjs b/app/assets/javascripts/discourse/app/components/post-stream.gjsindex a6b06a75f3a..b815d2b2be1 100644--- a/app/assets/javascripts/discourse/app/components/post-stream.gjs+++ b/app/assets/javascripts/discourse/app/components/post-stream.gjs@@ -119,8 +119,8 @@ export default class PostStream extends Component {}daysBetween(post1, post2) {- const time1 = post1 ? new Date(post1.createdAt).getTime() : null;- const time2 = post2 ? new Date(post2.createdAt).getTime() : null;+ const time1 = post1 ? new Date(post1.created_at).getTime() : null;+ const time2 = post2 ? new Date(post2.created_at).getTime() : null;if (!time1 || !time2) {return null;diff --git a/app/assets/javascripts/discourse/app/components/post/links.gjs b/app/assets/javascripts/discourse/app/components/post/links.gjsindex 3792af7cd9c..9b99728eedf 100644--- a/app/assets/javascripts/discourse/app/components/post/links.gjs+++ b/app/assets/javascripts/discourse/app/components/post/links.gjs@@ -1,6 +1,7 @@import Component from "@glimmer/component";import { cached, tracked } from "@glimmer/tracking";import { action } from "@ember/object";+import { gt } from "truth-helpers";import DButton from "discourse/components/d-button";import icon from "discourse/helpers/d-icon";import replaceEmoji from "discourse/helpers/replace-emoji";@@ -51,7 +52,7 @@ export default class PostLinks extends Component {<li><aclass="track-link inbound"- data-clicks={{link.clicks}}+ data-clicks={{if (gt link.clicks 0) link.clicks}}href={{link.url}}>{{icon "link"}}diff --git a/app/assets/javascripts/discourse/app/components/post/time-gap.gjs b/app/assets/javascripts/discourse/app/components/post/time-gap.gjsindex 0551bca4eaf..776e4dd0f30 100644--- a/app/assets/javascripts/discourse/app/components/post/time-gap.gjs+++ b/app/assets/javascripts/discourse/app/components/post/time-gap.gjs@@ -17,9 +17,11 @@ export default class PostTimeGap extends Component {}<template>- <div class="topic-avatar"></div>- <div class="small-action-desc timegap">- {{this.description}}+ <div class="time-gap small-action">+ <div class="topic-avatar"></div>+ <div class="small-action-desc timegap">+ {{this.description}}+ </div></div></template>}diff --git a/app/assets/javascripts/discourse/tests/integration/components/post/post-links-test.gjs b/app/assets/javascripts/discourse/tests/integration/components/post/post-links-test.gjsindex 24b2b0484b9..19e1a0d13fd 100644--- a/app/assets/javascripts/discourse/tests/integration/components/post/post-links-test.gjs+++ b/app/assets/javascripts/discourse/tests/integration/components/post/post-links-test.gjs@@ -126,4 +126,33 @@ module("Integration | Component | Post | PostLinks", function (hooks) {assert.dom(".post-links a.track-link").exists({ count: 7 });assert.dom(".expand-links").doesNotExist("there is no expand button");});++ test("data-clicks", async function (assert) {+ this.post.link_counts = [+ {+ title: "Link 1",+ url: "/t/1",+ internal: true,+ reflection: true,+ clicks: 2,+ },+ {+ title: "Link 2",+ url: "/t/2",+ internal: true,+ reflection: true,+ clicks: 0,+ },+ ];++ await renderComponent(this.post);++ assert+ .dom(".post-links a.track-link[href='/t/1']")+ .hasAttribute("data-clicks", "2", "Link 1 has the correct click count");++ assert+ .dom(".post-links a.track-link[href='/t/2']")+ .doesNotHaveAttribute("data-clicks");+ });});diff --git a/app/assets/stylesheets/common/base/topic-post.scss b/app/assets/stylesheets/common/base/topic-post.scssindex dd1390a1837..1afa40e3501 100644--- a/app/assets/stylesheets/common/base/topic-post.scss+++ b/app/assets/stylesheets/common/base/topic-post.scss@@ -950,6 +950,10 @@ aside.quote {flex: 0 0 auto;margin-right: 0.5em;+ .btn {+ padding: revert;+ }+&.post-date {margin-right: 0;}@@ -988,6 +992,7 @@ aside.quote {}.d-icon {+ margin-right: 0;order: 1;color: var(--primary-med-or-secondary-med);}