mirror of
https://github.com/FreeTubeApp/FreeTube
synced 2025-01-19 07:49:59 +01:00
IV: Allow fetching more community posts (#3466)
* Allow fetching more community posts with IV * Update src/renderer/views/Channel/Channel.js Co-authored-by: PikachuEXE <pikachuexe@gmail.com> --------- Co-authored-by: PikachuEXE <pikachuexe@gmail.com>
This commit is contained in:
parent
1c29745d98
commit
c197b5ac93
@ -145,16 +145,21 @@ function parseInvidiousCommentData(response) {
|
|||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function invidiousGetCommunityPosts(channelId) {
|
export async function invidiousGetCommunityPosts(channelId, continuation = null) {
|
||||||
const payload = {
|
const payload = {
|
||||||
resource: 'channels',
|
resource: 'channels',
|
||||||
id: channelId,
|
id: channelId,
|
||||||
subResource: 'community'
|
subResource: 'community',
|
||||||
|
params: {}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (continuation) {
|
||||||
|
payload.params.continuation = continuation
|
||||||
}
|
}
|
||||||
|
|
||||||
const response = await invidiousAPICall(payload)
|
const response = await invidiousAPICall(payload)
|
||||||
response.comments = response.comments.map(communityPost => parseInvidiousCommunityData(communityPost))
|
response.comments = response.comments.map(communityPost => parseInvidiousCommunityData(communityPost))
|
||||||
return response.comments
|
return { posts: response.comments, continuation: response.continuation ?? null }
|
||||||
}
|
}
|
||||||
|
|
||||||
function parseInvidiousCommunityData(data) {
|
function parseInvidiousCommunityData(data) {
|
||||||
|
@ -1119,8 +1119,15 @@ export default defineComponent({
|
|||||||
},
|
},
|
||||||
|
|
||||||
getCommunityPostsInvidious: function() {
|
getCommunityPostsInvidious: function() {
|
||||||
invidiousGetCommunityPosts(this.id).then(posts => {
|
const more = !isNullOrEmpty(this.communityContinuationData)
|
||||||
this.latestCommunityPosts = posts
|
|
||||||
|
invidiousGetCommunityPosts(this.id, this.communityContinuationData).then(({ posts, continuation }) => {
|
||||||
|
if (more) {
|
||||||
|
this.latestCommunityPosts.push(...posts)
|
||||||
|
} else {
|
||||||
|
this.latestCommunityPosts = posts
|
||||||
|
}
|
||||||
|
this.communityContinuationData = continuation
|
||||||
}).catch(async (err) => {
|
}).catch(async (err) => {
|
||||||
console.error(err)
|
console.error(err)
|
||||||
const errorMessage = this.$t('Invidious API Error (Click to copy)')
|
const errorMessage = this.$t('Invidious API Error (Click to copy)')
|
||||||
@ -1263,8 +1270,7 @@ export default defineComponent({
|
|||||||
this.getCommunityPostsLocalMore()
|
this.getCommunityPostsLocalMore()
|
||||||
break
|
break
|
||||||
case 'invidious':
|
case 'invidious':
|
||||||
// not supported by invidious yet...
|
this.getCommunityPostsInvidious()
|
||||||
// this.getCommunityPostsInvidiousMore()
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
break
|
break
|
||||||
|
Loading…
x
Reference in New Issue
Block a user