diff --git a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileEventsHandlers.kt b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileEventsHandlers.kt index 001ee7bc933..16799b9b69c 100644 --- a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileEventsHandlers.kt +++ b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileEventsHandlers.kt @@ -71,7 +71,7 @@ interface OtherUserProfileBottomSheetEventsHandler { fun onMutingConversationStatusChange(conversationId: ConversationId?, status: MutedConversationStatus) fun onAddConversationToFavourites(conversationId: ConversationId? = null) fun onMoveConversationToFolder(conversationId: ConversationId? = null) - fun onMoveConversationToArchive(conversationId: ConversationId, isArchivingConversation: Boolean) + fun onMoveConversationToArchive(dialogState: DialogState) fun onClearConversationContent(dialogState: DialogState) companion object { @@ -81,7 +81,7 @@ interface OtherUserProfileBottomSheetEventsHandler { override fun onMutingConversationStatusChange(conversationId: ConversationId?, status: MutedConversationStatus) {} override fun onAddConversationToFavourites(conversationId: ConversationId?) {} override fun onMoveConversationToFolder(conversationId: ConversationId?) {} - override fun onMoveConversationToArchive(conversationId: ConversationId, isArchivingConversation: Boolean) {} + override fun onMoveConversationToArchive(dialogState: DialogState) {} override fun onClearConversationContent(dialogState: DialogState) {} } } diff --git a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreen.kt b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreen.kt index db7eab12d80..f3b5f43b302 100644 --- a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreen.kt @@ -75,11 +75,13 @@ import com.wire.android.ui.common.bottomsheet.WireModalSheetState import com.wire.android.ui.common.bottomsheet.rememberWireModalSheetState import com.wire.android.ui.common.button.WireButtonState import com.wire.android.ui.common.calculateCurrentTab +import com.wire.android.ui.common.dialogs.ArchiveConversationDialog import com.wire.android.ui.common.dialogs.BlockUserDialogContent import com.wire.android.ui.common.dialogs.BlockUserDialogState import com.wire.android.ui.common.dialogs.UnblockUserDialogContent import com.wire.android.ui.common.dialogs.UnblockUserDialogState import com.wire.android.ui.common.dimensions +import com.wire.android.ui.common.snackbar.LocalSnackbarHostState import com.wire.android.ui.common.topBarElevation import com.wire.android.ui.common.topappbar.NavigationIconType import com.wire.android.ui.common.topappbar.WireCenterAlignedTopAppBar @@ -90,7 +92,6 @@ import com.wire.android.ui.destinations.DeviceDetailsScreenDestination import com.wire.android.ui.home.conversations.details.dialog.ClearConversationContentDialog import com.wire.android.ui.home.conversationslist.model.DialogState import com.wire.android.ui.home.conversationslist.model.Membership -import com.wire.android.ui.common.snackbar.LocalSnackbarHostState import com.wire.android.ui.theme.WireTheme import com.wire.android.ui.theme.wireColorScheme import com.wire.android.ui.theme.wireDimensions @@ -313,6 +314,10 @@ fun OtherProfileScreenContent( bottomSheetEventsHandler.onClearConversationContent(it) } ) + ArchiveConversationDialog( + dialogState = archivingConversationDialogState, + onArchiveButtonClicked = bottomSheetEventsHandler::onMoveConversationToArchive + ) } @Composable diff --git a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreenViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreenViewModel.kt index b55ce36be0c..64af56a2b3b 100644 --- a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreenViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileScreenViewModel.kt @@ -295,18 +295,23 @@ class OtherUserProfileScreenViewModel @Inject constructor( override fun onMoveConversationToFolder(conversationId: ConversationId?) { } - override fun onMoveConversationToArchive(conversationId: ConversationId, isArchivingConversation: Boolean) { + override fun onMoveConversationToArchive(dialogState: DialogState) { viewModelScope.launch { + val shouldArchive = !dialogState.isArchived requestInProgress = true - val result = withContext(dispatchers.io()) { updateConversationArchivedStatus(conversationId, isArchivingConversation) } + val result = withContext(dispatchers.io()) { updateConversationArchivedStatus(dialogState.conversationId, shouldArchive) } requestInProgress = false when (result) { ArchiveStatusUpdateResult.Failure -> { - closeBottomSheetAndShowInfoMessage(OtherUserProfileInfoMessageType.ArchiveConversationError(isArchivingConversation)) + closeBottomSheetAndShowInfoMessage(OtherUserProfileInfoMessageType.ArchiveConversationError(shouldArchive)) } ArchiveStatusUpdateResult.Success -> { - closeBottomSheetAndShowInfoMessage(OtherUserProfileInfoMessageType.ArchiveConversationSuccess(isArchivingConversation)) + closeBottomSheetAndShowInfoMessage( + OtherUserProfileInfoMessageType.ArchiveConversationSuccess( + shouldArchive + ) + ) } } } diff --git a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/bottomsheet/OtherUserProfileBottomSheet.kt b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/bottomsheet/OtherUserProfileBottomSheet.kt index 7c5725b1020..106000afe74 100644 --- a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/bottomsheet/OtherUserProfileBottomSheet.kt +++ b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/bottomsheet/OtherUserProfileBottomSheet.kt @@ -58,7 +58,7 @@ fun OtherUserProfileBottomSheetContent( if (!it.isArchived) { archivingStatusState(it) } else { - eventsHandler.onMoveConversationToArchive(it.conversationId, isArchivingConversation = false) + eventsHandler.onMoveConversationToArchive(it) } }, clearConversationContent = clearContent,