21.02 Write Data - When Task Added
This commit is contained in:
parent
8a28fd068a
commit
d09fc4e6ba
@ -54,13 +54,13 @@ const actions = {
|
||||
deleteTask ({ commit }, id) {
|
||||
commit('deleteTask', id)
|
||||
},
|
||||
addTask ({ commit }, task) {
|
||||
addTask ({ dispatch }, task) {
|
||||
const taskId = uid()
|
||||
const payload = {
|
||||
id: taskId,
|
||||
task: task
|
||||
}
|
||||
commit('addTask', payload)
|
||||
dispatch('fbAddTask', payload)
|
||||
},
|
||||
setSearch ({ commit }, value) {
|
||||
commit('setSearch', value)
|
||||
@ -97,6 +97,11 @@ const actions = {
|
||||
const taskId = snapshot.key
|
||||
commit('deleteTask', taskId)
|
||||
})
|
||||
},
|
||||
fbAddTask ({ commit }, payload) {
|
||||
const userId = firebaseAuth.currentUser.uid
|
||||
const taskRef = firebaseDb.ref('tasks/' + userId + '/' + payload.id)
|
||||
taskRef.set(payload.task)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user