22.04 Hide Loading View when Tasks Downloaded

This commit is contained in:
Fredrick W. Warren 2021-02-15 10:35:25 -08:00
parent 0a02263d13
commit 47c282d94f
3 changed files with 17 additions and 10 deletions

View File

@ -3,7 +3,16 @@
<div class="q-pa-md absolute full-width full-height column"> <div class="q-pa-md absolute full-width full-height column">
<template v-if="tasksDownloaded"> <template v-if="!tasksDownloaded">
<div class="absolute-center">
<q-spinner
color="primary"
size="6em"
></q-spinner>
</div>
</template>
<template v-else>
<div class="row q-mb-lg"> <div class="row q-mb-lg">
<search /> <search />
<sort /> <sort />
@ -39,15 +48,6 @@
</div> </div>
</template> </template>
<template v-else>
<div class="absolute-center">
<q-spinner
color="primary"
size="6em"
></q-spinner>
</div>
</template>
</div> </div>
<q-dialog v-model="showAddTask"> <q-dialog v-model="showAddTask">

View File

@ -35,6 +35,7 @@ const actions = {
}) })
}, },
logoutUser () { logoutUser () {
console.log('xx')
firebaseAuth.signOut() firebaseAuth.signOut()
}, },
handleAuthStateChange ({ commit, dispatch }) { handleAuthStateChange ({ commit, dispatch }) {
@ -47,6 +48,7 @@ const actions = {
dispatch('tasks/fbReadData', null, { root: true }) dispatch('tasks/fbReadData', null, { root: true })
} else { } else {
commit('setLoggedIn', false) commit('setLoggedIn', false)
commit('/tasks/setTasksDownloaded', false, { root: true })
this.$router.replace('/auth').catch(err => { }) this.$router.replace('/auth').catch(err => { })
} }
}) })

View File

@ -76,6 +76,11 @@ const actions = {
const userId = firebaseAuth.currentUser.uid const userId = firebaseAuth.currentUser.uid
const userTasks = firebaseDb.ref('tasks/' + userId) const userTasks = firebaseDb.ref('tasks/' + userId)
// initial chcek for data
userTasks.once('value', snapshot => {
commit('setTasksDownloaded', true)
})
// child added // child added
userTasks.on('child_added', snapshot => { userTasks.on('child_added', snapshot => {
const task = snapshot.val() const task = snapshot.val()