diff --git a/webapp/components/Comment.vue b/webapp/components/Comment.vue index 9b3f2861b..3d0fe21c6 100644 --- a/webapp/components/Comment.vue +++ b/webapp/components/Comment.vue @@ -141,13 +141,13 @@ export default { this.openEditCommentMenu = showMenu this.setEditPending(showMenu) }, - deleteCommentCallback() { - this.$apollo - .mutate({ + async deleteCommentCallback() { + try { + await this.$apollo.mutate({ mutation: CommentMutations(this.$i18n).DeleteComment, variables: { id: this.comment.id }, - update: store => { - const data = store.readQuery({ + update: async store => { + const data = await store.readQuery({ query: PostQuery(this.$i18n), variables: { id: this.post.id }, }) @@ -158,16 +158,14 @@ export default { if (index !== -1) { data.Post[0].comments.splice(index, 1) } - store.writeQuery({ query: PostQuery(this.$i18n), data }) + await store.writeQuery({ query: PostQuery(this.$i18n), data }) }, }) - .then(res => { - this.$toast.success(this.$t(`delete.comment.success`)) - this.$emit('deleteComment') - }) - .catch(err => { - this.$toast.error(err.message) - }) + this.$toast.success(this.$t(`delete.comment.success`)) + this.$emit('deleteComment') + } catch (err) { + this.$toast.error(err.message) + } }, }, } diff --git a/webapp/components/CommentForm/CommentForm.vue b/webapp/components/CommentForm/CommentForm.vue index 14b28b91b..8439165d4 100644 --- a/webapp/components/CommentForm/CommentForm.vue +++ b/webapp/components/CommentForm/CommentForm.vue @@ -80,13 +80,13 @@ export default { postId: this.post.id, content: this.form.content, }, - update: (store, { data: { CreateComment } }) => { - const data = store.readQuery({ + update: async (store, { data: { CreateComment } }) => { + const data = await store.readQuery({ query: PostQuery(this.$i18n), variables: { id: this.post.id }, }) data.Post[0].comments.push(CreateComment) - store.writeQuery({ query: PostQuery(this.$i18n), data }) + await store.writeQuery({ query: PostQuery(this.$i18n), data }) }, }) .then(res => {