Allow comment sorting with the Invidious API

This commit is contained in:
Preston 2020-10-08 10:06:06 -04:00
parent 36c4d17ac4
commit 2916f8b35a
1 changed files with 14 additions and 4 deletions

View File

@ -72,7 +72,16 @@ export default Vue.extend({
handleSortChange: function (sortType) { handleSortChange: function (sortType) {
this.sortNewest = !this.sortNewest this.sortNewest = !this.sortNewest
this.getCommentData(true) switch (this.backendPreference) {
case 'local':
this.getCommentDataLocal(true)
break
case 'invidious':
this.isLoading = true
this.commentData = []
this.getCommentDataInvidious(null)
break
}
}, },
getCommentData: function (sortChanged = false) { getCommentData: function (sortChanged = false) {
@ -186,7 +195,8 @@ export default Vue.extend({
resource: 'comments', resource: 'comments',
id: this.id, id: this.id,
params: { params: {
continuation: this.nextPageToken continuation: this.nextPageToken,
sort_by: this.sortNewest ? 'new' : 'top'
} }
} }
@ -201,7 +211,7 @@ export default Vue.extend({
} else { } else {
comment.likes = comment.likeCount comment.likes = comment.likeCount
} }
comment.text = comment.content comment.text = autolinker.link(comment.content)
comment.dataType = 'invidious' comment.dataType = 'invidious'
if (typeof (comment.replies) !== 'undefined' && typeof (comment.replies.replyCount) !== 'undefined') { if (typeof (comment.replies) !== 'undefined' && typeof (comment.replies.replyCount) !== 'undefined') {
@ -269,7 +279,7 @@ export default Vue.extend({
} else { } else {
comment.likes = comment.likeCount comment.likes = comment.likeCount
} }
comment.text = comment.content comment.text = autolinker.link(comment.content)
comment.time = comment.publishedText comment.time = comment.publishedText
comment.dataType = 'invidious' comment.dataType = 'invidious'
comment.numReplies = 0 comment.numReplies = 0