21.04 Write Data - When Task Deleted

This commit is contained in:
Fredrick W. Warren 2021-02-15 08:52:17 -08:00
parent 65b76d2255
commit f6de60571b

View File

@ -51,8 +51,8 @@ const actions = {
updateTask ({ dispatch }, payload) {
dispatch('fbUpdateTask', payload)
},
deleteTask ({ commit }, id) {
commit('deleteTask', id)
deleteTask ({ dispatch }, id) {
dispatch('fbDeleteTask', id)
},
addTask ({ dispatch }, task) {
const taskId = uid()
@ -107,7 +107,12 @@ const actions = {
const userId = firebaseAuth.currentUser.uid
const taskRef = firebaseDb.ref('tasks/' + userId + '/' + payload.id)
taskRef.update(payload.updates)
}
},
fbDeleteTask ({ commit }, taskId) {
const userId = firebaseAuth.currentUser.uid
const taskRef = firebaseDb.ref('tasks/' + userId + '/' + taskId)
taskRef.remove()
}
}
const getters = {