Skip to content

Commit

Permalink
Fix Hide Channel Subscribers setting still displaying subscribers if …
Browse files Browse the repository at this point in the history
…changed from a secondary window (FreeTubeApp#3504) (FreeTubeApp#3692)

* Fix Hide Channel Subscribers setting still displaying subscribers if changed from a secondary window (FreeTubeApp#3504)

* Revert naming change subscriptionCountText to channelSubCountText

* Use `!=` instead of `!==` for `subscriberCount` in ft-list-channel

* Set subscriberCount to null if `data.subscribers` is null in ft-list-channel.js

Co-authored-by: absidue <[email protected]>

---------

Co-authored-by: absidue <[email protected]>
  • Loading branch information
Rikthepixel and absidue authored Jun 25, 2023
1 parent b0eb157 commit 96835dd
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 35 deletions.
13 changes: 3 additions & 10 deletions src/renderer/components/ft-list-channel/ft-list-channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,8 @@ export default defineComponent({

this.channelName = this.data.name
this.id = this.data.id
if (this.hideChannelSubscriptions || this.data.subscribers == null) {
this.subscriberCount = null
} else {
this.subscriberCount = this.data.subscribers.replace(/ subscriber(s)?/, '')
}
this.subscriberCount = this.data.subscribers != null ? this.data.subscribers.replace(/ subscriber(s)?/, '') : null

if (this.data.videos === null) {
this.videoCount = 0
} else {
Expand All @@ -79,11 +76,7 @@ export default defineComponent({

this.channelName = this.data.author
this.id = this.data.authorId
if (this.hideChannelSubscriptions) {
this.subscriberCount = null
} else {
this.subscriberCount = formatNumber(this.data.subCount)
}
this.subscriberCount = formatNumber(this.data.subCount)
this.videoCount = formatNumber(this.data.videoCount)
this.description = this.data.description
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@
</router-link>
<div class="infoLine">
<span
v-if="subscriberCount !== null"
v-if="subscriberCount !== null && !hideChannelSubscriptions"
class="subscriberCount"
>
{{ subscriberCount }} subscribers -
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,9 +50,13 @@ export default defineComponent({
return this.subscriptionInfo !== null
},

hideChannelSubscriptions: function () {
return this.$store.getters.getHideChannelSubscriptions
},

subscribedText: function () {
let subscribedValue = (this.isSubscribed ? this.$t('Channel.Unsubscribe') : this.$t('Channel.Subscribe')).toUpperCase()
if (this.subscriptionCountText !== '') {
if (this.subscriptionCountText !== '' && !this.hideChannelSubscriptions) {
subscribedValue += ' ' + this.subscriptionCountText
}
return subscribedValue
Expand Down
8 changes: 2 additions & 6 deletions src/renderer/views/Channel/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -559,7 +559,7 @@ export default defineComponent({

document.title = `${channelName} - ${packageDetails.productName}`

if (!this.hideChannelSubscriptions && subscriberText) {
if (subscriberText) {
const subCount = parseLocalSubscriberCount(subscriberText)

if (isNaN(subCount)) {
Expand Down Expand Up @@ -864,11 +864,7 @@ export default defineComponent({
document.title = `${this.channelName} - ${packageDetails.productName}`
this.id = channelId
this.isFamilyFriendly = response.isFamilyFriendly
if (this.hideChannelSubscriptions) {
this.subCount = null
} else {
this.subCount = response.subCount
}
this.subCount = response.subCount
const thumbnail = response.authorThumbnails[3].url
this.thumbnailUrl = youtubeImageUrlToInvidious(thumbnail, this.currentInvidiousInstance)
this.updateSubscriptionDetails({ channelThumbnailUrl: thumbnail, channelName: channelName, channelId: channelId })
Expand Down
2 changes: 1 addition & 1 deletion src/renderer/views/Channel/Channel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
</h1>

<p
v-if="subCount !== null"
v-if="subCount !== null && !hideChannelSubscriptions"
class="channelSubCount"
>
{{ formattedSubCount }}
Expand Down
21 changes: 5 additions & 16 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -357,18 +357,10 @@ export default defineComponent({
this.isUpcoming = !!result.basic_info.is_upcoming
this.isLiveContent = !!result.basic_info.is_live_content

if (!this.hideChannelSubscriptions) {
const subCount = parseLocalSubscriberCount(result.secondary_info.owner.subscriber_count.text)
const subCount = parseLocalSubscriberCount(result.secondary_info.owner.subscriber_count.text)

if (!isNaN(subCount)) {
if (subCount >= 10000) {
this.channelSubscriptionCountText = formatNumber(subCount, { notation: 'compact' })
} else {
this.channelSubscriptionCountText = formatNumber(subCount)
}
} else {
this.channelSubscriptionCountText = ''
}
if (!isNaN(subCount)) {
this.channelSubscriptionCountText = formatNumber(subCount, subCount >= 10000 ? { notation: 'compact' } : undefined)
} else {
this.channelSubscriptionCountText = ''
}
Expand Down Expand Up @@ -720,18 +712,15 @@ export default defineComponent({

this.videoTitle = result.title
this.videoViewCount = result.viewCount
this.channelSubscriptionCountText = result.subCountText || 'FT-0'
if (this.hideVideoLikesAndDislikes) {
this.videoLikeCount = null
this.videoDislikeCount = null
} else {
this.videoLikeCount = result.likeCount
this.videoDislikeCount = result.dislikeCount
}
if (this.hideChannelSubscriptions) {
this.channelSubscriptionCountText = ''
} else {
this.channelSubscriptionCountText = result.subCountText || 'FT-0'
}

this.channelId = result.authorId
this.channelName = result.author
const channelThumb = result.authorThumbnails[1]
Expand Down

0 comments on commit 96835dd

Please sign in to comment.