Centralize the code used for parsing invidious comments (#2780)
This commit is contained in:
@@ -240,18 +240,8 @@ export default Vue.extend({
|
||||
}
|
||||
},
|
||||
|
||||
getCommentDataInvidious: function () {
|
||||
const payload = {
|
||||
resource: 'comments',
|
||||
id: this.id,
|
||||
params: {
|
||||
continuation: this.nextPageToken ?? '',
|
||||
sort_by: this.sortNewest ? 'new' : 'top'
|
||||
}
|
||||
}
|
||||
|
||||
this.invidiousAPICall(payload).then((response) => {
|
||||
const commentData = response.comments.map((comment) => {
|
||||
parseInvidiousCommentData: function (response) {
|
||||
return response.comments.map((comment) => {
|
||||
comment.showReplies = false
|
||||
comment.authorLink = comment.authorId
|
||||
comment.authorThumb = comment.authorThumbnails[1].url.replace('https://yt3.ggpht.com', `${this.currentInvidiousInstance}/ggpht/`)
|
||||
@@ -279,6 +269,20 @@ export default Vue.extend({
|
||||
|
||||
return comment
|
||||
})
|
||||
},
|
||||
|
||||
getCommentDataInvidious: function () {
|
||||
const payload = {
|
||||
resource: 'comments',
|
||||
id: this.id,
|
||||
params: {
|
||||
continuation: this.nextPageToken ?? '',
|
||||
sort_by: this.sortNewest ? 'new' : 'top'
|
||||
}
|
||||
}
|
||||
|
||||
this.invidiousAPICall(payload).then((response) => {
|
||||
const commentData = this.parseInvidiousCommentData(response)
|
||||
|
||||
this.commentData = this.commentData.concat(commentData)
|
||||
this.nextPageToken = response.continuation
|
||||
@@ -310,24 +314,7 @@ export default Vue.extend({
|
||||
}
|
||||
|
||||
this.invidiousAPICall(payload).then((response) => {
|
||||
const commentData = response.comments.map((comment) => {
|
||||
comment.showReplies = false
|
||||
comment.authorLink = comment.authorId
|
||||
comment.authorThumb = comment.authorThumbnails[1].url.replace('https://yt3.ggpht.com', `${this.currentInvidiousInstance}/ggpht/`)
|
||||
if (this.hideCommentLikes) {
|
||||
comment.likes = null
|
||||
} else {
|
||||
comment.likes = comment.likeCount
|
||||
}
|
||||
comment.text = autolinker.link(comment.content.replace(/(<(?!br>)([^>]+)>)/ig, ''))
|
||||
comment.time = comment.publishedText
|
||||
comment.dataType = 'invidious'
|
||||
comment.numReplies = 0
|
||||
comment.replyContinuation = ''
|
||||
comment.replies = []
|
||||
|
||||
return comment
|
||||
})
|
||||
const commentData = this.parseInvidiousCommentData(response)
|
||||
|
||||
this.commentData[index].replies = commentData
|
||||
this.commentData[index].showReplies = true
|
||||
|
||||
Reference in New Issue
Block a user