mirror of
https://github.com/FreeTubeApp/FreeTube
synced 2024-12-12 04:29:49 +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 = {
|
||||
resource: 'channels',
|
||||
id: channelId,
|
||||
subResource: 'community'
|
||||
subResource: 'community',
|
||||
params: {}
|
||||
}
|
||||
|
||||
if (continuation) {
|
||||
payload.params.continuation = continuation
|
||||
}
|
||||
|
||||
const response = await invidiousAPICall(payload)
|
||||
response.comments = response.comments.map(communityPost => parseInvidiousCommunityData(communityPost))
|
||||
return response.comments
|
||||
return { posts: response.comments, continuation: response.continuation ?? null }
|
||||
}
|
||||
|
||||
function parseInvidiousCommunityData(data) {
|
||||
|
@ -1119,8 +1119,15 @@ export default defineComponent({
|
||||
},
|
||||
|
||||
getCommunityPostsInvidious: function() {
|
||||
invidiousGetCommunityPosts(this.id).then(posts => {
|
||||
this.latestCommunityPosts = posts
|
||||
const more = !isNullOrEmpty(this.communityContinuationData)
|
||||
|
||||
invidiousGetCommunityPosts(this.id, this.communityContinuationData).then(({ posts, continuation }) => {
|
||||
if (more) {
|
||||
this.latestCommunityPosts.push(...posts)
|
||||
} else {
|
||||
this.latestCommunityPosts = posts
|
||||
}
|
||||
this.communityContinuationData = continuation
|
||||
}).catch(async (err) => {
|
||||
console.error(err)
|
||||
const errorMessage = this.$t('Invidious API Error (Click to copy)')
|
||||
@ -1263,8 +1270,7 @@ export default defineComponent({
|
||||
this.getCommunityPostsLocalMore()
|
||||
break
|
||||
case 'invidious':
|
||||
// not supported by invidious yet...
|
||||
// this.getCommunityPostsInvidiousMore()
|
||||
this.getCommunityPostsInvidious()
|
||||
break
|
||||
}
|
||||
break
|
||||
|
Loading…
Reference in New Issue
Block a user