Skip to content

Commit

Permalink
fix: not showing dialog when archiving users from user profile screen…
Browse files Browse the repository at this point in the history
… [WPB-4993] (#2304)
  • Loading branch information
gongracr authored Oct 9, 2023
1 parent 6caf28e commit 480af5a
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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) {}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -313,6 +314,10 @@ fun OtherProfileScreenContent(
bottomSheetEventsHandler.onClearConversationContent(it)
}
)
ArchiveConversationDialog(
dialogState = archivingConversationDialogState,
onArchiveButtonClicked = bottomSheetEventsHandler::onMoveConversationToArchive
)
}

@Composable
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
)
)
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ fun OtherUserProfileBottomSheetContent(
if (!it.isArchived) {
archivingStatusState(it)
} else {
eventsHandler.onMoveConversationToArchive(it.conversationId, isArchivingConversation = false)
eventsHandler.onMoveConversationToArchive(it)
}
},
clearConversationContent = clearContent,
Expand Down

0 comments on commit 480af5a

Please sign in to comment.