allowing the messages view to fail with nothing to see here

- means the user can go into the settings and enable logging to find out what's going wrong
This commit is contained in:
Adam Brown 2022-11-10 22:40:42 +00:00
parent b8f60d804a
commit d66f0c0ab9
1 changed files with 3 additions and 5 deletions

View File

@ -15,7 +15,6 @@ import app.dapk.st.profile.state.ProfileState
import app.dapk.st.viewmodel.DapkViewModel import app.dapk.st.viewmodel.DapkViewModel
import kotlinx.coroutines.CoroutineScope import kotlinx.coroutines.CoroutineScope
import kotlinx.coroutines.Job import kotlinx.coroutines.Job
import kotlinx.coroutines.flow.first
import kotlinx.coroutines.flow.launchIn import kotlinx.coroutines.flow.launchIn
import kotlinx.coroutines.flow.onEach import kotlinx.coroutines.flow.onEach
import kotlinx.coroutines.launch import kotlinx.coroutines.launch
@ -58,11 +57,10 @@ internal class HomeViewModel(
private suspend fun initialHomeContent(): SignedIn { private suspend fun initialHomeContent(): SignedIn {
val me = chatEngine.me(forceRefresh = false) val me = chatEngine.me(forceRefresh = false)
val initialInvites = chatEngine.invites().first().size
return when (val current = state) { return when (val current = state) {
Loading -> SignedIn(Page.Directory, me, invites = initialInvites) Loading -> SignedIn(Page.Directory, me, invites = 0)
is SignedIn -> current.copy(me = me, invites = initialInvites) is SignedIn -> current.copy(me = me, invites = current.invites)
SignedOut -> SignedIn(Page.Directory, me, invites = initialInvites) SignedOut -> SignedIn(Page.Directory, me, invites = 0)
} }
} }