From 1fcb41e89eb885f53ce23e9c4f10dbd7e35dcf42 Mon Sep 17 00:00:00 2001 From: AndroidBob Date: Mon, 29 Apr 2024 10:33:04 +0200 Subject: [PATCH] fix: Fetch MLS status on every conversation opening [WPB-8610] (#2892) Co-authored-by: boris Co-authored-by: Mojtaba Chenani --- .../main/kotlin/com/wire/android/di/CoreLogicModule.kt | 8 ++++++++ .../home/conversations/info/ConversationInfoViewModel.kt | 9 +++++++++ .../info/ConversationInfoViewModelArrangement.kt | 6 ++++++ 3 files changed, 23 insertions(+) diff --git a/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt b/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt index 35bcd7786c0..da4e9f5baf7 100644 --- a/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt +++ b/app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt @@ -35,6 +35,7 @@ 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.e2ei.usecase.FetchConversationMLSVerificationStatusUseCase import com.wire.kalium.logic.feature.featureConfig.ObserveIsAppLockEditableUseCase import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveSelfDeletionTimerSettingsForConversationUseCase import com.wire.kalium.logic.feature.selfDeletingMessages.ObserveTeamSettingsSelfDeletingStatusUseCase @@ -465,4 +466,11 @@ class UseCaseModule { @Provides fun provideMembersHavingLegalHoldClientUseCase(@KaliumCoreLogic coreLogic: CoreLogic, @CurrentAccount currentAccount: UserId) = coreLogic.getSessionScope(currentAccount).membersHavingLegalHoldClient + + @ViewModelScoped + @Provides + fun provideFetchConversationMLSVerificationStatusUseCase( + @KaliumCoreLogic coreLogic: CoreLogic, + @CurrentAccount currentAccount: UserId + ): FetchConversationMLSVerificationStatusUseCase = coreLogic.getSessionScope(currentAccount).fetchConversationMLSVerificationStatus } diff --git a/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModel.kt b/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModel.kt index f7ba4647941..a0d6c7cc135 100644 --- a/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModel.kt +++ b/app/src/main/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModel.kt @@ -39,6 +39,7 @@ 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.ObserveConversationDetailsUseCase +import com.wire.kalium.logic.feature.e2ei.usecase.FetchConversationMLSVerificationStatusUseCase import com.wire.kalium.logic.feature.user.GetSelfUserUseCase import dagger.hilt.android.lifecycle.HiltViewModel import kotlinx.coroutines.flow.first @@ -52,6 +53,7 @@ class ConversationInfoViewModel @Inject constructor( override val savedStateHandle: SavedStateHandle, private val observeConversationDetails: ObserveConversationDetailsUseCase, private val observerSelfUser: GetSelfUserUseCase, + private val fetchConversationMLSVerificationStatus: FetchConversationMLSVerificationStatusUseCase, private val wireSessionImageLoader: WireSessionImageLoader, ) : SavedStateViewModel(savedStateHandle) { @@ -64,6 +66,13 @@ class ConversationInfoViewModel @Inject constructor( init { getSelfUserId() + fetchMLSVerificationStatus() + } + + private fun fetchMLSVerificationStatus() { + viewModelScope.launch { + fetchConversationMLSVerificationStatus(conversationId) + } } private fun getSelfUserId() { diff --git a/app/src/test/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModelArrangement.kt b/app/src/test/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModelArrangement.kt index 5a17b46ecb8..397c3e3107b 100644 --- a/app/src/test/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModelArrangement.kt +++ b/app/src/test/kotlin/com/wire/android/ui/home/conversations/info/ConversationInfoViewModelArrangement.kt @@ -31,6 +31,7 @@ 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.ObserveConversationDetailsUseCase +import com.wire.kalium.logic.feature.e2ei.usecase.FetchConversationMLSVerificationStatusUseCase import com.wire.kalium.logic.feature.user.GetSelfUserUseCase import io.mockk.MockKAnnotations import io.mockk.coEvery @@ -59,6 +60,9 @@ class ConversationInfoViewModelArrangement { @MockK lateinit var observerSelfUser: GetSelfUserUseCase + @MockK + lateinit var fetchConversationMLSVerificationStatus: FetchConversationMLSVerificationStatusUseCase + @MockK private lateinit var wireSessionImageLoader: WireSessionImageLoader @@ -71,6 +75,7 @@ class ConversationInfoViewModelArrangement { savedStateHandle, observeConversationDetails, observerSelfUser, + fetchConversationMLSVerificationStatus, wireSessionImageLoader ) } @@ -86,6 +91,7 @@ class ConversationInfoViewModelArrangement { coEvery { observeConversationDetails(any()) } returns conversationDetailsChannel.consumeAsFlow().map { ObserveConversationDetailsUseCase.Result.Success(it) } + coEvery { fetchConversationMLSVerificationStatus.invoke(any()) } returns Unit } suspend fun withConversationDetailUpdate(conversationDetails: ConversationDetails) = apply {