Merge pull request #597 from GilgusMaximus/development

Comment sorting and comment day time display
This commit is contained in:
Luca Hohmann 2020-10-05 20:02:24 +02:00 committed by GitHub
commit f761a679b6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 19 additions and 16 deletions

6
package-lock.json generated
View File

@ -20706,9 +20706,9 @@
}
},
"yt-comment-scraper": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/yt-comment-scraper/-/yt-comment-scraper-1.2.0.tgz",
"integrity": "sha512-XVQijojldm4ztqT8GnS4YJAJYxJelEE4zTdYHiup0BRYnNMbo8p4/W3lHLcbx/6FamKBdCyCSieM4RM98li4Pw==",
"version": "1.3.2",
"resolved": "https://registry.npmjs.org/yt-comment-scraper/-/yt-comment-scraper-1.3.2.tgz",
"integrity": "sha512-i2e+7ZNm5Dvdwsk3W8UyKtxR2xjtcMfUVGUjxVAR31HlEb8wE66XslDr5eIxSCpbhCLV7ItbmvL8NGL3D1TSxw==",
"requires": {
"axios": "^0.19.2",
"html2json": "^1.0.2"

View File

@ -42,7 +42,7 @@
"youtube-chat": "^1.1.0",
"youtube-suggest": "^1.1.0",
"yt-channel-info": "^1.1.2",
"yt-comment-scraper": "^1.2.0",
"yt-comment-scraper": "^1.3.2",
"yt-dash-manifest-generator": "^1.1.0",
"yt-trending-scraper": "^1.0.3",
"yt-xml2vtt": "^1.1.2",

View File

@ -4,7 +4,6 @@ import FtCard from '../ft-card/ft-card.vue'
import FtLoader from '../../components/ft-loader/ft-loader.vue'
import FtSelect from '../../components/ft-select/ft-select.vue'
import FtTimestampCatcher from '../../components/ft-timestamp-catcher/ft-timestamp-catcher.vue'
import CommentScraper from 'yt-comment-scraper'
export default Vue.extend({
@ -27,7 +26,8 @@ export default Vue.extend({
showComments: false,
commentScraper: null,
nextPageToken: null,
commentData: []
commentData: [],
sortNewest: false
}
},
computed: {
@ -55,6 +55,10 @@ export default Vue.extend({
'top',
'newest'
]
},
currentSortValue: function () {
return (this.sortNewest) ? 'newest' : 'top'
}
},
methods: {
@ -63,17 +67,15 @@ export default Vue.extend({
},
handleSortChange: function (sortType) {
console.log(sortType)
this.showToast({
message: 'Not currently implemented'
})
this.sortNewest = !this.sortNewest
this.getCommentData(true)
},
getCommentData: function () {
getCommentData: function (sortChanged = false) {
this.isLoading = true
switch (this.backendPreference) {
case 'local':
this.getCommentDataLocal()
this.getCommentDataLocal(sortChanged)
break
case 'invidious':
this.getCommentDataInvidious(this.nextPageToken)
@ -107,9 +109,10 @@ export default Vue.extend({
}
},
getCommentDataLocal: function () {
if (this.commentScraper === null) {
this.commentScraper = new CommentScraper(false)
getCommentDataLocal: function (sortChanged = false) {
if (this.commentScraper === null || sortChanged === true) {
this.commentScraper = new CommentScraper(false, this.sortNewest)
this.commentData = []
}
this.commentScraper.scrape_next_page_youtube_comments(this.id).then((response) => {
console.log(response)

View File

@ -21,7 +21,7 @@
v-if="commentData.length > 0 && !isLoading && showComments"
class="commentSort"
:placeholder="$t('Comments.Sort by')"
:value="sortValues[0]"
:value="currentSortValue"
:select-names="sortNames"
:select-values="sortValues"
@change="handleSortChange"