Implement minimize comments in WatchVideo

This commit is contained in:
Alexandre Moreau 2022-10-24 01:21:47 +02:00
parent ffc091131f
commit 8d711f3aa9

View file

@ -162,9 +162,14 @@
<hr /> <hr />
<div class="grid xl:grid-cols-5 sm:grid-cols-4 grid-cols-1"> <div class="grid xl:grid-cols-5 sm:grid-cols-4 grid-cols-1">
<div v-if="!commentsEnabled" class="xl:col-span-4 sm:col-span-3"> <div class="xl:col-span-4 sm:col-span-3">
<p class="text-center mt-8" v-t="'comment.user_disabled'"></p> <button
class="btn mb-2"
@click="toggleComments"
v-t="`actions.${showComments ? 'minimize_comments' : 'show_comments'}`"
/>
</div> </div>
<div v-if="!showComments" class="xl:col-span-4 sm:col-span-3"></div>
<div v-else-if="!comments" class="xl:col-span-4 sm:col-span-3"> <div v-else-if="!comments" class="xl:col-span-4 sm:col-span-3">
<p class="text-center mt-8" v-t="'comment.loading'"></p> <p class="text-center mt-8" v-t="'comment.loading'"></p>
</div> </div>
@ -243,6 +248,7 @@ export default {
sponsors: null, sponsors: null,
selectedAutoLoop: false, selectedAutoLoop: false,
selectedAutoPlay: null, selectedAutoPlay: null,
showComments: true,
showDesc: true, showDesc: true,
showRecs: true, showRecs: true,
showChapters: true, showChapters: true,
@ -363,6 +369,12 @@ export default {
'"]', '"]',
}); });
}, },
toggleComments() {
this.showComments = !this.showComments;
if (this.showComments && this.comments === null) {
this.fetchComments();
}
},
fetchComments() { fetchComments() {
return this.fetchJson(this.apiUrl() + "/comments/" + this.getVideoId()); return this.fetchJson(this.apiUrl() + "/comments/" + this.getVideoId());
}, },