24.02 Handle Write Errors

This commit is contained in:
Fredrick W. Warren 2021-02-15 12:12:16 -08:00
parent 45ac159e30
commit 8037495aea

View File

@ -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)
}
})
}
}