From 50d78bfedecc4f484a17e665df26c7215f4417e1 Mon Sep 17 00:00:00 2001 From: Nicolas Pennec Date: Fri, 22 Sep 2023 20:11:22 +0200 Subject: [PATCH] [comments] fix the comment data being loaded twice Data fetch runs twice due to nested task-info components --- src/components/mixins/player.js | 1 - src/components/pages/playlists/PlaylistPlayer.vue | 2 +- src/components/previews/PreviewPlayer.vue | 1 + src/components/sides/TaskInfo.vue | 9 ++++++++- 4 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/components/mixins/player.js b/src/components/mixins/player.js index 74f3958455..6c103d783f 100644 --- a/src/components/mixins/player.js +++ b/src/components/mixins/player.js @@ -1268,7 +1268,6 @@ export const playerMixin = { watch: { isCommentsHidden() { - if (!this.isCommentsHidden) this.$refs['task-info'].loadTaskData() if (this.isCurrentPreviewSound) { this.soundPlayer.redraw() } diff --git a/src/components/pages/playlists/PlaylistPlayer.vue b/src/components/pages/playlists/PlaylistPlayer.vue index 6ef38e2048..259e045088 100644 --- a/src/components/pages/playlists/PlaylistPlayer.vue +++ b/src/components/pages/playlists/PlaylistPlayer.vue @@ -1423,7 +1423,7 @@ export default { if (this.$refs['video-container']) { this.$refs['video-container'].style.height = `${height}px` } - if (!this.isCommentsHidden) { + if (this.$refs['task-info'] && !this.isCommentsHidden) { this.$refs['task-info'].$el.style.height = `${height}px` } if (this.$refs['picture-preview-wrapper']) { diff --git a/src/components/previews/PreviewPlayer.vue b/src/components/previews/PreviewPlayer.vue index a7c0fcdd8f..c555105cc4 100644 --- a/src/components/previews/PreviewPlayer.vue +++ b/src/components/previews/PreviewPlayer.vue @@ -93,6 +93,7 @@ class="flexrow-item task-info-column" :task="task" :is-preview="false" + :silent="isCommentsHidden" :current-time-raw="currentTimeRaw" :current-parent-preview="currentPreview" @comment-added="$emit('comment-added')" diff --git a/src/components/sides/TaskInfo.vue b/src/components/sides/TaskInfo.vue index 159c772764..ebd2deb47d 100644 --- a/src/components/sides/TaskInfo.vue +++ b/src/components/sides/TaskInfo.vue @@ -404,7 +404,6 @@ export default { }, mounted() { - this.loadTaskData() if (this.$refs['add-comment']) { const draft = drafts.getTaskDraft(this.task.id) if (draft) { @@ -1274,6 +1273,14 @@ export default { if (!this.silent) { this.loadTaskData() } + }, + silent: { + immediate: true, + handler() { + if (!this.silent) { + this.loadTaskData() + } + } } },