diff --git a/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/ConversationSheetContent.kt b/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/ConversationSheetContent.kt index f268710d81..306a0e7508 100644 --- a/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/ConversationSheetContent.kt +++ b/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/ConversationSheetContent.kt @@ -41,7 +41,7 @@ fun ConversationSheetContent( onMutingConversationStatusChange: () -> Unit, addConversationToFavourites: () -> Unit, moveConversationToFolder: () -> Unit, - moveConversationToArchive: (DialogState) -> Unit, + updateConversationArchiveStatus: (DialogState) -> Unit, clearConversationContent: (DialogState) -> Unit, blockUser: (BlockUserDialogState) -> Unit, unblockUser: (UnblockUserDialogState) -> Unit, @@ -61,7 +61,7 @@ fun ConversationSheetContent( // // addConversationToFavourites = addConversationToFavourites, // moveConversationToFolder = moveConversationToFolder, - moveConversationToArchive = moveConversationToArchive, + updateConversationArchiveStatus = updateConversationArchiveStatus, clearConversationContent = clearConversationContent, blockUserClick = blockUser, unblockUserClick = unblockUser, @@ -124,7 +124,8 @@ data class ConversationSheetContent( val mutingConversationState: MutedConversationStatus, val conversationTypeDetail: ConversationTypeDetail, val selfRole: Conversation.Member.Role?, - val isTeamConversation: Boolean + val isTeamConversation: Boolean, + val isArchived: Boolean ) { private val isSelfUserMember: Boolean get() = selfRole != null diff --git a/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/ConversationSheetState.kt b/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/ConversationSheetState.kt index 3b8535d1b1..648c1f4c62 100644 --- a/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/ConversationSheetState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/ConversationSheetState.kt @@ -75,7 +75,8 @@ fun rememberConversationSheetState( isCreator = isSelfUserCreator ), isTeamConversation = teamId != null, - selfRole = selfMemberRole + selfRole = selfMemberRole, + isArchived = conversationItem.isArchived ) } } @@ -93,7 +94,8 @@ fun rememberConversationSheetState( blockingState ), isTeamConversation = isTeamConversation, - selfRole = Conversation.Member.Role.Member + selfRole = Conversation.Member.Role.Member, + isArchived = conversationItem.isArchived ) } } @@ -107,7 +109,8 @@ fun rememberConversationSheetState( userAvatarData.asset ), isTeamConversation = isTeamConversation, - selfRole = Conversation.Member.Role.Member + selfRole = Conversation.Member.Role.Member, + isArchived = conversationItem.isArchived ) } } diff --git a/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/HomeSheetContent.kt b/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/HomeSheetContent.kt index b2f5e9562c..e2d3fdff93 100644 --- a/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/HomeSheetContent.kt +++ b/app/src/main/kotlin/com/wire/android/ui/common/bottomsheet/conversation/HomeSheetContent.kt @@ -23,8 +23,8 @@ package com.wire.android.ui.common.bottomsheet.conversation import androidx.compose.foundation.layout.Row import androidx.compose.foundation.layout.Spacer import androidx.compose.foundation.layout.size -import androidx.compose.material3.Text import androidx.compose.material3.MaterialTheme +import androidx.compose.material3.Text import androidx.compose.runtime.Composable import androidx.compose.ui.Alignment import androidx.compose.ui.Modifier @@ -60,7 +60,7 @@ internal fun ConversationMainSheetContent( // TODO(profile): enable when implemented // addConversationToFavourites: () -> Unit, // moveConversationToFolder: () -> Unit, - moveConversationToArchive: (DialogState) -> Unit, + updateConversationArchiveStatus: (DialogState) -> Unit, clearConversationContent: (DialogState) -> Unit, blockUserClick: (BlockUserDialogState) -> Unit, unblockUserClick: (UnblockUserDialogState) -> Unit, @@ -139,17 +139,24 @@ internal fun ConversationMainSheetContent( icon = { MenuItemIcon( id = R.drawable.ic_archive, - contentDescription = stringResource(R.string.content_description_move_to_archive), + contentDescription = stringResource( + if (conversationSheetContent.isArchived) R.string.content_description_unarchive + else R.string.content_description_move_to_archive + ), ) }, - title = stringResource(R.string.label_move_to_archive), + title = stringResource( + if (!conversationSheetContent.isArchived) R.string.label_move_to_archive + else R.string.label_unarchive + ), onItemClick = { with(conversationSheetContent) { - moveConversationToArchive( + updateConversationArchiveStatus( DialogState( conversationId, title, - conversationTypeDetail + conversationTypeDetail, + isArchived ) ) } @@ -169,7 +176,8 @@ internal fun ConversationMainSheetContent( DialogState( conversationSheetContent.conversationId, conversationSheetContent.title, - conversationSheetContent.conversationTypeDetail + conversationSheetContent.conversationTypeDetail, + conversationSheetContent.isArchived ) ) } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/HomeScreen.kt b/app/src/main/kotlin/com/wire/android/ui/home/HomeScreen.kt index fa2c4ce80d..eafefc761b 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/HomeScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/HomeScreen.kt @@ -363,8 +363,19 @@ private fun handleSnackBarMessage( if (messageType.isGroup) R.string.group_content_deleted else R.string.conversation_content_deleted ) - HomeSnackbarState.ArchivingConversationError -> stringResource(id = R.string.error_archiving_conversation) - HomeSnackbarState.ArchivingConversationSuccess -> stringResource(id = R.string.success_archiving_conversation) + is HomeSnackbarState.UpdateArchivingStatusSuccess -> { + stringResource( + id = if (messageType.isArchiving) R.string.success_archiving_conversation + else R.string.success_unarchiving_conversation + ) + } + + is HomeSnackbarState.UpdateArchivingStatusError -> { + stringResource( + id = if (messageType.isArchiving) R.string.error_archiving_conversation + else R.string.error_archiving_conversation + ) + } } LaunchedEffect(messageType) { diff --git a/app/src/main/kotlin/com/wire/android/ui/home/HomeSnackbarState.kt b/app/src/main/kotlin/com/wire/android/ui/home/HomeSnackbarState.kt index 15ccf7e134..a4ca2b708c 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/HomeSnackbarState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/HomeSnackbarState.kt @@ -35,6 +35,6 @@ sealed class HomeSnackbarState { object DeleteConversationGroupError : HomeSnackbarState() object LeftConversationSuccess : HomeSnackbarState() object LeaveConversationError : HomeSnackbarState() - object ArchivingConversationSuccess : HomeSnackbarState() - object ArchivingConversationError : HomeSnackbarState() + data class UpdateArchivingStatusSuccess(val isArchiving: Boolean) : HomeSnackbarState() + data class UpdateArchivingStatusError(val isArchiving: Boolean) : HomeSnackbarState() } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsScreen.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsScreen.kt index 6b0b6d5e0e..2e9f592550 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsScreen.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsScreen.kt @@ -360,11 +360,11 @@ private fun GroupConversationDetailsContent( }, addConversationToFavourites = bottomSheetEventsHandler::onAddConversationToFavourites, moveConversationToFolder = bottomSheetEventsHandler::onMoveConversationToFolder, - moveConversationToArchive = { + updateConversationArchiveStatus = { conversationSheetContent?.let { - bottomSheetEventsHandler.onMoveConversationToArchive( + bottomSheetEventsHandler.updateConversationArchiveStatus( conversationId = it.conversationId, - shouldArchive = true, + shouldArchive = !it.isArchived, onMessage = closeBottomSheetAndShowSnackbarMessage ) } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsViewModel.kt index 44c29dbd7d..16fa680ab0 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsViewModel.kt @@ -149,7 +149,8 @@ class GroupConversationDetailsViewModel @Inject constructor( mutingConversationState = groupDetails.conversation.mutedStatus, conversationTypeDetail = ConversationTypeDetail.Group(conversationId, groupDetails.isSelfUserCreator), isTeamConversation = groupDetails.conversation.teamId?.value != null, - selfRole = groupDetails.selfRole + selfRole = groupDetails.selfRole, + isArchived = groupDetails.conversation.archived ) val isGuestAllowed = groupDetails.conversation.isGuestAllowed() || groupDetails.conversation.isNonTeamMemberAllowed() val isUpdatingReadReceiptAllowed = if (selfTeam == null) { @@ -378,7 +379,7 @@ class GroupConversationDetailsViewModel @Inject constructor( override fun onMoveConversationToFolder(conversationId: ConversationId?) { } - override fun onMoveConversationToArchive( + override fun updateConversationArchiveStatus( conversationId: ConversationId, shouldArchive: Boolean, timestamp: Long, @@ -390,8 +391,17 @@ class GroupConversationDetailsViewModel @Inject constructor( withContext(dispatcher.io()) { updateConversationArchivedStatus(conversationId, shouldArchive, timestamp) } requestInProgress = false when (result) { - ArchiveStatusUpdateResult.Failure -> onMessage(UIText.StringResource(R.string.error_archiving_conversation)) - ArchiveStatusUpdateResult.Success -> onMessage(UIText.StringResource(R.string.success_archiving_conversation)) + ArchiveStatusUpdateResult.Failure -> onMessage( + UIText.StringResource( + if (shouldArchive) R.string.error_archiving_conversation else R.string.error_unarchiving_conversation + ) + ) + + ArchiveStatusUpdateResult.Success -> onMessage( + UIText.StringResource( + if (shouldArchive) R.string.success_archiving_conversation else R.string.success_unarchiving_conversation + ) + ) } } } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/menu/GroupConversationDetailsBottomSheetEventsHandler.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/menu/GroupConversationDetailsBottomSheetEventsHandler.kt index 25c8465d32..c81fcabb27 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/menu/GroupConversationDetailsBottomSheetEventsHandler.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/details/menu/GroupConversationDetailsBottomSheetEventsHandler.kt @@ -31,7 +31,7 @@ interface GroupConversationDetailsBottomSheetEventsHandler { fun onMutingConversationStatusChange(conversationId: ConversationId?, status: MutedConversationStatus, onMessage: (UIText) -> Unit) fun onAddConversationToFavourites(conversationId: ConversationId? = null) fun onMoveConversationToFolder(conversationId: ConversationId? = null) - fun onMoveConversationToArchive( + fun updateConversationArchiveStatus( conversationId: ConversationId, shouldArchive: Boolean, timestamp: Long = DateTimeUtil.currentInstant().toEpochMilliseconds(), @@ -52,7 +52,7 @@ interface GroupConversationDetailsBottomSheetEventsHandler { override fun onAddConversationToFavourites(conversationId: ConversationId?) {} override fun onMoveConversationToFolder(conversationId: ConversationId?) {} - override fun onMoveConversationToArchive( + override fun updateConversationArchiveStatus( conversationId: ConversationId, shouldArchive: Boolean, timestamp: Long, diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/ConversationListViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/ConversationListViewModel.kt index fde5aca9bd..b9d3848d11 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/ConversationListViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/ConversationListViewModel.kt @@ -432,11 +432,11 @@ class ConversationListViewModel @Inject constructor( requestInProgress = false when (result) { is ArchiveStatusUpdateResult.Failure -> { - homeSnackBarState.emit(HomeSnackbarState.ArchivingConversationError) + homeSnackBarState.emit(HomeSnackbarState.UpdateArchivingStatusError(isArchiving)) } is ArchiveStatusUpdateResult.Success -> { - homeSnackBarState.emit(HomeSnackbarState.ArchivingConversationSuccess) + homeSnackBarState.emit(HomeSnackbarState.UpdateArchivingStatusSuccess(isArchiving)) } } } @@ -498,7 +498,8 @@ private fun ConversationDetails.toConversationItem( isSelfUserCreator = isSelfUserCreator, isSelfUserMember = isSelfUserMember, teamId = conversation.teamId, - selfMemberRole = selfRole + selfMemberRole = selfRole, + isArchived = conversation.archived ) } @@ -528,7 +529,8 @@ private fun ConversationDetails.toConversationItem( ), userId = otherUser.id, blockingState = otherUser.BlockState, - teamId = otherUser.teamId + teamId = otherUser.teamId, + isArchived = conversation.archived ) } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/ConversationRouter.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/ConversationRouter.kt index b9870c8820..3f7bb88a97 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/ConversationRouter.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/ConversationRouter.kt @@ -149,10 +149,10 @@ fun ConversationRouterHomeBridge( }, addConversationToFavourites = viewModel::addConversationToFavourites, moveConversationToFolder = viewModel::moveConversationToFolder, - moveConversationToArchive = { + updateConversationArchiveStatus = { viewModel.moveConversationToArchive( conversationId = it.conversationId, - isArchiving = true // All conversations at this point are not archived + isArchiving = !it.isArchived ) onCloseBottomSheet() }, diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/common/ConversationItemFactory.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/common/ConversationItemFactory.kt index 07c08f5e12..5cd637842b 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/common/ConversationItemFactory.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/common/ConversationItemFactory.kt @@ -249,7 +249,8 @@ fun PreviewGroupConversationItemWithUnreadCount() { ), badgeEventType = BadgeEventType.UnreadMessage(100), selfMemberRole = null, - teamId = null + teamId = null, + isArchived = false ), searchQuery = "", isSelectableItem = false, @@ -271,7 +272,8 @@ fun PreviewGroupConversationItemWithNoBadges() { ), badgeEventType = BadgeEventType.None, selfMemberRole = null, - teamId = null + teamId = null, + isArchived = false ), searchQuery = "", isSelectableItem = false, @@ -293,7 +295,8 @@ fun PreviewGroupConversationItemWithMutedBadgeAndUnreadMentionBadge() { ), badgeEventType = BadgeEventType.UnreadMention, selfMemberRole = null, - teamId = null + teamId = null, + isArchived = false ), searchQuery = "", isSelectableItem = false, @@ -317,6 +320,7 @@ fun PreviewGroupConversationItemWithOngoingCall() { selfMemberRole = null, teamId = null, hasOnGoingCall = true, + isArchived = false ), searchQuery = "", isSelectableItem = false, @@ -376,7 +380,8 @@ fun PreviewPrivateConversationItemWithBlockedBadge() { conversationInfo = ConversationInfo("Name"), blockingState = BlockingState.BLOCKED, teamId = null, - userId = UserId("value", "domain") + userId = UserId("value", "domain"), + isArchived = false ), searchQuery = "", isSelectableItem = false, diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/model/ConversationItem.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/model/ConversationItem.kt index 598c2c28f3..be72a99c49 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/model/ConversationItem.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/model/ConversationItem.kt @@ -39,21 +39,23 @@ sealed class ConversationItem { abstract val lastMessageContent: UILastMessageContent? abstract val badgeEventType: BadgeEventType abstract val teamId: TeamId? + abstract val isArchived: Boolean val isTeamConversation get() = teamId != null data class GroupConversation( val groupName: String, + val hasOnGoingCall: Boolean = false, + val isSelfUserCreator: Boolean = false, + val selfMemberRole: Conversation.Member.Role?, + val isSelfUserMember: Boolean = true, override val conversationId: ConversationId, override val mutedStatus: MutedConversationStatus, override val isLegalHold: Boolean = false, override val lastMessageContent: UILastMessageContent?, override val badgeEventType: BadgeEventType, override val teamId: TeamId?, - val hasOnGoingCall: Boolean = false, - val isSelfUserCreator: Boolean = false, - val selfMemberRole: Conversation.Member.Role?, - val isSelfUserMember: Boolean = true, + override val isArchived: Boolean, ) : ConversationItem() data class PrivateConversation( @@ -66,7 +68,8 @@ sealed class ConversationItem { override val isLegalHold: Boolean = false, override val lastMessageContent: UILastMessageContent?, override val badgeEventType: BadgeEventType, - override val teamId: TeamId? + override val teamId: TeamId?, + override val isArchived: Boolean ) : ConversationItem() data class ConnectionConversation( @@ -77,6 +80,7 @@ sealed class ConversationItem { override val isLegalHold: Boolean = false, override val lastMessageContent: UILastMessageContent?, override val badgeEventType: BadgeEventType, + override val isArchived: Boolean = false, ) : ConversationItem() { override val teamId: TeamId? = null } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/model/GroupDialogState.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/model/GroupDialogState.kt index 1001fe93d1..cffea2a5b4 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/model/GroupDialogState.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversationslist/model/GroupDialogState.kt @@ -31,5 +31,6 @@ data class GroupDialogState( data class DialogState( val conversationId: ConversationId, val conversationName: String, - val conversationTypeDetail: ConversationTypeDetail + val conversationTypeDetail: ConversationTypeDetail, + val isArchived: Boolean ) diff --git a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt index 68183813bc..327d81e718 100644 --- a/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/sharing/ImportMediaAuthenticatedViewModel.kt @@ -191,7 +191,8 @@ class ImportMediaAuthenticatedViewModel @Inject constructor( isSelfUserCreator = isSelfUserCreator, isSelfUserMember = isSelfUserMember, teamId = conversation.teamId, - selfMemberRole = selfRole + selfMemberRole = selfRole, + isArchived = conversation.archived ) } @@ -226,7 +227,8 @@ class ImportMediaAuthenticatedViewModel @Inject constructor( ), userId = otherUser.id, blockingState = otherUser.BlockState, - teamId = otherUser.teamId + teamId = otherUser.teamId, + isArchived = conversation.archived ) } 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 67ad451915..001ee7bc93 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, shouldArchiveConversation: Boolean) + fun onMoveConversationToArchive(conversationId: ConversationId, isArchivingConversation: Boolean) 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, shouldArchiveConversation: Boolean) {} + override fun onMoveConversationToArchive(conversationId: ConversationId, isArchivingConversation: Boolean) {} override fun onClearConversationContent(dialogState: DialogState) {} } } diff --git a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileInfoMessageType.kt b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileInfoMessageType.kt index 3c2348d3ed..280f145c6c 100644 --- a/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileInfoMessageType.kt +++ b/app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileInfoMessageType.kt @@ -55,7 +55,17 @@ sealed class OtherUserProfileInfoMessageType(override val uiText: UIText) : Snac object ConversationContentDeleteFailure : OtherUserProfileInfoMessageType(UIText.StringResource(R.string.conversation_content_delete_failure)) - object ArchiveConversationError : OtherUserProfileInfoMessageType(UIText.StringResource(R.string.error_archiving_conversation)) - object ArchiveConversationSuccess : OtherUserProfileInfoMessageType(UIText.StringResource(R.string.success_archiving_conversation)) + data class ArchiveConversationError(val isArchiving: Boolean) : OtherUserProfileInfoMessageType( + UIText.StringResource( + if (isArchiving) R.string.error_archiving_conversation + else R.string.error_unarchiving_conversation + ) + ) + data class ArchiveConversationSuccess(val isArchiving: Boolean) : OtherUserProfileInfoMessageType( + UIText.StringResource( + if (isArchiving) R.string.success_archiving_conversation + else R.string.success_unarchiving_conversation + ) + ) } 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 33a27987c6..b55ce36be0 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,18 @@ class OtherUserProfileScreenViewModel @Inject constructor( override fun onMoveConversationToFolder(conversationId: ConversationId?) { } - override fun onMoveConversationToArchive(conversationId: ConversationId, shouldArchiveConversation: Boolean) { + override fun onMoveConversationToArchive(conversationId: ConversationId, isArchivingConversation: Boolean) { viewModelScope.launch { requestInProgress = true - val result = withContext(dispatchers.io()) { updateConversationArchivedStatus(conversationId, shouldArchiveConversation) } + val result = withContext(dispatchers.io()) { updateConversationArchivedStatus(conversationId, isArchivingConversation) } requestInProgress = false when (result) { ArchiveStatusUpdateResult.Failure -> { - closeBottomSheetAndShowInfoMessage(OtherUserProfileInfoMessageType.ArchiveConversationError) + closeBottomSheetAndShowInfoMessage(OtherUserProfileInfoMessageType.ArchiveConversationError(isArchivingConversation)) } ArchiveStatusUpdateResult.Success -> { - closeBottomSheetAndShowInfoMessage(OtherUserProfileInfoMessageType.ArchiveConversationSuccess) + closeBottomSheetAndShowInfoMessage(OtherUserProfileInfoMessageType.ArchiveConversationSuccess(isArchivingConversation)) } } } @@ -372,7 +372,8 @@ class OtherUserProfileScreenViewModel @Inject constructor( otherUser.BlockState ), isTeamConversation = conversation.isTeamGroup(), - selfRole = Conversation.Member.Role.Member + selfRole = Conversation.Member.Role.Member, + isArchived = conversation.archived ) } ) 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 293ff54525..f1f2b94f81 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 @@ -32,7 +32,7 @@ import com.wire.android.ui.userprofile.other.OtherUserProfileBottomSheetEventsHa fun OtherUserProfileBottomSheetContent( bottomSheetState: OtherUserBottomSheetState, eventsHandler: OtherUserProfileBottomSheetEventsHandler, - clearContent : (DialogState) -> Unit, + clearContent: (DialogState) -> Unit, blockUser: (BlockUserDialogState) -> Unit, unblockUser: (UnblockUserDialogState) -> Unit, closeBottomSheet: () -> Unit, @@ -53,7 +53,12 @@ fun OtherUserProfileBottomSheetContent( }, addConversationToFavourites = eventsHandler::onAddConversationToFavourites, moveConversationToFolder = eventsHandler::onMoveConversationToFolder, - moveConversationToArchive = { eventsHandler.onMoveConversationToArchive(it.conversationId, true) }, + updateConversationArchiveStatus = { + eventsHandler.onMoveConversationToArchive( + conversationId = it.conversationId, + isArchivingConversation = !it.isArchived + ) + }, clearConversationContent = clearContent, blockUser = blockUser, unblockUser = unblockUser, @@ -61,12 +66,14 @@ fun OtherUserProfileBottomSheetContent( deleteGroup = { } ) } + is BottomSheetContent.ChangeRole -> EditGroupRoleBottomSheet( groupState = state.groupState, changeMemberRole = eventsHandler::onChangeMemberRole, closeChangeRoleBottomSheet = closeBottomSheet ) + null -> { // we don't want to show empty BottomSheet closeBottomSheet() diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index cc40d7adbf..2d2375f92e 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -97,6 +97,7 @@ Add to Favorites Move to folder Move to archive + Move out of Archive Block Unblock Leave the group @@ -520,6 +521,7 @@ Add to Favorites Move to Folder Move to Archive + Move out of Archive Clear Content… Block Unblock @@ -718,7 +720,9 @@ There was an error while deleting conversation You can only send up to 20 files at once Conversation was archived + Conversation was unarchived Conversation could not be archived + Conversation could not be unarchived MessageComposeInputState transition Collapse button rotation degree transition diff --git a/app/src/test/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsViewModelTest.kt index a7fa277e98..29bec253ee 100644 --- a/app/src/test/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/home/conversations/details/GroupConversationDetailsViewModelTest.kt @@ -147,7 +147,7 @@ class GroupConversationDetailsViewModelTest { .arrange() // When - viewModel.onMoveConversationToArchive( + viewModel.updateConversationArchiveStatus( conversationId = viewModel.conversationId, shouldArchive = true, timestamp = archivingEventTimestamp @@ -185,7 +185,7 @@ class GroupConversationDetailsViewModelTest { .arrange() // When - viewModel.onMoveConversationToArchive(viewModel.conversationId, false, archivingEventTimestamp) {} + viewModel.updateConversationArchiveStatus(viewModel.conversationId, false, archivingEventTimestamp) {} // Then coVerify(exactly = 1) { @@ -392,7 +392,8 @@ class GroupConversationDetailsViewModelTest { mutingConversationState = details.conversation.mutedStatus, conversationTypeDetail = ConversationTypeDetail.Group(details.conversation.id, details.isSelfUserCreator), selfRole = Conversation.Member.Role.Member, - isTeamConversation = details.conversation.isTeamGroup() + isTeamConversation = details.conversation.isTeamGroup(), + isArchived = false ) // When - Then assertEquals(expected, viewModel.conversationSheetContent) diff --git a/app/src/test/kotlin/com/wire/android/ui/home/conversationslist/ConversationListViewModelTest.kt b/app/src/test/kotlin/com/wire/android/ui/home/conversationslist/ConversationListViewModelTest.kt index 7b5abe7d80..959f23049a 100644 --- a/app/src/test/kotlin/com/wire/android/ui/home/conversationslist/ConversationListViewModelTest.kt +++ b/app/src/test/kotlin/com/wire/android/ui/home/conversationslist/ConversationListViewModelTest.kt @@ -263,7 +263,7 @@ class ConversationListViewModelTest { conversationListViewModel.homeSnackBarState.test { conversationListViewModel.moveConversationToArchive(conversationId, isArchiving, archivingTimestamp) - expectMostRecentItem() shouldBeEqualTo HomeSnackbarState.ArchivingConversationSuccess + expectMostRecentItem() shouldBeEqualTo HomeSnackbarState.UpdateArchivingStatusSuccess(isArchiving = isArchiving) } } @@ -276,7 +276,7 @@ class ConversationListViewModelTest { conversationListViewModel.homeSnackBarState.test { conversationListViewModel.moveConversationToArchive(conversationId, isArchiving, archivingTimestamp) - expectMostRecentItem() shouldBeEqualTo HomeSnackbarState.ArchivingConversationError + expectMostRecentItem() shouldBeEqualTo HomeSnackbarState.UpdateArchivingStatusError(isArchiving = isArchiving) } } @@ -297,7 +297,8 @@ class ConversationListViewModelTest { badgeEventType = BadgeEventType.None, userId = userId, blockingState = BlockingState.CAN_NOT_BE_BLOCKED, - teamId = null + teamId = null, + isArchived = false ) } }