mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Revert to using async/await, follow @appinteractive PR suggestions
This commit is contained in:
parent
ed76482daa
commit
470da18381
@ -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)
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
|
||||
@ -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 => {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user