Skip to content
Snippets Groups Projects
Commit b6bc739b authored by Mikolai Gütschow's avatar Mikolai Gütschow Committed by Sebastian
Browse files

show spinner while loading messages

parent 6668be23
Branches
Tags
1 merge request!70Let user delete all messages with a contact
Pipeline #8983 passed
...@@ -75,6 +75,11 @@ fun ConversationScreen( ...@@ -75,6 +75,11 @@ fun ConversationScreen(
) )
}, },
content = { padding -> content = { padding ->
if (viewModel.loadingMessages.value) {
Loader()
return@Scaffold
}
LazyColumn( LazyColumn(
state = scrollState, state = scrollState,
// reverseLayout to display most recent message (index 0) at the bottom // reverseLayout to display most recent message (index 0) at the bottom
... ...
......
...@@ -73,6 +73,7 @@ constructor( ...@@ -73,6 +73,7 @@ constructor(
private val _contactId = mutableStateOf<ContactId?>(null) private val _contactId = mutableStateOf<ContactId?>(null)
private val _contactItem = mutableStateOf<ContactItem?>(null) private val _contactItem = mutableStateOf<ContactItem?>(null)
private val _messages = mutableStateListOf<ConversationItem>() private val _messages = mutableStateListOf<ConversationItem>()
private val _loadingMessages = mutableStateOf(false)
private val _newMessage = mutableStateOf("") private val _newMessage = mutableStateOf("")
...@@ -80,6 +81,7 @@ constructor( ...@@ -80,6 +81,7 @@ constructor(
val contactItem = _contactItem.asState() val contactItem = _contactItem.asState()
val messages = _messages.asList() val messages = _messages.asList()
val loadingMessages = _loadingMessages.asState()
val newMessage = _newMessage.asState() val newMessage = _newMessage.asState()
...@@ -201,6 +203,7 @@ constructor( ...@@ -201,6 +203,7 @@ constructor(
} }
private fun loadMessages(txn: Transaction, contact: ContactItem) { private fun loadMessages(txn: Transaction, contact: ContactItem) {
_loadingMessages.value = true
try { try {
var start = LogUtils.now() var start = LogUtils.now()
val headers = conversationManager.getMessageHeaders(txn, contact.idWrapper.contactId) val headers = conversationManager.getMessageHeaders(txn, contact.idWrapper.contactId)
...@@ -215,6 +218,8 @@ constructor( ...@@ -215,6 +218,8 @@ constructor(
} catch (e: NoSuchContactException) { } catch (e: NoSuchContactException) {
// todo: handle this properly // todo: handle this properly
LOG.warn(e) {} LOG.warn(e) {}
} finally {
_loadingMessages.value = false
} }
} }
...@@ -306,11 +311,12 @@ constructor( ...@@ -306,11 +311,12 @@ constructor(
} }
fun deleteAllMessages() = runOnDbThread { fun deleteAllMessages() = runOnDbThread {
_loadingMessages.value = true
try { try {
val result = conversationManager.deleteAllMessages(_contactId.value!!) val result = conversationManager.deleteAllMessages(_contactId.value!!)
reloadConversationAfterDeletingMessages(result) reloadConversationAfterDeletingMessages(result)
} finally { } finally {
// todo: _loadingMessages.value = false
} }
} }
... ...
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment