Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 1 addition & 4 deletions src/renderer/views/Channel/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -170,10 +170,7 @@ export default defineComponent({
},

isSubscribedInAnyProfile: function () {
const profileList = this.$store.getters.getProfileList

// check the all channels profile
return profileList[0].subscriptions.some((channel) => channel.id === this.id)
return this.$store.getters.getSubscribedChannelIdSet.has(this.id)
},

videoLiveShortSelectValues: function () {
Expand Down
42 changes: 42 additions & 0 deletions src/renderer/views/Search/Search.js
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,8 @@ export default defineComponent({
}

this.$store.commit('addToSessionSearchHistory', historyPayload)

this.updateSubscriptionDetails(results)
} catch (err) {
console.error(err)
const errorMessage = this.$t('Local API Error (Click to copy)')
Expand Down Expand Up @@ -194,6 +196,8 @@ export default defineComponent({
}

this.$store.commit('addToSessionSearchHistory', historyPayload)

this.updateSubscriptionDetails(results)
} catch (err) {
console.error(err)
const errorMessage = this.$t('Local API Error (Click to copy)')
Expand Down Expand Up @@ -263,6 +267,8 @@ export default defineComponent({
}

this.$store.commit('addToSessionSearchHistory', historyPayload)

this.updateSubscriptionDetails(returnData)
}).catch((err) => {
console.error(err)
const errorMessage = this.$t('Invidious API Error (Click to copy)')
Expand Down Expand Up @@ -318,6 +324,42 @@ export default defineComponent({

// This is kept in case there is some race condition
this.isLoading = false
},

/**
* @param {any[]} results
*/
updateSubscriptionDetails: function (results) {
/** @type {Set<string>} */
const subscribedChannelIds = this.$store.getters.getSubscribedChannelIdSet

const channels = []

for (const result of results) {
if (result.type !== 'channel' || !subscribedChannelIds.has(result.id ?? result.authorId)) {
continue
}

if (result.dataSource === 'local') {
channels.push({
channelId: result.id,
channelName: result.name,
channelThumbnailUrl: result.thumbnail.replace(/^\/\//, 'https://')
})
} else {
channels.push({
channelId: result.authorId,
channelName: result.author,
channelThumbnailUrl: result.authorThumbnails[0].url.replace(/^\/\//, 'https://')
})
}
}

if (channels.length === 1) {
this.$store.dispatch('updateSubscriptionDetails', channels[0])
} else if (channels.length > 1) {
this.$store.dispatch('batchUpdateSubscriptionDetails', channels)
}
}
}
})