Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: Fetch MLS status on every conversation opening [WPB-8610] #2884

Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading