Skip to content

Commit

Permalink
fix: do not show confirmation dialogs when unarchiving conversations …
Browse files Browse the repository at this point in the history
…[WPB-4435] (#2303)
  • Loading branch information
gongracr committed Oct 6, 2023
1 parent 88bfae8 commit 6caf28e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ internal fun ConversationMainSheetContent(
customVerticalPadding = dimensions().spacing8x
),
menuItems = buildList<@Composable () -> Unit> {
if (conversationSheetContent.canEditNotifications()) {
if (conversationSheetContent.canEditNotifications() && !conversationSheetContent.isArchived) {
add {
MenuBottomSheetItem(
title = stringResource(R.string.label_notifications),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ import com.wire.android.ui.home.conversationslist.model.ConversationItem
import com.wire.android.ui.home.conversationslist.model.ConversationsSource
import com.wire.android.ui.home.conversationslist.model.DialogState
import com.wire.android.ui.home.conversationslist.model.GroupDialogState
import com.wire.android.ui.home.conversationslist.model.isArchive
import com.wire.android.ui.home.conversationslist.search.SearchConversationScreen
import com.wire.android.util.extension.openAppInfoScreen
import com.wire.kalium.logic.data.id.ConversationId
Expand All @@ -68,6 +69,7 @@ import kotlinx.coroutines.flow.MutableSharedFlow
// Since the HomeScreen is responsible for displaying the bottom sheet content,
// we create a bridge that passes the content of the BottomSheet
// also we expose the lambda which expands the BottomSheet from the HomeScreen
@Suppress("ComplexMethod")
@Composable
fun ConversationRouterHomeBridge(
navigator: Navigator,
Expand Down Expand Up @@ -119,6 +121,16 @@ fun ConversationRouterHomeBridge(
}
}

fun showConfirmationDialogOrUnarchive(): (DialogState) -> Unit {
return { dialogState ->
if (dialogState.isArchived) {
viewModel.moveConversationToArchive(dialogState)
} else {
conversationRouterHomeState.archiveConversationDialogState.show(dialogState)
}
}
}

with(conversationRouterHomeState) {
fun openConversationBottomSheet(
conversationItem: ConversationItem,
Expand Down Expand Up @@ -156,7 +168,7 @@ fun ConversationRouterHomeBridge(
},
addConversationToFavourites = viewModel::addConversationToFavourites,
moveConversationToFolder = viewModel::moveConversationToFolder,
updateConversationArchiveStatus = archiveConversationDialogState::show,
updateConversationArchiveStatus = showConfirmationDialogOrUnarchive(),
clearConversationContent = clearContentDialogState::show,
blockUser = blockUserDialogState::show,
unblockUser = unblockUserDialogState::show,
Expand Down Expand Up @@ -201,6 +213,7 @@ fun ConversationRouterHomeBridge(
ConversationItemType.ALL_CONVERSATIONS ->
AllConversationScreenContent(
conversations = foldersWithConversations,
isFromArchive = conversationsSource.isArchive(),
hasNoConversations = hasNoConversations,
onEditConversation = onEditConversationItem,
onOpenConversationNotificationsSettings = onEditNotifications,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,3 +29,5 @@ enum class ConversationsSource {
MAIN,
ARCHIVE
}

fun ConversationsSource.isArchive(): Boolean = this == ConversationsSource.ARCHIVE

0 comments on commit 6caf28e

Please sign in to comment.