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

feat: move conversation to folder from other user profile [WPB-15479] [WPB-14630] #3849

Merged
merged 5 commits into from
Jan 30, 2025
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 @@ -29,7 +29,7 @@ import com.wire.kalium.logic.feature.conversation.ConversationScope
import com.wire.kalium.logic.feature.conversation.CreateGroupConversationUseCase
import com.wire.kalium.logic.feature.conversation.GetConversationProtocolInfoUseCase
import com.wire.kalium.logic.feature.conversation.GetConversationUnreadEventsCountUseCase
import com.wire.kalium.logic.feature.conversation.GetOneToOneConversationUseCase
import com.wire.kalium.logic.feature.conversation.GetOneToOneConversationDetailsUseCase
import com.wire.kalium.logic.feature.conversation.GetOrCreateOneToOneConversationUseCase
import com.wire.kalium.logic.feature.conversation.IsOneToOneConversationCreatedUseCase
import com.wire.kalium.logic.feature.conversation.JoinConversationViaCodeUseCase
Expand Down Expand Up @@ -95,7 +95,7 @@ class ConversationModule {

@ViewModelScoped
@Provides
fun provideObserveConversationUseCase(conversationScope: ConversationScope): GetOneToOneConversationUseCase =
fun provideObserveConversationUseCase(conversationScope: ConversationScope): GetOneToOneConversationDetailsUseCase =
conversationScope.getOneToOneConversation

@ViewModelScoped
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@

package com.wire.android.ui.connection

import androidx.compose.foundation.layout.Box
import androidx.compose.foundation.layout.Column
import androidx.compose.foundation.layout.Spacer
import androidx.compose.foundation.layout.height
Expand Down Expand Up @@ -66,6 +67,7 @@ fun ConnectionActionButton(
fullName: String,
connectionStatus: ConnectionState,
isConversationStarted: Boolean,
modifier: Modifier = Modifier,
onConnectionRequestIgnored: (String) -> Unit = {},
onOpenConversation: (ConversationId) -> Unit = {},
viewModel: ConnectionActionButtonViewModel =
Expand Down Expand Up @@ -95,43 +97,28 @@ fun ConnectionActionButton(
}
}

when (connectionStatus) {
ConnectionState.SENT -> WireSecondaryButton(
text = stringResource(R.string.connection_label_cancel_request),
loading = viewModel.actionableState().isPerformingAction,
onClick = viewModel::onCancelConnectionRequest,
clickBlockParams = ClickBlockParams(blockWhenSyncing = true, blockWhenConnecting = true),
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)

ConnectionState.ACCEPTED -> WirePrimaryButton(
text = stringResource(if (isConversationStarted) R.string.label_open_conversation else R.string.label_start_conversation),
loading = viewModel.actionableState().isPerformingAction,
onClick = {
viewModel.onOpenConversation(onOpenConversation) {
unableStartConversationDialogState.show(UnableStartConversationDialogState(fullName))
}
},
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)
Box(modifier = modifier) {
when (connectionStatus) {
ConnectionState.SENT -> WireSecondaryButton(
text = stringResource(R.string.connection_label_cancel_request),
loading = viewModel.actionableState().isPerformingAction,
onClick = viewModel::onCancelConnectionRequest,
clickBlockParams = ClickBlockParams(blockWhenSyncing = true, blockWhenConnecting = true),
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)

ConnectionState.IGNORED -> WirePrimaryButton(
text = stringResource(R.string.connection_label_accept),
loading = viewModel.actionableState().isPerformingAction,
onClick = viewModel::onAcceptConnectionRequest,
clickBlockParams = ClickBlockParams(blockWhenSyncing = true, blockWhenConnecting = true),
leadingIcon = {
Icon(
painter = painterResource(id = R.drawable.ic_check_tick),
contentDescription = null,
modifier = Modifier.padding(dimensions().spacing8x)
)
},
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)
ConnectionState.ACCEPTED -> WirePrimaryButton(
text = stringResource(if (isConversationStarted) R.string.label_open_conversation else R.string.label_start_conversation),
loading = viewModel.actionableState().isPerformingAction,
onClick = {
viewModel.onOpenConversation(onOpenConversation) {
unableStartConversationDialogState.show(UnableStartConversationDialogState(fullName))
}
},
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)

ConnectionState.PENDING -> Column {
WirePrimaryButton(
ConnectionState.IGNORED -> WirePrimaryButton(
text = stringResource(R.string.connection_label_accept),
loading = viewModel.actionableState().isPerformingAction,
onClick = viewModel::onAcceptConnectionRequest,
Expand All @@ -145,61 +132,78 @@ fun ConnectionActionButton(
},
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)
Spacer(modifier = Modifier.height(dimensions().spacing8x))
WirePrimaryButton(
text = stringResource(R.string.connection_label_ignore),

ConnectionState.PENDING -> Column {
WirePrimaryButton(
text = stringResource(R.string.connection_label_accept),
loading = viewModel.actionableState().isPerformingAction,
onClick = viewModel::onAcceptConnectionRequest,
clickBlockParams = ClickBlockParams(blockWhenSyncing = true, blockWhenConnecting = true),
leadingIcon = {
Icon(
painter = painterResource(id = R.drawable.ic_check_tick),
contentDescription = null,
modifier = Modifier.padding(dimensions().spacing8x)
)
},
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)
Spacer(modifier = Modifier.height(dimensions().spacing8x))
WirePrimaryButton(
text = stringResource(R.string.connection_label_ignore),
loading = viewModel.actionableState().isPerformingAction,
state = WireButtonState.Error,
onClick = {
viewModel.onIgnoreConnectionRequest {
onConnectionRequestIgnored(it)
}
},
clickBlockParams = ClickBlockParams(blockWhenSyncing = true, blockWhenConnecting = true),
leadingIcon = {
Icon(
painter = painterResource(id = R.drawable.ic_close),
contentDescription = null,
modifier = Modifier.padding(dimensions().spacing8x)
)
},
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)
}

ConnectionState.BLOCKED -> {
WireSecondaryButton(
text = stringResource(R.string.user_profile_unblock_user),
loading = viewModel.actionableState().isPerformingAction,
onClick = {
unblockUserDialogState.show(
UnblockUserDialogState(
userId = userId,
userName = userName
)
)
},
clickBlockParams = ClickBlockParams(blockWhenSyncing = true, blockWhenConnecting = true),
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)
}

ConnectionState.NOT_CONNECTED,
ConnectionState.CANCELLED,
ConnectionState.MISSING_LEGALHOLD_CONSENT -> WirePrimaryButton(
text = stringResource(R.string.connection_label_connect),
loading = viewModel.actionableState().isPerformingAction,
state = WireButtonState.Error,
onClick = {
viewModel.onIgnoreConnectionRequest {
onConnectionRequestIgnored(it)
}
},
onClick = viewModel::onSendConnectionRequest,
clickBlockParams = ClickBlockParams(blockWhenSyncing = true, blockWhenConnecting = true),
leadingIcon = {
Icon(
painter = painterResource(id = R.drawable.ic_close),
painter = painterResource(id = R.drawable.ic_add_contact),
contentDescription = null,
modifier = Modifier.padding(dimensions().spacing8x)
)
},
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)
}

ConnectionState.BLOCKED -> {
WireSecondaryButton(
text = stringResource(R.string.user_profile_unblock_user),
loading = viewModel.actionableState().isPerformingAction,
onClick = {
unblockUserDialogState.show(
UnblockUserDialogState(
userId = userId,
userName = userName
)
)
},
clickBlockParams = ClickBlockParams(blockWhenSyncing = true, blockWhenConnecting = true),
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)
}

ConnectionState.NOT_CONNECTED,
ConnectionState.CANCELLED,
ConnectionState.MISSING_LEGALHOLD_CONSENT -> WirePrimaryButton(
text = stringResource(R.string.connection_label_connect),
loading = viewModel.actionableState().isPerformingAction,
onClick = viewModel::onSendConnectionRequest,
clickBlockParams = ClickBlockParams(blockWhenSyncing = true, blockWhenConnecting = true),
leadingIcon = {
Icon(
painter = painterResource(id = R.drawable.ic_add_contact),
contentDescription = null,
modifier = Modifier.padding(dimensions().spacing8x)
)
},
modifier = Modifier.testTag(CONNECTION_ACTION_BUTTONS_TEST_TAG),
)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -126,9 +126,9 @@ import com.wire.android.ui.theme.wireColorScheme
import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.ui.PreviewMultipleThemes
import com.wire.android.util.ui.SnackBarMessageHandler
import com.wire.android.util.ui.UIText
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.conversation.ConversationFolder
import com.wire.kalium.logic.data.conversation.MutedConversationStatus
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.GroupID
Expand All @@ -149,10 +149,6 @@ fun GroupConversationDetailsScreen(
conversationFoldersScreenResultRecipient:
ResultRecipient<ConversationFoldersScreenDestination, ConversationFoldersNavBackArgs>,
viewModel: GroupConversationDetailsViewModel = hiltViewModel(),
removeConversationFromFolderVM: RemoveConversationFromFolderVM =
hiltViewModelScoped<RemoveConversationFromFolderVMImpl, RemoveConversationFromFolderVM, RemoveConversationFromFolderArgs>(
RemoveConversationFromFolderArgs
),
) {
val scope = rememberCoroutineScope()
val resources = LocalContext.current.resources
Expand Down Expand Up @@ -264,7 +260,6 @@ fun GroupConversationDetailsScreen(
onMoveToFolder = {
navigator.navigate(NavigationCommand(ConversationFoldersScreenDestination(it)))
},
removeFromFolder = removeConversationFromFolderVM::removeFromFolder
)

val tryAgainSnackBarMessage = stringResource(id = R.string.error_unknown_message)
Expand Down Expand Up @@ -318,13 +313,16 @@ private fun GroupConversationDetailsContent(
isAbandonedOneOnOneConversation: Boolean,
onSearchConversationMessagesClick: () -> Unit,
onConversationMediaClick: () -> Unit,
removeFromFolder: (conversationId: ConversationId, conversationName: String, folder: ConversationFolder) -> Unit,
onMoveToFolder: (ConversationFoldersNavArgs) -> Unit = {},
initialPageIndex: GroupConversationDetailsTabItem = GroupConversationDetailsTabItem.OPTIONS,
changeConversationFavoriteStateViewModel: ChangeConversationFavoriteVM =
hiltViewModelScoped<ChangeConversationFavoriteVMImpl, ChangeConversationFavoriteVM, ChangeConversationFavoriteStateArgs>(
ChangeConversationFavoriteStateArgs
),
removeConversationFromFolderVM: RemoveConversationFromFolderVM =
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

what VM refers to ? better to use full name than abbreviation

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's because it's hard to fit to the max line with this view model argument

hiltViewModelScoped<RemoveConversationFromFolderVMImpl, RemoveConversationFromFolderVM, RemoveConversationFromFolderArgs>(
RemoveConversationFromFolderArgs
),
) {
val scope = rememberCoroutineScope()
val resources = LocalContext.current.resources
Expand Down Expand Up @@ -504,7 +502,7 @@ private fun GroupConversationDetailsContent(
},
changeFavoriteState = changeConversationFavoriteStateViewModel::changeFavoriteState,
moveConversationToFolder = onMoveToFolder,
removeFromFolder = removeFromFolder,
removeFromFolder = removeConversationFromFolderVM::removeFromFolder,
updateConversationArchiveStatus = {
// Only show the confirmation dialog if the conversation is not archived
if (!it.isArchived) {
Expand Down Expand Up @@ -556,6 +554,14 @@ private fun GroupConversationDetailsContent(
VisibilityState(legalHoldSubjectDialogState) {
LegalHoldSubjectConversationDialog(legalHoldSubjectDialogState::dismiss)
}

SnackBarMessageHandler(infoMessages = changeConversationFavoriteStateViewModel.infoMessage, onEmitted = {
sheetState.hide()
})

SnackBarMessageHandler(infoMessages = removeConversationFromFolderVM.infoMessage, onEmitted = {
sheetState.hide()
})
}

@Composable
Expand Down Expand Up @@ -659,8 +665,7 @@ fun PreviewGroupConversationDetails() {
onSearchConversationMessagesClick = {},
onConversationMediaClick = {},
isAbandonedOneOnOneConversation = false,
initialPageIndex = GroupConversationDetailsTabItem.PARTICIPANTS,
removeFromFolder = { _, _, _ -> }
initialPageIndex = GroupConversationDetailsTabItem.PARTICIPANTS
)
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,9 @@ fun OtherUserProfileScreen(
navigateBack = navigator::navigateBack,
onConversationMediaClick = onConversationMediaClick,
onLegalHoldLearnMoreClick = remember { { legalHoldSubjectDialogState.show(Unit) } },
onMoveToFolder = null // TODO implement when conversation details will be available in OtherUserProfileScreenViewModel
onMoveToFolder = {
navigator.navigate(NavigationCommand(ConversationFoldersScreenDestination(it)))
}
)

LaunchedEffect(Unit) {
Expand Down Expand Up @@ -266,7 +268,7 @@ fun OtherProfileScreenContent(
onConversationMediaClick: () -> Unit = {},
navigateBack: () -> Unit = {},
onLegalHoldLearnMoreClick: () -> Unit = {},
onMoveToFolder: ((ConversationFoldersNavArgs) -> Unit)? = null,
onMoveToFolder: (ConversationFoldersNavArgs) -> Unit = {},
changeConversationFavoriteViewModel: ChangeConversationFavoriteVM =
hiltViewModelScoped<ChangeConversationFavoriteVMImpl, ChangeConversationFavoriteVM, ChangeConversationFavoriteStateArgs>(
ChangeConversationFavoriteStateArgs
Expand Down Expand Up @@ -641,8 +643,8 @@ fun ContentFooter(
state.fullName,
state.connectionState,
state.isConversationStarted,
onIgnoreConnectionRequest,
onOpenConversation
onConnectionRequestIgnored = onIgnoreConnectionRequest,
onOpenConversation = onOpenConversation
)
}
}
Expand Down
Loading
Loading