forked from AkkomaGang/admin-fe
Move try/catch error handling from view file to relays module
This commit is contained in:
parent
b2c9308b80
commit
c4b13ebb9f
2 changed files with 18 additions and 18 deletions
|
@ -28,15 +28,27 @@ const relays = {
|
||||||
commit('SET_RELAYS', response.data.relays)
|
commit('SET_RELAYS', response.data.relays)
|
||||||
commit('SET_LOADING', false)
|
commit('SET_LOADING', false)
|
||||||
},
|
},
|
||||||
async AddRelay({ commit, getters }, relay) {
|
async AddRelay({ commit, dispatch, getters }, relay) {
|
||||||
commit('ADD_RELAY', relay)
|
commit('ADD_RELAY', relay)
|
||||||
|
|
||||||
await addRelay(relay, getters.authHost, getters.token)
|
try {
|
||||||
|
await addRelay(relay, getters.authHost, getters.token)
|
||||||
|
} catch (_e) {
|
||||||
|
return
|
||||||
|
} finally {
|
||||||
|
dispatch('FetchRelays')
|
||||||
|
}
|
||||||
},
|
},
|
||||||
async DeleteRelay({ commit, getters }, relay) {
|
async DeleteRelay({ commit, dispatch, getters }, relay) {
|
||||||
commit('DELETE_RELAY', relay)
|
commit('DELETE_RELAY', relay)
|
||||||
|
|
||||||
await deleteRelay(relay, getters.authHost, getters.token)
|
try {
|
||||||
|
await deleteRelay(relay, getters.authHost, getters.token)
|
||||||
|
} catch (_e) {
|
||||||
|
return
|
||||||
|
} finally {
|
||||||
|
dispatch('FetchRelays')
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -52,22 +52,10 @@ export default {
|
||||||
},
|
},
|
||||||
methods: {
|
methods: {
|
||||||
followRelay() {
|
followRelay() {
|
||||||
try {
|
this.$store.dispatch('AddRelay', this.newRelay)
|
||||||
this.$store.dispatch('AddRelay', this.newRelay)
|
|
||||||
} catch (_e) {
|
|
||||||
return
|
|
||||||
} finally {
|
|
||||||
this.$store.dispatch('FetchRelays')
|
|
||||||
}
|
|
||||||
},
|
},
|
||||||
deleteRelay(relay) {
|
deleteRelay(relay) {
|
||||||
try {
|
this.$store.dispatch('DeleteRelay', relay)
|
||||||
this.$store.dispatch('DeleteRelay', relay)
|
|
||||||
} catch (_e) {
|
|
||||||
return
|
|
||||||
} finally {
|
|
||||||
this.$store.dispatch('FetchRelays')
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue