Skip to content

Commit

Permalink
Assign authorId to posts in the parsing functions (FreeTubeApp#5936)
Browse files Browse the repository at this point in the history
  • Loading branch information
absidue authored and Soham456 committed Dec 5, 2024
1 parent 4ce85c3 commit 64debe9
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -235,9 +235,7 @@ export default defineComponent({
this.errorChannels.push(channel)
return []
}
entries.forEach(post => {
post.authorId = channel.id
})

return entries
} catch (err) {
console.error(err)
Expand All @@ -256,9 +254,6 @@ export default defineComponent({
getChannelPostsInvidious: function (channel) {
return new Promise((resolve, reject) => {
invidiousGetCommunityPosts(channel.id).then(result => {
result.posts.forEach(post => {
post.authorId = channel.id
})
resolve(result.posts)
}).catch((err) => {
console.error(err)
Expand Down
1 change: 1 addition & 0 deletions src/renderer/helpers/api/invidious.js
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,7 @@ function parseInvidiousCommunityData(data) {
voteCount: data.likeCount,
postContent: parseInvidiousCommunityAttachments(data.attachment),
commentCount: data?.replyCount ?? 0, // https://github.com/iv-org/invidious/pull/3635/
authorId: data.authorId,
author: data.author,
type: 'community'
}
Expand Down
1 change: 1 addition & 0 deletions src/renderer/helpers/api/local.js
Original file line number Diff line number Diff line change
Expand Up @@ -1489,6 +1489,7 @@ function parseLocalCommunityPost(post) {
voteCount: post.vote_count ? parseLocalSubscriberCount(post.vote_count.text) : 0,
postContent: parseLocalAttachment(post.attachment),
commentCount: replyCount,
authorId: post.author.id,
author: post.author.name,
type: 'community'
}
Expand Down
9 changes: 0 additions & 9 deletions src/renderer/views/Channel/Channel.js
Original file line number Diff line number Diff line change
Expand Up @@ -1697,9 +1697,6 @@ export default defineComponent({
this.communityContinuationData = communityTab.has_continuation ? communityTab : null

if (this.latestCommunityPosts.length > 0) {
this.latestCommunityPosts.forEach(post => {
post.authorId = this.id
})
this.updateSubscriptionPostsCacheByChannel({
channelId: this.id,
// create a copy so that we only cache the first page
Expand Down Expand Up @@ -1761,9 +1758,6 @@ export default defineComponent({
this.communityContinuationData = continuation

if (this.isSubscribedInAnyProfile && !more && this.latestCommunityPosts.length > 0) {
this.latestCommunityPosts.forEach(post => {
post.authorId = this.id
})
this.updateSubscriptionPostsCacheByChannel({
channelId: this.id,
// create a copy so that we only cache the first page
Expand Down Expand Up @@ -2009,9 +2003,6 @@ export default defineComponent({
})
}

this.latestCommunityPosts.forEach(post => {
post.authorId = this.id
})
this.updateSubscriptionPostsCacheByChannel({
channelId: this.id,
posts: [...this.latestCommunityPosts]
Expand Down

0 comments on commit 64debe9

Please sign in to comment.