diff --git a/app/assets/javascripts/discourse/app/components/topic-map/topic-map-summary.gjs b/app/assets/javascripts/discourse/app/components/topic-map/topic-map-summary.gjs index 0979302d0d1..189f2a71b4f 100644 --- a/app/assets/javascripts/discourse/app/components/topic-map/topic-map-summary.gjs +++ b/app/assets/javascripts/discourse/app/components/topic-map/topic-map-summary.gjs @@ -98,6 +98,10 @@ export default class TopicMapSummary extends Component { return [this.hasLikes, this.hasUsers, this.hasLinks].every(Boolean); } + get minViewsCount() { + return Math.max(this.args.topic.views, 1); + } + get shouldShowViewsChart() { return this.views.stats.length > 2; } @@ -249,9 +253,9 @@ export default class TopicMapSummary extends Component { @onShow={{this.fetchViews}} > <:trigger> - {{number @topic.views noTitle="true"}} + {{number this.minViewsCount noTitle="true"}} - {{i18n "views_lowercase" count=@topic.views}} + {{i18n "views_lowercase" count=this.minViewsCount}} <:content> diff --git a/app/assets/javascripts/discourse/app/components/topic-map/topic-views.gjs b/app/assets/javascripts/discourse/app/components/topic-map/topic-views.gjs index 254a9135964..93e6118d178 100644 --- a/app/assets/javascripts/discourse/app/components/topic-map/topic-views.gjs +++ b/app/assets/javascripts/discourse/app/components/topic-map/topic-views.gjs @@ -58,6 +58,11 @@ export default class TopicViews extends Component { }; }); + // today should always have at least 1 view + // because it's being viewed right now + const lastStat = stats[stats.length - 1]; + lastStat.views = Math.max(lastStat.views, 1); + return stats; }