simplify v-if

Co-Authored-By: PikachuEXE <pikachuexe@gmail.com>
This commit is contained in:
chunky programmer 2023-05-10 22:26:31 -04:00
parent c5244b0bd4
commit b883d8328d
2 changed files with 6 additions and 4 deletions

View File

@ -22,7 +22,7 @@ export default defineComponent({
channelName: '',
channelId: '',
videoCount: 0,
viewCount: 0,
viewCount: null,
lastUpdated: '',
description: '',
infoSource: ''
@ -70,8 +70,10 @@ export default defineComponent({
this.infoSource = this.data.infoSource
// Causes errors if not put inside of a check
if (typeof (this.data.viewCount) !== 'undefined' && !isNaN(this.data.viewCount)) {
this.viewCount = this.hideViews ? null : formatNumber(this.data.viewCount)
if (this.data.viewCount != null) {
// youtube displays 'No views' instead of 0 views for NaN viewCounts
const views = isNaN(this.data.viewCount) ? 0 : this.data.viewCount
this.viewCount = this.hideViews ? null : formatNumber(views)
}
if (typeof (this.data.videoCount) !== 'undefined' && !isNaN(this.data.videoCount)) {

View File

@ -22,7 +22,7 @@
{{ title }}
</h2>
<p>
{{ videoCount }} {{ $t("Playlist.Videos") }} <span v-if="!hideViews && infoSource !== 'piped'">- {{ viewCount }} {{ $t("Playlist.Views") }} </span>
{{ videoCount }} {{ $t("Playlist.Videos") }} <span v-if="viewCount != null">- {{ viewCount }} {{ $t("Playlist.Views") }} </span>
<span v-if="infoSource === 'local'"> - </span>
<span v-if="infoSource === 'invidious'"> - {{ $t("Playlist.Last Updated On") }}</span>
{{ lastUpdated }}