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) {
|
deleteTask ({ commit }, id) {
|
||||||
commit('deleteTask', id)
|
commit('deleteTask', id)
|
||||||
},
|
},
|
||||||
addTask ({ commit }, task) {
|
addTask ({ dispatch }, task) {
|
||||||
const taskId = uid()
|
const taskId = uid()
|
||||||
const payload = {
|
const payload = {
|
||||||
id: taskId,
|
id: taskId,
|
||||||
task: task
|
task: task
|
||||||
}
|
}
|
||||||
commit('addTask', payload)
|
dispatch('fbAddTask', payload)
|
||||||
},
|
},
|
||||||
setSearch ({ commit }, value) {
|
setSearch ({ commit }, value) {
|
||||||
commit('setSearch', value)
|
commit('setSearch', value)
|
||||||
@ -97,6 +97,11 @@ const actions = {
|
|||||||
const taskId = snapshot.key
|
const taskId = snapshot.key
|
||||||
commit('deleteTask', taskId)
|
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