Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix comment section style inconsistency and more... #3231

Merged
merged 3 commits into from
May 22, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,18 @@
color: var(--title-color);
}

.commentsTitle,
.getMoreComments {
padding-bottom: 1em;
.noCommentMsg {
padding-top: 1em;
}
padding-bottom: 1em;

.center {
text-align: center;
}

.commentsTitle {
padding-bottom: 1em;
padding-top: 1em;
}

.commentSort {
float: right;
}
Expand All @@ -36,10 +38,6 @@
position: relative;
}

.comment:last-child {
padding-bottom: 0;
}

.hideComments {
font-size: 13px;
text-decoration: underline;
Expand Down Expand Up @@ -166,6 +164,8 @@
}

.getMoreComments {
padding-bottom: 1em;

text-align: center;
text-decoration: underline;
cursor: pointer;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,10 @@ export default defineComponent({
type: Boolean,
required: true
},
forceState: {
type: String,
default: null,
},
},
data: function () {
return {
Expand Down Expand Up @@ -110,7 +114,20 @@ export default defineComponent({
return this.commentData.length > 0 && !this.isLoading && this.showComments && this.nextPageToken
},
},

mounted: function () {
// region No comment detection
// For videos without any comment (comment disabled?)
// e.g. https://youtu.be/8NBSwDEf8a8
//
// `comments_entry_point_header` is null probably when comment disabled
if (this.forceState === 'noComment') {
this.commentData = []
this.nextPageToken = null
this.isLoading = false
this.showComments = true
}
// endregion No comment detection
},
methods: {
onTimestamp: function (timestamp) {
this.$emit('timestamp-event', timestamp)
Expand Down Expand Up @@ -248,11 +265,24 @@ export default defineComponent({
this.nextPageToken = response.continuation
this.isLoading = false
this.showComments = true
}).catch((xhr) => {
console.error(xhr)
}).catch((err) => {
// region No comment detection
// No comment related info when video info requested earlier in parent component
if (err.message.includes('Comments not found')) {
// For videos without any comment (comment disabled?)
// e.g. https://youtu.be/8NBSwDEf8a8
this.commentData = []
this.nextPageToken = null
this.isLoading = false
this.showComments = true
return
}
// endregion No comment detection

console.error(err)
const errorMessage = this.$t('Invidious API Error (Click to copy)')
showToast(`${errorMessage}: ${xhr.responseText}`, 10000, () => {
copyToClipboard(xhr.responseText)
showToast(`${errorMessage}: ${err}`, 10000, () => {
copyToClipboard(err)
})
if (process.env.IS_ELECTRON && this.backendFallback && this.backendPreference === 'invidious') {
showToast(this.$t('Falling back to local API'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -233,7 +233,7 @@
<div
v-else-if="showComments && !isLoading"
>
<h3 class="center">
<h3 class="noCommentMsg">
{{ $t("There are no comments available for this video") }}
</h3>
</div>
Expand Down
12 changes: 12 additions & 0 deletions src/renderer/views/Watch/Watch.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ export default defineComponent({
playNextTimeout: null,
playNextCountDownIntervalId: null,
infoAreaSticky: true,
commentsEnabled: true,
}
},
computed: {
Expand Down Expand Up @@ -617,6 +618,17 @@ export default defineComponent({
}
}

// region No comment detection
// For videos without any comment (comment disabled?)
// e.g. https://youtu.be/8NBSwDEf8a8
//
// `comments_entry_point_header` is null probably when comment disabled
// e.g. https://youtu.be/8NBSwDEf8a8
// However videos with comments enabled but have no comment
// are different (which is not detected here)
this.commentsEnabled = result.comments_entry_point_header != null
// endregion No comment detection

this.isLoading = false
this.updateTitle()
} catch (err) {
Expand Down
1 change: 1 addition & 0 deletions src/renderer/views/Watch/Watch.vue
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,7 @@
:channel-thumbnail="channelThumbnail"
:channel-name="channelName"
:video-player-ready="videoPlayerReady"
:force-state="commentsEnabled ? null : 'noComment'"
@timestamp-event="changeTimestamp"
/>
</div>
Expand Down