Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: not showing dialog when archiving users from user profile screen [WPB-4993] #2304

Merged
merged 1 commit into from
Oct 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@
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 @@
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) {}

Check warning on line 84 in app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileEventsHandlers.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/userprofile/other/OtherUserProfileEventsHandlers.kt#L84

Added line #L84 was not covered by tests
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
Loading