mirror of
https://github.com/IT4Change/Ocelot-Social.git
synced 2025-12-13 07:45:56 +00:00
Refactor ReportModal
@Tirokk and I had a hard time to reason about the then/catch block if $toast is undefined.
This commit is contained in:
parent
193cff45e2
commit
c0d545bae0
@ -94,11 +94,11 @@ export default {
|
||||
close() {
|
||||
this.$store.commit('modal/SET_OPEN', {})
|
||||
},
|
||||
report() {
|
||||
async report() {
|
||||
this.loading = true
|
||||
this.disabled = true
|
||||
this.$apollo
|
||||
.mutate({
|
||||
try {
|
||||
await this.$apollo.mutate({
|
||||
mutation: gql`
|
||||
mutation($id: ID!, $description: String) {
|
||||
report(id: $id, description: $description) {
|
||||
@ -111,18 +111,15 @@ export default {
|
||||
description: '-'
|
||||
}
|
||||
})
|
||||
.then(() => {
|
||||
this.success = true
|
||||
this.$toast.success('Thanks for reporting!')
|
||||
setTimeout(this.close, 1500)
|
||||
})
|
||||
.catch(err => {
|
||||
this.$toast.error(err.message)
|
||||
this.disabled = false
|
||||
})
|
||||
.finally(() => {
|
||||
this.loading = false
|
||||
})
|
||||
this.success = true
|
||||
this.$toast.success('Thanks for reporting!')
|
||||
setTimeout(this.close, 1500)
|
||||
} catch (err) {
|
||||
this.$toast.error(err.message)
|
||||
this.disabled = false
|
||||
} finally {
|
||||
this.loading = false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user