From 8182ba1273dd373e079f27f685f60c654293856b Mon Sep 17 00:00:00 2001 From: root Date: Tue, 9 Aug 2022 11:52:35 +0530 Subject: [PATCH] Move from disabling comments to optionally fetching comments while disabled by default --- src/routes/Preferences.vue | 4 ++-- src/routes/WatchVideo.vue | 20 ++++++++++++-------- src/store/prefs-store.js | 2 +- src/translations/en.json | 3 +-- 4 files changed, 16 insertions(+), 13 deletions(-) diff --git a/src/routes/Preferences.vue b/src/routes/Preferences.vue index 478b2a2..7b74152 100644 --- a/src/routes/Preferences.vue +++ b/src/routes/Preferences.vue @@ -129,9 +129,9 @@ export default { default: true }, { - id: 'showComments', + id: 'disableCommentsByDefault', type: 'bool', - default: true + default: false }, { id: 'showRelatedVideos', diff --git a/src/routes/WatchVideo.vue b/src/routes/WatchVideo.vue index 586137f..c53b105 100644 --- a/src/routes/WatchVideo.vue +++ b/src/routes/WatchVideo.vue @@ -124,13 +124,16 @@ - +
Comments
+ + Load Comments +
Related Videos
@@ -242,8 +245,8 @@ export default { initialize () { this.getVideoData() this.getSponsors() - if (this.areCommentsEnabled) { - this.fetchComments().then(data => (this.comments = data)) + if (!this.$store.getters['prefs/getPreferenceBoolean']('disableCommentsByDefault')) { + this.fetchComments() } }, @@ -294,8 +297,8 @@ export default { } }) }, - fetchComments () { - return this.$store.dispatch('auth/makeRequest', { + async fetchComments () { + this.comments = await this.$store.dispatch('auth/makeRequest', { path: '/comments/' + this.videoId }) }, @@ -392,12 +395,13 @@ export default { isAutoplayEnabled () { return this.$store.getters['prefs/getPreferenceBoolean']('autoplay', false) }, - areCommentsEnabled () { - return this.$store.getters['prefs/getPreferenceBoolean']('showComments') - }, videoId () { return this.$route.query.v || this.$route.params.v }, + availableComments () { + const l = this.comments?.comments?.length + return Number.isFinite(l) ? l : 0 + }, initialSkip () { // 't' in $route.query ? Number($route.query.t) : (lastWatch.progress ? lastWatch.progress : undefined) // 1st Priority - t in query diff --git a/src/store/prefs-store.js b/src/store/prefs-store.js index c9b4f1c..a2bc541 100644 --- a/src/store/prefs-store.js +++ b/src/store/prefs-store.js @@ -13,7 +13,7 @@ const PrefsStore = { skipToLastPoint: true, clickbaitThumbnailAvoidance: false, - showComments: true, + disableCommentsByDefault: false, showRelatedVideos: true, showMarkers: true, disableLBRY: true, diff --git a/src/translations/en.json b/src/translations/en.json index 65394f3..4d25f26 100644 --- a/src/translations/en.json +++ b/src/translations/en.json @@ -80,7 +80,6 @@ "dark": "Dark", "light": "Light", "buffering_goal": "Buffering Goal (in seconds)", - "show_comments": "Show Comments", "minimize_description": "Minimize Description by default", "store_watch_history": "Store Watch History", "language_selection": "Language Selection", @@ -102,7 +101,7 @@ "clickbaitThumbnailAvoidance": "Replace default thumbnails with auto-generated ones", "disableLBRY": "Disable LBRY", "proxyLBRY": "Proxy LBRY videos", - "showComments": "Show Comments", + "disableCommentsByDefault": "Don't show comments by default", "showRelatedVideos": "Show Related Videos", "showMarkers": "Show SponsorBlock Markers" }