Skip to content

Commit

Permalink
[comments] fix the comment data being loaded twice
Browse files Browse the repository at this point in the history
Data fetch runs twice due to nested task-info components
  • Loading branch information
NicoPennec committed Sep 22, 2023
1 parent 8dea79a commit 50d78bf
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 3 deletions.
1 change: 0 additions & 1 deletion src/components/mixins/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -1268,7 +1268,6 @@ export const playerMixin = {

watch: {
isCommentsHidden() {
if (!this.isCommentsHidden) this.$refs['task-info'].loadTaskData()
if (this.isCurrentPreviewSound) {
this.soundPlayer.redraw()
}
Expand Down
2 changes: 1 addition & 1 deletion src/components/pages/playlists/PlaylistPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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']) {
Expand Down
1 change: 1 addition & 0 deletions src/components/previews/PreviewPlayer.vue
Original file line number Diff line number Diff line change
Expand Up @@ -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')"
Expand Down
9 changes: 8 additions & 1 deletion src/components/sides/TaskInfo.vue
Original file line number Diff line number Diff line change
Expand Up @@ -404,7 +404,6 @@ export default {
},
mounted() {
this.loadTaskData()
if (this.$refs['add-comment']) {
const draft = drafts.getTaskDraft(this.task.id)
if (draft) {
Expand Down Expand Up @@ -1274,6 +1273,14 @@ export default {
if (!this.silent) {
this.loadTaskData()
}
},
silent: {
immediate: true,
handler() {
if (!this.silent) {
this.loadTaskData()
}
}
}
},
Expand Down

0 comments on commit 50d78bf

Please sign in to comment.