Prevent `channelInstance` from being `null` in community tab fallback (#3346)

* Create `getChannelInstanceLocal` function

which allows channel instances for the local API
to be set within the community posts fallback

* Remove channel variable in `getChanneLocal`

* Switch playlist fallback to calling `getChannelPlaylistsLocal`

* Prevent accidentally refetching channel instance from Local API

* Add fallback for fetching more channel videos through invidious

similar to the fallback for playlists

* Use existing `getLocalChannel` instead of creating a new function
This commit is contained in:
Emma 2023-04-01 10:43:37 -04:00 committed by GitHub
parent 87ce511292
commit 2a9ec5ee10
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 15 additions and 4 deletions

View File

@ -402,7 +402,12 @@ export default defineComponent({
const expectedId = this.id
try {
const channel = await getLocalChannel(this.id)
let channel
if (!this.channelInstance) {
channel = await getLocalChannel(this.id)
} else {
channel = this.channelInstance
}
let channelName
let channelThumbnailUrl
@ -993,7 +998,7 @@ export default defineComponent({
this.playlistContinuationData = response.continuation || null
this.latestPlaylists = response.playlists
this.isElementListLoading = false
}).catch((err) => {
}).catch(async (err) => {
console.error(err)
const errorMessage = this.$t('Invidious API Error (Click to copy)')
showToast(`${errorMessage}: ${err}`, 10000, () => {
@ -1001,7 +1006,10 @@ export default defineComponent({
})
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
showToast(this.$t('Falling back to Local API'))
this.getChannelLocal()
if (!this.channelInstance) {
this.channelInstance = await getLocalChannel(this.id)
}
this.getChannelPlaylistsLocal()
} else {
this.isLoading = false
}
@ -1117,7 +1125,7 @@ export default defineComponent({
getCommunityPostsInvidious: function() {
invidiousGetCommunityPosts(this.id).then(posts => {
this.latestCommunityPosts = posts
}).catch((err) => {
}).catch(async (err) => {
console.error(err)
const errorMessage = this.$t('Invidious API Error (Click to copy)')
showToast(`${errorMessage}: ${err}`, 10000, () => {
@ -1125,6 +1133,9 @@ export default defineComponent({
})
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
showToast(this.$t('Falling back to Local API'))
if (!this.channelInstance) {
this.channelInstance = await getLocalChannel(this.id)
}
this.getCommunityPostsLocal()
}
})