Skip to content
Snippets Groups Projects
Commit c7a83f21 authored by Sebastian's avatar Sebastian
Browse files

Don't fail on startup if no contact is added yet

parent 089fbcdb
No related branches found
No related tags found
1 merge request!13Don't fail on startup if no contact is added yet
Pipeline #7593 passed
...@@ -32,7 +32,7 @@ fun BriarUIStateManager( ...@@ -32,7 +32,7 @@ fun BriarUIStateManager(
val (uiMode, setUiMode) = remember { mutableStateOf("Contacts") } val (uiMode, setUiMode) = remember { mutableStateOf("Contacts") }
// TODO Figure out how to handle accounts with 0 contacts // TODO Figure out how to handle accounts with 0 contacts
// current selected contact // current selected contact
val (contact, setContact) = remember { mutableStateOf(contacts[0]) } val (contact, setContact) = remember { mutableStateOf(contact(contacts)) }
// current selected forum // current selected forum
val (forum, setForum) = remember { mutableStateOf(0) } val (forum, setForum) = remember { mutableStateOf(0) }
// current blog state // current blog state
...@@ -46,7 +46,7 @@ fun BriarUIStateManager( ...@@ -46,7 +46,7 @@ fun BriarUIStateManager(
BriarSidebar(uiMode, setUiMode) BriarSidebar(uiMode, setUiMode)
Divider(color = divider, modifier = Modifier.fillMaxHeight().width(1.dp)) Divider(color = divider, modifier = Modifier.fillMaxHeight().width(1.dp))
when (uiMode) { when (uiMode) {
"Contacts" -> PrivateMessageView( "Contacts" -> if (contact != null) PrivateMessageView(
contact, contact,
contacts, contacts,
setContact setContact
...@@ -57,3 +57,7 @@ fun BriarUIStateManager( ...@@ -57,3 +57,7 @@ fun BriarUIStateManager(
} }
} }
} }
fun contact(contacts: List<Contact>): Contact? {
return if (contacts.isEmpty()) null else contacts[0]
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment