Skip to content

Commit

Permalink
fix: Fetch MLS status on every conversation opening [WPB-8610] (#2884)
Browse files Browse the repository at this point in the history
Co-authored-by: Mojtaba Chenani <[email protected]>
  • Loading branch information
borichellow and mchenani authored Apr 15, 2024
1 parent fb657e9 commit 2d5066d
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 1 deletion.
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 @@ -445,4 +446,11 @@ class UseCaseModule {
fun provideObserveIsAppLockEditableUseCase(
@KaliumCoreLogic coreLogic: CoreLogic
): ObserveIsAppLockEditableUseCase = coreLogic.getGlobalScope().observeIsAppLockEditableUseCase

@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 2d5066d

Please sign in to comment.