Skip to content

Commit

Permalink
fix: Fetch MLS status on every conversation opening [WPB-8610] (#2892)
Browse files Browse the repository at this point in the history
Co-authored-by: boris <[email protected]>
Co-authored-by: Mojtaba Chenani <[email protected]>
  • Loading branch information
3 people authored Apr 29, 2024
1 parent b0043db commit 1fcb41e
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/src/main/kotlin/com/wire/android/di/CoreLogicModule.kt
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
}
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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) {

Expand All @@ -64,6 +66,13 @@ class ConversationInfoViewModel @Inject constructor(

init {
getSelfUserId()
fetchMLSVerificationStatus()
}

private fun fetchMLSVerificationStatus() {
viewModelScope.launch {
fetchConversationMLSVerificationStatus(conversationId)
}
}

private fun getSelfUserId() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -59,6 +60,9 @@ class ConversationInfoViewModelArrangement {
@MockK
lateinit var observerSelfUser: GetSelfUserUseCase

@MockK
lateinit var fetchConversationMLSVerificationStatus: FetchConversationMLSVerificationStatusUseCase

@MockK
private lateinit var wireSessionImageLoader: WireSessionImageLoader

Expand All @@ -71,6 +75,7 @@ class ConversationInfoViewModelArrangement {
savedStateHandle,
observeConversationDetails,
observerSelfUser,
fetchConversationMLSVerificationStatus,
wireSessionImageLoader
)
}
Expand All @@ -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 {
Expand Down

0 comments on commit 1fcb41e

Please sign in to comment.