Skip to content

Commit

Permalink
Merge branch 'develop' into feat/add-a-button-to-check-crl-revocation…
Browse files Browse the repository at this point in the history
…-to-the-debug-screen-cherry-pick

# Conflicts:
#	kalium
  • Loading branch information
MohamadJaara committed Mar 22, 2024
2 parents 947f5de + 06d1399 commit 89ecea1
Show file tree
Hide file tree
Showing 42 changed files with 1,143 additions and 347 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,7 @@ import com.wire.kalium.logic.feature.conversation.RenameConversationUseCase
import com.wire.kalium.logic.feature.conversation.SendTypingEventUseCase
import com.wire.kalium.logic.feature.conversation.SetNotifiedAboutConversationUnderLegalHoldUseCase
import com.wire.kalium.logic.feature.conversation.SetUserInformedAboutVerificationUseCase
import com.wire.kalium.logic.feature.conversation.SyncConversationCodeUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationAccessRoleUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationArchivedStatusUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationMemberRoleUseCase
Expand Down Expand Up @@ -288,4 +289,9 @@ class ConversationModule {
fun provideObserveLegalHoldWithChangeNotifiedForConversationUseCase(
conversationScope: ConversationScope,
): ObserveConversationUnderLegalHoldNotifiedUseCase = conversationScope.observeConversationUnderLegalHoldNotified

@ViewModelScoped
@Provides
fun provideSyncConversationCodeUseCase(conversationScope: ConversationScope): SyncConversationCodeUseCase =
conversationScope.syncConversationCode
}
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,9 @@ import com.wire.kalium.logic.feature.message.SendLocationUseCase
import com.wire.kalium.logic.feature.message.SendTextMessageUseCase
import com.wire.kalium.logic.feature.message.ToggleReactionUseCase
import com.wire.kalium.logic.feature.message.composite.SendButtonActionMessageUseCase
import com.wire.kalium.logic.feature.message.draft.GetMessageDraftUseCase
import com.wire.kalium.logic.feature.message.draft.RemoveMessageDraftUseCase
import com.wire.kalium.logic.feature.message.draft.SaveMessageDraftUseCase
import com.wire.kalium.logic.feature.message.ephemeral.EnqueueMessageSelfDeletionUseCase
import com.wire.kalium.logic.feature.message.getPaginatedFlowOfAssetMessageByConversationId
import com.wire.kalium.logic.feature.message.getPaginatedFlowOfMessagesByConversation
Expand Down Expand Up @@ -198,4 +201,19 @@ class MessageModule {
@Provides
fun provideObserveAssetStatusesUseCase(messageScope: MessageScope): ObserveAssetStatusesUseCase =
messageScope.observeAssetStatuses

@ViewModelScoped
@Provides
fun provideSaveMessageDraftUseCase(messageScope: MessageScope): SaveMessageDraftUseCase =
messageScope.saveMessageDraftUseCase

@ViewModelScoped
@Provides
fun provideGetMessageDraftUseCase(messageScope: MessageScope): GetMessageDraftUseCase =
messageScope.getMessageDraftUseCase

@ViewModelScoped
@Provides
fun provideRemoveMessageDraftUseCase(messageScope: MessageScope): RemoveMessageDraftUseCase =
messageScope.removeMessageDraftUseCase
}
6 changes: 3 additions & 3 deletions app/src/main/kotlin/com/wire/android/model/ItemActionType.kt
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@
package com.wire.android.model

enum class ItemActionType {
CHECK, CLICK, CHECK_AND_CLICK;
CHECK, CLICK;

val checkable: Boolean get() = this == CHECK || this == CHECK_AND_CLICK
val clickable: Boolean get() = this == CLICK || this == CHECK_AND_CLICK
val checkable: Boolean get() = this == CHECK
val clickable: Boolean get() = this == CLICK
}
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import androidx.compose.foundation.layout.padding
import androidx.compose.foundation.layout.wrapContentWidth
import androidx.compose.runtime.Composable
import androidx.compose.ui.Modifier
import androidx.compose.ui.unit.Dp
import com.wire.android.model.Clickable
import com.wire.android.ui.home.conversationslist.common.RowItem
import com.wire.android.ui.theme.DEFAULT_WEIGHT
Expand All @@ -32,6 +33,7 @@ import com.wire.android.ui.theme.DEFAULT_WEIGHT
fun RowItemTemplate(
leadingIcon: @Composable () -> Unit = {},
title: @Composable () -> Unit = {},
titleStartPadding: Dp = dimensions().spacing8x,
subtitle: @Composable () -> Unit = {},
actions: @Composable () -> Unit = {},
clickable: Clickable = Clickable(false) {},
Expand All @@ -45,7 +47,7 @@ fun RowItemTemplate(
Column(
modifier = Modifier
.weight(1f)
.padding(start = dimensions().spacing8x)
.padding(start = titleStartPadding)
) {
title()
subtitle()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,11 +85,13 @@ fun WireLabelledCheckbox(
@Composable
fun WireCheckbox(
checked: Boolean,
onCheckedChange: ((Boolean) -> Unit)
onCheckedChange: ((Boolean) -> Unit)?,
modifier: Modifier = Modifier,
) {
Checkbox(
checked = checked,
onCheckedChange = onCheckedChange,
colors = wireCheckBoxColors()
colors = wireCheckBoxColors(),
modifier = modifier,
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,7 @@ import com.wire.android.ui.home.conversations.info.ConversationInfoViewModel
import com.wire.android.ui.home.conversations.info.ConversationInfoViewState
import com.wire.android.ui.home.conversations.messages.ConversationMessagesViewModel
import com.wire.android.ui.home.conversations.messages.ConversationMessagesViewState
import com.wire.android.ui.home.conversations.messages.draft.MessageDraftViewModel
import com.wire.android.ui.home.conversations.migration.ConversationMigrationViewModel
import com.wire.android.ui.home.conversations.model.ExpirationStatus
import com.wire.android.ui.home.conversations.model.UIMessage
Expand All @@ -132,6 +133,7 @@ import com.wire.android.ui.home.conversations.selfdeletion.SelfDeletionMenuItems
import com.wire.android.ui.home.gallery.MediaGalleryActionType
import com.wire.android.ui.home.gallery.MediaGalleryNavBackArgs
import com.wire.android.ui.home.messagecomposer.MessageComposer
import com.wire.android.ui.home.messagecomposer.model.MessageComposition
import com.wire.android.ui.home.messagecomposer.state.MessageBundle
import com.wire.android.ui.home.messagecomposer.state.MessageComposerStateHolder
import com.wire.android.ui.home.messagecomposer.state.rememberMessageComposerStateHolder
Expand Down Expand Up @@ -187,6 +189,7 @@ fun ConversationScreen(
conversationMessagesViewModel: ConversationMessagesViewModel = hiltViewModel(),
messageComposerViewModel: MessageComposerViewModel = hiltViewModel(),
conversationMigrationViewModel: ConversationMigrationViewModel = hiltViewModel(),
messageDraftViewModel: MessageDraftViewModel = hiltViewModel(),
groupDetailsScreenResultRecipient: ResultRecipient<GroupConversationDetailsScreenDestination, GroupConversationDetailsNavBackArgs>,
mediaGalleryScreenResultRecipient: ResultRecipient<MediaGalleryScreenDestination, MediaGalleryNavBackArgs>,
resultNavigator: ResultBackNavigator<GroupConversationDetailsNavBackArgs>,
Expand All @@ -199,7 +202,9 @@ fun ConversationScreen(
val messageComposerViewState = messageComposerViewModel.messageComposerViewState
val messageComposerStateHolder = rememberMessageComposerStateHolder(
messageComposerViewState = messageComposerViewState,
modalBottomSheetState = conversationScreenState.modalBottomSheetState
modalBottomSheetState = conversationScreenState.modalBottomSheetState,
messageComposition = messageDraftViewModel.state,
onSaveDraft = messageComposerViewModel::saveDraft
)
val permissionPermanentlyDeniedDialogState =
rememberVisibilityState<PermissionPermanentlyDeniedDialogState>()
Expand All @@ -214,6 +219,17 @@ fun ConversationScreen(
}
}

// set message composer input to edit mode when editMessage is not null from MessageDraft
LaunchedEffect(messageDraftViewModel.state.value.editMessageId) {
val compositionState = messageDraftViewModel.state.value
if (compositionState.editMessageId != null) {
messageComposerStateHolder.toEdit(
messageId = compositionState.editMessageId,
editMessageText = compositionState.messageText,
mentions = compositionState.selectedMentions.map { it.intoMessageMention() })
}
}

conversationMigrationViewModel.migratedConversationId?.let { migratedConversationId ->
navigator.navigate(
NavigationCommand(
Expand Down Expand Up @@ -1047,10 +1063,13 @@ private fun CoroutineScope.withSmoothScreenLoad(block: () -> Unit) = launch {
@Composable
fun PreviewConversationScreen() {
val messageComposerViewState = remember { mutableStateOf(MessageComposerViewState()) }
val messageCompositionState = remember { mutableStateOf(MessageComposition.DEFAULT) }
val conversationScreenState = rememberConversationScreenState()
val messageComposerStateHolder = rememberMessageComposerStateHolder(
messageComposerViewState = messageComposerViewState,
modalBottomSheetState = conversationScreenState.modalBottomSheetState
modalBottomSheetState = conversationScreenState.modalBottomSheetState,
messageComposition = messageCompositionState,
onSaveDraft = {}
)
ConversationScreen(
bannerMessage = null,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@ import com.wire.kalium.logic.data.asset.KaliumFileSystem
import com.wire.kalium.logic.data.conversation.Conversation.TypingIndicatorMode
import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.message.SelfDeletionTimer
import com.wire.kalium.logic.data.message.draft.MessageDraft
import com.wire.kalium.logic.data.user.OtherUser
import com.wire.kalium.logic.failure.LegalHoldEnabledForConversationFailure
import com.wire.kalium.logic.feature.asset.GetAssetSizeLimitUseCase
Expand All @@ -73,6 +74,8 @@ import com.wire.kalium.logic.feature.message.SendEditTextMessageUseCase
import com.wire.kalium.logic.feature.message.SendKnockUseCase
import com.wire.kalium.logic.feature.message.SendLocationUseCase
import com.wire.kalium.logic.feature.message.SendTextMessageUseCase
import com.wire.kalium.logic.feature.message.draft.RemoveMessageDraftUseCase
import com.wire.kalium.logic.feature.message.draft.SaveMessageDraftUseCase
import com.wire.kalium.logic.feature.message.ephemeral.EnqueueMessageSelfDeletionUseCase
import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveSelfDeletionTimerSettingsForConversationUseCase
import com.wire.kalium.logic.feature.selfDeletingMessages.PersistNewSelfDeletionTimerUseCase
Expand Down Expand Up @@ -120,6 +123,8 @@ class MessageComposerViewModel @Inject constructor(
private val setNotifiedAboutConversationUnderLegalHold: SetNotifiedAboutConversationUnderLegalHoldUseCase,
private val observeConversationUnderLegalHoldNotified: ObserveConversationUnderLegalHoldNotifiedUseCase,
private val sendLocation: SendLocationUseCase,
private val saveMessageDraft: SaveMessageDraftUseCase,
private val removeMessageDraft: RemoveMessageDraftUseCase
) : SavedStateViewModel(savedStateHandle) {

var messageComposerViewState = mutableStateOf(MessageComposerViewState())
Expand Down Expand Up @@ -240,6 +245,7 @@ class MessageComposerViewModel @Inject constructor(
mentions = newMentions.map { it.intoMessageMention() },
).handleLegalHoldFailureAfterSendingMessage()
}
removeMessageDraft(conversationId)
sendTypingEvent(conversationId, TypingIndicatorMode.STOPPED)
}

Expand All @@ -265,6 +271,7 @@ class MessageComposerViewModel @Inject constructor(
quotedMessageId = quotedMessageId
).handleLegalHoldFailureAfterSendingMessage()
}
removeMessageDraft(conversationId)
sendTypingEvent(conversationId, TypingIndicatorMode.STOPPED)
}

Expand Down Expand Up @@ -506,6 +513,12 @@ class MessageComposerViewModel @Inject constructor(
}
}

fun saveDraft(messageDraft: MessageDraft) {
viewModelScope.launch {
saveMessageDraft(conversationId, messageDraft)
}
}

fun acceptSureAboutSendingMessage() {
(sureAboutMessagingDialogState as? SureAboutMessagingDialogState.Visible)?.let {
viewModelScope.launch {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import com.wire.android.util.dispatchers.DispatcherProvider
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.feature.conversation.ObserveConversationDetailsUseCase
import com.wire.kalium.logic.feature.conversation.SyncConversationCodeUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationAccessRoleUseCase
import com.wire.kalium.logic.feature.conversation.guestroomlink.CanCreatePasswordProtectedLinksUseCase
import com.wire.kalium.logic.feature.conversation.guestroomlink.GenerateGuestRoomLinkResult
Expand All @@ -49,6 +50,8 @@ import kotlinx.coroutines.flow.flowOn
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.flow.shareIn
import kotlinx.coroutines.launch
import kotlinx.coroutines.sync.Mutex
import kotlinx.coroutines.sync.withLock
import kotlinx.coroutines.withContext
import javax.inject.Inject

Expand All @@ -64,6 +67,7 @@ class EditGuestAccessViewModel @Inject constructor(
private val observeGuestRoomLink: ObserveGuestRoomLinkUseCase,
private val observeGuestRoomLinkFeatureFlag: ObserveGuestRoomLinkFeatureFlagUseCase,
private val canCreatePasswordProtectedLinks: CanCreatePasswordProtectedLinksUseCase,
private val syncConversationCode: SyncConversationCodeUseCase,
savedStateHandle: SavedStateHandle
) : ViewModel() {

Expand All @@ -86,6 +90,20 @@ class EditGuestAccessViewModel @Inject constructor(
checkIfUserCanCreatePasswordProtectedLinks()
}

private val syncCodeMutex = Mutex()

private var isGuestCodeUpdated = false
private fun updateConversationCodeOnce() {
viewModelScope.launch {
syncCodeMutex.withLock {
if (!isGuestCodeUpdated) {
syncConversationCode(conversationId)
isGuestCodeUpdated = true
}
}
}
}

private fun checkIfUserCanCreatePasswordProtectedLinks() {
viewModelScope.launch {
val canCreatePasswordProtectedLinks = when {
Expand Down Expand Up @@ -123,6 +141,8 @@ class EditGuestAccessViewModel @Inject constructor(
conversationDetailsFlow,
isSelfAdminFlow
) { conversationDetails, isSelfAnAdmin ->
isSelfAnAdmin to conversationDetails
}.collect { (isSelfAnAdmin, conversationDetails) ->

val isGuestAllowed =
conversationDetails.conversation.isGuestAllowed() || conversationDetails.conversation.isNonTeamMemberAllowed()
Expand All @@ -132,6 +152,8 @@ class EditGuestAccessViewModel @Inject constructor(
isServicesAccessAllowed = conversationDetails.conversation.isServicesAllowed(),
isUpdatingGuestAccessAllowed = isSelfAnAdmin
)

if (isGuestAllowed) updateConversationCodeOnce()
}
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ fun ConversationParticipantItem(
)
)
},
titleStartPadding = dimensions().spacing0x,
title = {
Row(verticalAlignment = Alignment.CenterVertically) {
HighlightName(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
package com.wire.android.ui.home.conversations.mention

import androidx.compose.foundation.layout.Row
import androidx.compose.foundation.layout.padding
import androidx.compose.runtime.Composable
import androidx.compose.ui.Alignment
import androidx.compose.ui.Modifier
Expand Down Expand Up @@ -47,6 +48,7 @@ fun MemberItemToMention(
leadingIcon = {
Row { UserProfileAvatar(avatarData) }
},
titleStartPadding = dimensions().spacing0x,
title = {
Row(verticalAlignment = Alignment.CenterVertically) {
HighlightName(
Expand All @@ -68,7 +70,7 @@ fun MemberItemToMention(
},
actions = { },
clickable = clickable,
modifier = modifier
modifier = modifier.padding(start = dimensions().spacing8x)
)
}

Expand Down
Loading

0 comments on commit 89ecea1

Please sign in to comment.