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) { updateTask ({ dispatch }, payload) {
dispatch('fbUpdateTask', payload) dispatch('fbUpdateTask', payload)
}, },
deleteTask ({ commit }, id) { deleteTask ({ dispatch }, id) {
commit('deleteTask', id) dispatch('fbDeleteTask', id)
}, },
addTask ({ dispatch }, task) { addTask ({ dispatch }, task) {
const taskId = uid() const taskId = uid()
@ -107,6 +107,11 @@ const actions = {
const userId = firebaseAuth.currentUser.uid const userId = firebaseAuth.currentUser.uid
const taskRef = firebaseDb.ref('tasks/' + userId + '/' + payload.id) const taskRef = firebaseDb.ref('tasks/' + userId + '/' + payload.id)
taskRef.update(payload.updates) taskRef.update(payload.updates)
},
fbDeleteTask ({ commit }, taskId) {
const userId = firebaseAuth.currentUser.uid
const taskRef = firebaseDb.ref('tasks/' + userId + '/' + taskId)
taskRef.remove()
} }
} }