mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
UX: view count in topic map should always be at least 1 (#28447)
This commit is contained in:
parent
10ae7ef44a
commit
6c159241c9
@ -98,6 +98,10 @@ export default class TopicMapSummary extends Component {
|
|||||||
return [this.hasLikes, this.hasUsers, this.hasLinks].every(Boolean);
|
return [this.hasLikes, this.hasUsers, this.hasLinks].every(Boolean);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
get minViewsCount() {
|
||||||
|
return Math.max(this.args.topic.views, 1);
|
||||||
|
}
|
||||||
|
|
||||||
get shouldShowViewsChart() {
|
get shouldShowViewsChart() {
|
||||||
return this.views.stats.length > 2;
|
return this.views.stats.length > 2;
|
||||||
}
|
}
|
||||||
@ -249,9 +253,9 @@ export default class TopicMapSummary extends Component {
|
|||||||
@onShow={{this.fetchViews}}
|
@onShow={{this.fetchViews}}
|
||||||
>
|
>
|
||||||
<:trigger>
|
<:trigger>
|
||||||
{{number @topic.views noTitle="true"}}
|
{{number this.minViewsCount noTitle="true"}}
|
||||||
<span class="topic-map__stat-label">
|
<span class="topic-map__stat-label">
|
||||||
{{i18n "views_lowercase" count=@topic.views}}
|
{{i18n "views_lowercase" count=this.minViewsCount}}
|
||||||
</span>
|
</span>
|
||||||
</:trigger>
|
</:trigger>
|
||||||
<:content>
|
<:content>
|
||||||
|
@ -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;
|
return stats;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user