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": { "yt-comment-scraper": {
"version": "1.2.0", "version": "1.3.2",
"resolved": "https://registry.npmjs.org/yt-comment-scraper/-/yt-comment-scraper-1.2.0.tgz", "resolved": "https://registry.npmjs.org/yt-comment-scraper/-/yt-comment-scraper-1.3.2.tgz",
"integrity": "sha512-XVQijojldm4ztqT8GnS4YJAJYxJelEE4zTdYHiup0BRYnNMbo8p4/W3lHLcbx/6FamKBdCyCSieM4RM98li4Pw==", "integrity": "sha512-i2e+7ZNm5Dvdwsk3W8UyKtxR2xjtcMfUVGUjxVAR31HlEb8wE66XslDr5eIxSCpbhCLV7ItbmvL8NGL3D1TSxw==",
"requires": { "requires": {
"axios": "^0.19.2", "axios": "^0.19.2",
"html2json": "^1.0.2" "html2json": "^1.0.2"

View File

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

View File

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