Show snackbar on archive/unarchive from bottomDialog

Signed-off-by: Marcel Hibbe <dev@mhibbe.de>
This commit is contained in:
Marcel Hibbe 2025-01-23 12:03:16 +01:00
parent 3427f4ce50
commit 7ac8c2483e
No known key found for this signature in database
GPG Key ID: C793F8B59F43CE7B
2 changed files with 30 additions and 11 deletions

View File

@ -200,17 +200,7 @@ class ConversationsListBottomDialog(
}
binding.conversationArchive.setOnClickListener {
val currentUser = userManager.currentUser.blockingGet()
val token = conversation.token
lifecycleScope.launch {
if (conversation.hasArchived) {
conversationInfoViewModel.unarchiveConversation(currentUser, token)
} else {
conversationInfoViewModel.archiveConversation(currentUser, token)
}
}
activity.fetchRooms()
dismiss()
handleArchiving()
}
binding.conversationOperationRename.setOnClickListener {
@ -226,6 +216,33 @@ class ConversationsListBottomDialog(
}
}
private fun handleArchiving() {
val currentUser = userManager.currentUser.blockingGet()
val token = conversation.token
lifecycleScope.launch {
if (conversation.hasArchived) {
conversationInfoViewModel.unarchiveConversation(currentUser, token)
activity.showSnackbar(
String.format(
context.resources.getString(R.string.unarchived_conversation),
conversation.displayName
)
)
dismiss()
} else {
conversationInfoViewModel.archiveConversation(currentUser, token)
activity.showSnackbar(
String.format(
context.resources.getString(R.string.archived_conversation),
conversation.displayName
)
)
dismiss()
}
}
activity.fetchRooms()
}
@Suppress("Detekt.TooGenericExceptionCaught")
@SuppressLint("StringFormatInvalid", "TooGenericExceptionCaught")
private fun addConversationToFavorites() {

View File

@ -848,4 +848,6 @@ How to translate with transifex:
<string name="user_absence_replacement">Replacement: </string>
<string name="resend_message">Resend</string>
<string name="no_conversations_archived">No conversations archived</string>
<string name="archived_conversation">Archived %1$s</string>
<string name="unarchived_conversation">Unarchived %1$s</string>
</resources>