Skip to content

Commit

Permalink
Merge branch 'develop' into feat/unread-archived-conversations-indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
Garzas committed Sep 28, 2023
2 parents f3ef9e4 + 0e96dfb commit 838d202
Show file tree
Hide file tree
Showing 13 changed files with 96 additions and 118 deletions.
13 changes: 0 additions & 13 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,6 @@ import com.wire.kalium.logic.feature.connection.BlockUserUseCase
import com.wire.kalium.logic.feature.connection.UnblockUserUseCase
import com.wire.kalium.logic.feature.conversation.ObserveOtherUserSecurityClassificationLabelUseCase
import com.wire.kalium.logic.feature.conversation.ObserveSecurityClassificationLabelUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationMemberRoleUseCase
import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveSelfDeletionTimerSettingsForConversationUseCase
import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveTeamSettingsSelfDeletingStatusUseCase
import com.wire.kalium.logic.feature.selfDeletingMessages.PersistNewSelfDeletionTimerUseCase
Expand Down Expand Up @@ -286,13 +285,6 @@ class UseCaseModule {
): QualifiedIdMapper =
coreLogic.getSessionScope(currentAccount).qualifiedIdMapper

@ViewModelScoped
@Provides
fun provideUpdateConversationMemberRoleUseCase(
@KaliumCoreLogic coreLogic: CoreLogic,
@CurrentAccount currentAccount: UserId
): UpdateConversationMemberRoleUseCase = coreLogic.getSessionScope(currentAccount).conversations.updateConversationMemberRole

@ViewModelScoped
@Provides
fun provideBlockUserUseCase(
Expand Down Expand Up @@ -425,9 +417,4 @@ class UseCaseModule {
@KaliumCoreLogic coreLogic: CoreLogic,
@CurrentAccount currentAccount: UserId
): ObserveScreenshotCensoringConfigUseCase = coreLogic.getSessionScope(currentAccount).observeScreenshotCensoringConfig

@ViewModelScoped
@Provides
fun provideGetConversationVerificationStatusUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) =
coreLogic.getSessionScope(currentAccount).getConversationVerificationStatus
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import com.wire.kalium.logic.feature.conversation.RemoveMemberFromConversationUs
import com.wire.kalium.logic.feature.conversation.RenameConversationUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationAccessRoleUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationArchivedStatusUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationMemberRoleUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationMutedStatusUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationReadDateUseCase
import com.wire.kalium.logic.feature.conversation.UpdateConversationReceiptModeUseCase
Expand Down Expand Up @@ -224,6 +225,11 @@ class ConversationModule {
fun provideUpdateConversationArchivedStatusUseCase(conversationScope: ConversationScope): UpdateConversationArchivedStatusUseCase =
conversationScope.updateConversationArchivedStatus

@ViewModelScoped
@Provides
fun provideUpdateConversationMemberRoleUseCase(conversationScope: ConversationScope): UpdateConversationMemberRoleUseCase =
conversationScope.updateConversationMemberRole

@ViewModelScoped
@Provides
fun provideObserveArchivedUnreadConversationsCountUseCase(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,8 @@ class MigrationMapper @Inject constructor() {
messageTimer = null,
userMessageTimer = null,
archived = false,
archivedDateTime = null
archivedDateTime = null,
verificationStatus = Conversation.VerificationStatus.NOT_VERIFIED
)
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,11 +63,10 @@ import com.wire.android.ui.theme.wireDimensions
import com.wire.android.ui.theme.wireTypography
import com.wire.android.util.debug.LocalFeatureVisibilityFlags
import com.wire.android.util.ui.UIText
import com.wire.kalium.logic.data.conversation.ConversationVerificationStatus
import com.wire.kalium.logic.data.conversation.Conversation
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.user.UserAvailabilityStatus
import com.wire.kalium.logic.feature.conversation.ConversationProtocol

@Composable
fun ConversationScreenTopAppBar(
Expand Down Expand Up @@ -134,20 +133,7 @@ private fun ConversationScreenTopAppBarContent(
overflow = TextOverflow.Ellipsis,
modifier = Modifier.weight(weight = 1f, fill = false)
)
if (conversationInfoViewState.verificationStatus?.status == ConversationVerificationStatus.VERIFIED) {
val (iconId, contentDescriptionId) = when (conversationInfoViewState.verificationStatus.protocol) {
ConversationProtocol.MLS ->
R.drawable.ic_certificate_valid_mls to R.string.content_description_mls_certificate_valid

ConversationProtocol.PROTEUS ->
R.drawable.ic_certificate_valid_proteus to R.string.content_description_proteus_certificate_valid
}
Image(
modifier = Modifier.padding(start = dimensions().spacing4x),
painter = painterResource(id = iconId),
contentDescription = stringResource(contentDescriptionId)
)
}
VerificationIcon(conversationInfoViewState.protocolInfo, conversationInfoViewState.verificationStatus)
if (isDropDownEnabled && isInteractionEnabled) {
Icon(
painter = painterResource(id = R.drawable.ic_dropdown_icon),
Expand Down Expand Up @@ -194,6 +180,24 @@ private fun ConversationScreenTopAppBarContent(
)
}

@Composable
private fun VerificationIcon(protocolInfo: Conversation.ProtocolInfo?, verificationStatus: Conversation.VerificationStatus?) {
if (verificationStatus != Conversation.VerificationStatus.VERIFIED || protocolInfo == null) return

val (iconId, contentDescriptionId) = when (protocolInfo) {
is Conversation.ProtocolInfo.MLS ->
R.drawable.ic_certificate_valid_mls to R.string.content_description_mls_certificate_valid

Conversation.ProtocolInfo.Proteus ->
R.drawable.ic_certificate_valid_proteus to R.string.content_description_proteus_certificate_valid
}
Image(
modifier = Modifier.padding(start = dimensions().spacing4x),
painter = painterResource(id = iconId),
contentDescription = stringResource(contentDescriptionId)
)
}

@Composable
private fun Avatar(
conversationAvatar: ConversationAvatar,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,6 @@ import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.id.QualifiedIdMapper
import com.wire.kalium.logic.data.user.ConnectionState
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.conversation.ConversationVerificationStatusResult
import com.wire.kalium.logic.feature.conversation.GetConversationVerificationStatusUseCase
import com.wire.kalium.logic.feature.conversation.ObserveConversationDetailsUseCase
import com.wire.kalium.logic.feature.user.GetSelfUserUseCase
import dagger.hilt.android.lifecycle.HiltViewModel
Expand All @@ -57,7 +55,6 @@ class ConversationInfoViewModel @Inject constructor(
private val observeConversationDetails: ObserveConversationDetailsUseCase,
private val observerSelfUser: GetSelfUserUseCase,
private val wireSessionImageLoader: WireSessionImageLoader,
private val getConversationVerificationStatus: GetConversationVerificationStatusUseCase
) : SavedStateViewModel(savedStateHandle) {

private val conversationNavArgs: ConversationNavArgs = savedStateHandle.navArgs()
Expand All @@ -75,12 +72,6 @@ class ConversationInfoViewModel @Inject constructor(
viewModelScope.launch {
selfUserId = observerSelfUser().first().id
}
viewModelScope.launch {
val result = getConversationVerificationStatus(conversationId)
if (result is ConversationVerificationStatusResult.Success) {
conversationInfoViewState = conversationInfoViewState.copy(verificationStatus = result)
}
}
}

/*
Expand Down Expand Up @@ -125,7 +116,9 @@ class ConversationInfoViewModel @Inject constructor(
conversationAvatar = getConversationAvatar(conversationDetails),
conversationDetailsData = detailsData,
hasUserPermissionToEdit = detailsData !is ConversationDetailsData.None,
conversationType = conversationDetails.conversation.type
conversationType = conversationDetails.conversation.type,
protocolInfo = conversationDetails.conversation.protocol,
verificationStatus = conversationDetails.conversation.verificationStatus
)
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.user.ConnectionState
import com.wire.kalium.logic.data.user.UserAvailabilityStatus
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.conversation.ConversationVerificationStatusResult

data class ConversationInfoViewState(
val conversationId: QualifiedID,
Expand All @@ -36,7 +35,8 @@ data class ConversationInfoViewState(
val conversationAvatar: ConversationAvatar = ConversationAvatar.None,
val hasUserPermissionToEdit: Boolean = false,
val conversationType: Conversation.Type = Conversation.Type.ONE_ON_ONE,
val verificationStatus: ConversationVerificationStatusResult.Success? = null,
val protocolInfo: Conversation.ProtocolInfo? = null,
val verificationStatus: Conversation.VerificationStatus? = null,
)

sealed class ConversationDetailsData {
Expand Down
15 changes: 10 additions & 5 deletions app/src/test/kotlin/com/wire/android/framework/TestConversation.kt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ object TestConversation {
messageTimer = null,
userMessageTimer = null,
archived = false,
archivedDateTime = null
archivedDateTime = null,
verificationStatus = Conversation.VerificationStatus.NOT_VERIFIED
)
val SELF = Conversation(
ID.copy(value = "SELF ID"),
Expand All @@ -71,7 +72,8 @@ object TestConversation {
messageTimer = null,
userMessageTimer = null,
archived = false,
archivedDateTime = null
archivedDateTime = null,
verificationStatus = Conversation.VerificationStatus.NOT_VERIFIED
)

fun GROUP(protocolInfo: ProtocolInfo = ProtocolInfo.Proteus) = Conversation(
Expand All @@ -92,7 +94,8 @@ object TestConversation {
messageTimer = null,
userMessageTimer = null,
archived = false,
archivedDateTime = null
archivedDateTime = null,
verificationStatus = Conversation.VerificationStatus.NOT_VERIFIED
)

fun one_on_one(convId: ConversationId) = Conversation(
Expand All @@ -113,7 +116,8 @@ object TestConversation {
messageTimer = null,
userMessageTimer = null,
archived = false,
archivedDateTime = null
archivedDateTime = null,
verificationStatus = Conversation.VerificationStatus.NOT_VERIFIED
)

val USER_1 = UserId("member1", "domainMember")
Expand Down Expand Up @@ -141,6 +145,7 @@ object TestConversation {
messageTimer = null,
userMessageTimer = null,
archived = false,
archivedDateTime = null
archivedDateTime = null,
verificationStatus = Conversation.VerificationStatus.NOT_VERIFIED
)
}
Original file line number Diff line number Diff line change
Expand Up @@ -561,7 +561,8 @@ class GroupConversationDetailsViewModelTest {
messageTimer = null,
userMessageTimer = null,
archived = false,
archivedDateTime = null
archivedDateTime = null,
verificationStatus = Conversation.VerificationStatus.NOT_VERIFIED
),
legalHoldStatus = LegalHoldStatus.DISABLED,
hasOngoingCall = false,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,14 +28,10 @@ import com.wire.android.ui.navArgs
import com.wire.android.util.ui.WireSessionImageLoader
import com.wire.kalium.logic.StorageFailure
import com.wire.kalium.logic.data.conversation.ConversationDetails
import com.wire.kalium.logic.data.conversation.ConversationVerificationStatus
import com.wire.kalium.logic.data.id.ConversationId
import com.wire.kalium.logic.data.id.QualifiedID
import com.wire.kalium.logic.data.id.QualifiedIdMapper
import com.wire.kalium.logic.data.user.UserId
import com.wire.kalium.logic.feature.conversation.ConversationProtocol
import com.wire.kalium.logic.feature.conversation.ConversationVerificationStatusResult
import com.wire.kalium.logic.feature.conversation.GetConversationVerificationStatusUseCase
import com.wire.kalium.logic.feature.conversation.ObserveConversationDetailsUseCase
import com.wire.kalium.logic.feature.user.GetSelfUserUseCase
import io.mockk.MockKAnnotations
Expand Down Expand Up @@ -68,9 +64,6 @@ class ConversationInfoViewModelArrangement {
@MockK
private lateinit var wireSessionImageLoader: WireSessionImageLoader

@MockK
private lateinit var getConversationVerificationStatus: GetConversationVerificationStatusUseCase

@MockK(relaxed = true)
lateinit var onNotFound: () -> Unit

Expand All @@ -80,8 +73,7 @@ class ConversationInfoViewModelArrangement {
savedStateHandle,
observeConversationDetails,
observerSelfUser,
wireSessionImageLoader,
getConversationVerificationStatus
wireSessionImageLoader
)
}

Expand All @@ -96,10 +88,6 @@ class ConversationInfoViewModelArrangement {
coEvery { observeConversationDetails(any()) } returns conversationDetailsChannel.consumeAsFlow().map {
ObserveConversationDetailsUseCase.Result.Success(it)
}
coEvery { getConversationVerificationStatus(any()) } returns ConversationVerificationStatusResult.Success(
ConversationProtocol.PROTEUS,
ConversationVerificationStatus.NOT_VERIFIED
)
}

suspend fun withConversationDetailUpdate(conversationDetails: ConversationDetails) = apply {
Expand All @@ -121,9 +109,5 @@ class ConversationInfoViewModelArrangement {
every { qualifiedIdMapper.fromStringToQualifiedID(id.toString()) } returns id
}

suspend fun withVerificationStatus(result: ConversationVerificationStatusResult) = apply {
coEvery { getConversationVerificationStatus(any()) } returns result
}

fun arrange() = this to viewModel
}
Loading

0 comments on commit 838d202

Please sign in to comment.