24.02 Handle Write Errors
This commit is contained in:
parent
45ac159e30
commit
8037495aea
@ -1,6 +1,7 @@
|
||||
import Vue from 'vue'
|
||||
import { uid } from 'quasar'
|
||||
import { firebaseDb, firebaseAuth } from 'boot/firebase'
|
||||
import { showErrorMessage } from 'src/functions/function-show-error-message'
|
||||
|
||||
const state = {
|
||||
tasks: {
|
||||
@ -113,17 +114,29 @@ const actions = {
|
||||
fbAddTask ({ commit }, payload) {
|
||||
const userId = firebaseAuth.currentUser.uid
|
||||
const taskRef = firebaseDb.ref('tasks/' + userId + '/' + payload.id)
|
||||
taskRef.set(payload.task)
|
||||
taskRef.set(payload.task, error => {
|
||||
if (error) {
|
||||
showErrorMessage(error.message)
|
||||
}
|
||||
})
|
||||
},
|
||||
fbUpdateTask ({ commit }, payload) {
|
||||
const userId = firebaseAuth.currentUser.uid
|
||||
const taskRef = firebaseDb.ref('tasks/' + userId + '/' + payload.id)
|
||||
taskRef.update(payload.updates)
|
||||
taskRef.update(payload.updates, error => {
|
||||
if (error) {
|
||||
showErrorMessage(error.message)
|
||||
}
|
||||
})
|
||||
},
|
||||
fbDeleteTask ({ commit }, taskId) {
|
||||
const userId = firebaseAuth.currentUser.uid
|
||||
const taskRef = firebaseDb.ref('tasks/' + userId + '/' + taskId)
|
||||
taskRef.remove()
|
||||
taskRef.remove(error => {
|
||||
if (error) {
|
||||
showErrorMessage(error.message)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user