mirror of https://github.com/FreeTubeApp/FreeTube
fix comment and playlist fallbacks
This commit is contained in:
parent
3633a86ac3
commit
3b4ee5990f
|
@ -41,7 +41,11 @@ export default defineComponent({
|
|||
},
|
||||
computed: {
|
||||
backendPreference: function () {
|
||||
return this.$store.getters.getBackendPreference
|
||||
let preference = this.$store.getters.getBackendPreference
|
||||
if (preference === 'piped') {
|
||||
preference = this.$store.getters.getFallbackPreference
|
||||
}
|
||||
return preference
|
||||
},
|
||||
currentInvidiousInstance: function () {
|
||||
return this.$store.getters.getCurrentInvidiousInstance
|
||||
|
|
|
@ -33,7 +33,11 @@ export default defineComponent({
|
|||
},
|
||||
computed: {
|
||||
backendPreference: function () {
|
||||
return this.$store.getters.getBackendPreference
|
||||
let preference = this.$store.getters.getBackendPreference
|
||||
if (preference === 'piped') {
|
||||
preference = this.$store.getters.getFallbackPreference
|
||||
}
|
||||
return preference
|
||||
},
|
||||
currentInvidiousInstance: function () {
|
||||
return this.$store.getters.getCurrentInvidiousInstance
|
||||
|
|
|
@ -62,7 +62,11 @@ export default defineComponent({
|
|||
},
|
||||
computed: {
|
||||
backendPreference: function () {
|
||||
return this.$store.getters.getBackendPreference
|
||||
let preference = this.$store.getters.getBackendPreference
|
||||
if (preference === 'piped') {
|
||||
preference = this.$store.getters.getFallbackPreference
|
||||
}
|
||||
return preference
|
||||
},
|
||||
|
||||
autoplayVideos: function () {
|
||||
|
|
|
@ -44,15 +44,15 @@ export default defineComponent({
|
|||
},
|
||||
computed: {
|
||||
backendPreference: function () {
|
||||
let preference = this.$store.getters.getBackendPreference
|
||||
if (preference === 'piped') {
|
||||
preference = this.$store.getters.getFallbackPreference
|
||||
}
|
||||
return preference
|
||||
return this.$store.getters.getBackendPreference
|
||||
},
|
||||
|
||||
fallbackPreference: function () {
|
||||
return this.$store.getters.getFallbackPreference
|
||||
},
|
||||
|
||||
backendFallback: function () {
|
||||
return this.$store.getters.getBackendFallback && this.$store.getters.getBackendPreference !== 'piped'
|
||||
return this.$store.getters.getBackendFallback
|
||||
},
|
||||
|
||||
hideCommentLikes: function () {
|
||||
|
@ -207,8 +207,13 @@ export default defineComponent({
|
|||
copyToClipboard(err)
|
||||
})
|
||||
if (this.backendFallback && this.backendPreference === 'local') {
|
||||
showToast(this.$t('Falling back to Invidious API'))
|
||||
this.getCommentDataInvidious()
|
||||
if (this.fallbackPreference === 'invidious') {
|
||||
showToast(this.$t('Falling back to Invidious API'))
|
||||
this.getCommentDataInvidious()
|
||||
} else if (this.fallbackPreference === 'piped') {
|
||||
showToast(this.$t('Falling back to Piped API'))
|
||||
this.getCommentDataPiped()
|
||||
}
|
||||
} else {
|
||||
this.isLoading = false
|
||||
}
|
||||
|
@ -240,8 +245,13 @@ export default defineComponent({
|
|||
copyToClipboard(err)
|
||||
})
|
||||
if (this.backendFallback && this.backendPreference === 'local') {
|
||||
showToast(this.$t('Falling back to Invidious API'))
|
||||
this.getCommentDataInvidious()
|
||||
if (this.fallbackPreference === 'invidious') {
|
||||
showToast(this.$t('Falling back to Invidious API'))
|
||||
this.getCommentDataInvidious()
|
||||
} else if (this.fallbackPreference === 'piped') {
|
||||
showToast(this.$t('Falling back to Piped API'))
|
||||
this.getCommentDataPiped()
|
||||
}
|
||||
} else {
|
||||
this.isLoading = false
|
||||
}
|
||||
|
@ -249,27 +259,65 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
getCommentDataPiped: async function () {
|
||||
const { comments, continuation } = await getPipedComments(this.id)
|
||||
this.commentData = comments
|
||||
this.nextPageToken = continuation
|
||||
this.isLoading = false
|
||||
this.showComments = true
|
||||
try {
|
||||
const { comments, continuation } = await getPipedComments(this.id)
|
||||
this.commentData = comments
|
||||
this.nextPageToken = continuation
|
||||
this.isLoading = false
|
||||
this.showComments = true
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
const errorMessage = this.$t('Piped API Error (Click to copy)')
|
||||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (this.backendFallback && this.backendPreference === 'piped') {
|
||||
if (this.fallbackPreference === 'invidious') {
|
||||
showToast(this.$t('Falling back to Invidious API'))
|
||||
this.getCommentDataInvidious()
|
||||
} else if (process.env.IS_ELECTRON && this.fallbackPreference === 'local') {
|
||||
showToast(this.$t('Falling back to local API'))
|
||||
this.getCommentDataLocal()
|
||||
}
|
||||
} else {
|
||||
this.isLoading = false
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getCommentDataPipedMore: async function(token, index = null) {
|
||||
const { comments, continuation } = await getPipedCommentsMore({
|
||||
videoId: this.id,
|
||||
continuation: token
|
||||
})
|
||||
if (index !== null) {
|
||||
this.commentData[index].replies = this.commentData[index].replies.concat(comments)
|
||||
this.commentData[index].showReplies = true
|
||||
this.commentData[index].replyToken = continuation
|
||||
} else {
|
||||
this.commentData = this.commentData.concat(comments)
|
||||
this.nextPageToken = continuation
|
||||
try {
|
||||
const { comments, continuation } = await getPipedCommentsMore({
|
||||
videoId: this.id,
|
||||
continuation: token
|
||||
})
|
||||
if (index !== null) {
|
||||
this.commentData[index].replies = this.commentData[index].replies.concat(comments)
|
||||
this.commentData[index].showReplies = true
|
||||
this.commentData[index].replyToken = continuation
|
||||
} else {
|
||||
this.commentData = this.commentData.concat(comments)
|
||||
this.nextPageToken = continuation
|
||||
}
|
||||
this.isLoading = false
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
const errorMessage = this.$t('Piped API Error (Click to copy)')
|
||||
showToast(`${errorMessage}: ${err}`, 10000, () => {
|
||||
copyToClipboard(err)
|
||||
})
|
||||
if (this.backendFallback && this.backendPreference === 'piped') {
|
||||
if (this.fallbackPreference === 'invidious') {
|
||||
showToast(this.$t('Falling back to Invidious API'))
|
||||
this.getCommentDataInvidious()
|
||||
} else if (process.env.IS_ELECTRON && this.fallbackPreference === 'local') {
|
||||
showToast(this.$t('Falling back to local API'))
|
||||
this.getCommentDataLocal()
|
||||
}
|
||||
} else {
|
||||
this.isLoading = false
|
||||
}
|
||||
}
|
||||
this.isLoading = false
|
||||
},
|
||||
|
||||
getCommentDataInvidious: function () {
|
||||
|
@ -288,9 +336,14 @@ export default defineComponent({
|
|||
showToast(`${errorMessage}: ${xhr.responseText}`, 10000, () => {
|
||||
copyToClipboard(xhr.responseText)
|
||||
})
|
||||
if (process.env.IS_ELECTRON && this.backendFallback && this.backendPreference === 'invidious') {
|
||||
showToast(this.$t('Falling back to local API'))
|
||||
this.getCommentDataLocal()
|
||||
if (this.backendFallback && this.backendPreference === 'invidious') {
|
||||
if (this.fallbackPreference === 'piped') {
|
||||
showToast(this.$t('Falling back to Piped API'))
|
||||
this.getCommentDataPiped()
|
||||
} else if (process.env.IS_ELECTRON && this.fallbackPreference === 'local') {
|
||||
showToast(this.$t('Falling back to local API'))
|
||||
this.getCommentDataLocal()
|
||||
}
|
||||
} else {
|
||||
this.isLoading = false
|
||||
}
|
||||
|
|
|
@ -398,9 +398,11 @@ export default defineComponent({
|
|||
if (this.fallbackPreference === 'invidious') {
|
||||
showToast(this.$t('Falling back to Invidious API'))
|
||||
this.getPlaylistInformationInvidious()
|
||||
} else {
|
||||
} else if (process.env.IS_ELECTRON && this.fallbackPreference === 'local') {
|
||||
showToast(this.$t('Falling back to Piped API'))
|
||||
this.getPlaylistInformationLocal()
|
||||
} else {
|
||||
this.isLoading = false
|
||||
}
|
||||
} else {
|
||||
this.isLoading = false
|
||||
|
|
|
@ -45,8 +45,10 @@ export default defineComponent({
|
|||
},
|
||||
computed: {
|
||||
backendPreference: function () {
|
||||
return 'piped'
|
||||
// return this.$store.getters.getBackendPreference
|
||||
return this.$store.getters.getBackendPreference
|
||||
},
|
||||
fallbackPreference: function () {
|
||||
return this.$store.getters.getFallbackPreference
|
||||
},
|
||||
backendFallback: function () {
|
||||
return this.$store.getters.getBackendFallback
|
||||
|
@ -117,8 +119,13 @@ export default defineComponent({
|
|||
}).catch((err) => {
|
||||
console.error(err)
|
||||
if (this.backendPreference === 'local' && this.backendFallback) {
|
||||
console.warn('Falling back to Invidious API')
|
||||
this.getPlaylistInvidious()
|
||||
if (this.fallbackPreference === 'invidious') {
|
||||
console.warn('Falling back to Invidious API')
|
||||
this.getPlaylistInvidious()
|
||||
} else {
|
||||
console.warn('Falling back to Piped API')
|
||||
this.getPlaylistPiped()
|
||||
}
|
||||
} else {
|
||||
this.isLoading = false
|
||||
}
|
||||
|
@ -156,9 +163,16 @@ export default defineComponent({
|
|||
this.isLoading = false
|
||||
}).catch((err) => {
|
||||
console.error(err)
|
||||
if (process.env.IS_ELECTRON && this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
console.warn('Error getting data with Invidious, falling back to local backend')
|
||||
this.getPlaylistLocal()
|
||||
if (this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.IS_ELECTRON && this.fallbackPreference === 'local') {
|
||||
console.warn('Error getting data with Invidious, falling back to local backend')
|
||||
this.getPlaylistLocal()
|
||||
} else if (this.fallbackPreference === 'piped') {
|
||||
console.warn('Error getting data with Invidious, falling back to Piped backend')
|
||||
this.getPlaylistPiped()
|
||||
} else {
|
||||
this.isLoading = false
|
||||
}
|
||||
} else {
|
||||
this.isLoading = false
|
||||
// TODO: Show toast with error message
|
||||
|
@ -167,18 +181,36 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
getPlaylistPiped: async function () {
|
||||
this.isLoading = true
|
||||
const { playlist, videos, nextpage } = await getPipedPlaylist(this.playlistId)
|
||||
this.infoData = playlist
|
||||
this.continuationData = nextpage
|
||||
this.playlistItems = this.playlistItems.concat(videos)
|
||||
try {
|
||||
this.isLoading = true
|
||||
const { playlist, videos, nextpage } = await getPipedPlaylist(this.playlistId)
|
||||
this.infoData = playlist
|
||||
this.continuationData = nextpage
|
||||
this.playlistItems = this.playlistItems.concat(videos)
|
||||
|
||||
this.updateSubscriptionDetails({
|
||||
channelThumbnailUrl: pipedImageToYouTube(playlist.channelThumbnail),
|
||||
channelName: playlist.channelName,
|
||||
channelId: playlist.channelId
|
||||
})
|
||||
this.isLoading = false
|
||||
this.updateSubscriptionDetails({
|
||||
channelThumbnailUrl: pipedImageToYouTube(playlist.channelThumbnail),
|
||||
channelName: playlist.channelName,
|
||||
channelId: playlist.channelId
|
||||
})
|
||||
this.isLoading = false
|
||||
} catch (err) {
|
||||
console.error(err)
|
||||
if (this.backendPreference === 'invidious' && this.backendFallback) {
|
||||
if (process.env.IS_ELECTRON && this.fallbackPreference === 'local') {
|
||||
console.warn('Error getting data with Piped, falling back to local backend')
|
||||
this.getPlaylistLocal()
|
||||
} else if (this.fallbackPreference === 'invidious') {
|
||||
console.warn('Error getting data with Piped, falling back to Invidious backend')
|
||||
this.getPlaylistPiped()
|
||||
} else {
|
||||
this.isLoading = false
|
||||
}
|
||||
} else {
|
||||
this.isLoading = false
|
||||
// TODO: Show toast with error message
|
||||
}
|
||||
}
|
||||
},
|
||||
|
||||
getNextPage: function () {
|
||||
|
|
|
@ -59,7 +59,11 @@ export default defineComponent({
|
|||
},
|
||||
|
||||
backendPreference: function () {
|
||||
return this.$store.getters.getBackendPreference
|
||||
let preference = this.$store.getters.getBackendPreference
|
||||
if (preference === 'piped') {
|
||||
preference = this.$store.getters.getFallbackPreference
|
||||
}
|
||||
return preference
|
||||
},
|
||||
|
||||
currentInvidiousInstance: function () {
|
||||
|
|
|
@ -848,6 +848,7 @@ Tooltips:
|
|||
# Toast Messages
|
||||
Local API Error (Click to copy): Local API Error (Click to copy)
|
||||
Invidious API Error (Click to copy): Invidious API Error (Click to copy)
|
||||
Piped API Error (Click to copy): Piped API Error (Click to copy)
|
||||
Falling back to Invidious API: Falling back to Invidious API
|
||||
Falling back to Piped API: Falling back to Piped API
|
||||
Falling back to the local API: Falling back to the local API
|
||||
|
|
Loading…
Reference in New Issue