Skip to content
Merged
Show file tree
Hide file tree
Changes from all 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
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,8 @@ private fun ColumnScope.DeviceItemTexts(
.then(semantic)
)
if (shouldShowVerifyLabel) {
if (shouldShowE2EIInfo) {
MLSVerificationIcon(device.mlsClientIdentity?.e2eiStatus)
if (shouldShowE2EIInfo && device.mlsClientIdentity != null) {
MLSVerificationIcon(device.mlsClientIdentity.e2eiStatus)
}
if (device.isVerifiedProteus && !isCurrentClient) {
ProteusVerifiedIcon(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,27 +71,27 @@ class NewConversationViewModel @Inject constructor(
) : ViewModel() {

var newGroupNameTextState: TextFieldState = TextFieldState()
var newGroupState: GroupMetadataState by mutableStateOf(
GroupMetadataState().let {
val defaultProtocol = CreateConversationParam
.Protocol
.fromSupportedProtocolToConversationOptionsProtocol(getDefaultProtocol())
it.copy(groupProtocol = defaultProtocol)
}
)
var newGroupState: GroupMetadataState by mutableStateOf(GroupMetadataState())

var groupOptionsState: GroupOptionState by mutableStateOf(GroupOptionState())
var isChannelCreationPossible: Boolean by mutableStateOf(true)
var isFreemiumAccount: Boolean by mutableStateOf(false) // TODO: implement logic to determine if the account is freemium
var createGroupState: CreateGroupState by mutableStateOf(CreateGroupState.Default)

init {
initNewGroupState()
observeAllowanceOfAppsUsageInitialState()
setConversationCreationParam()
observeChannelCreationPermission()
getWireCellFeatureState()
}

private fun initNewGroupState() = viewModelScope.launch {
val defaultProtocol = CreateConversationParam
.Protocol.fromSupportedProtocolToConversationOptionsProtocol(getDefaultProtocol())
newGroupState = newGroupState.copy(groupProtocol = defaultProtocol)
}

private fun observeAllowanceOfAppsUsageInitialState() {
viewModelScope.launch {
observeIsAppsAllowedForUsage()
Expand All @@ -118,7 +118,7 @@ class NewConversationViewModel @Inject constructor(
appsAllowed
}

fun resetState() {
fun resetState() = viewModelScope.launch {
newGroupNameTextState.clearText()
newGroupState = GroupMetadataState().let {
val defaultProtocol = CreateConversationParam
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ fun DeviceDetailsContent(
}
}

if (state.isE2EIEnabled) {
if (state.isE2EIEnabled && state.isE2eiCertificateDataAvailable) {
item {
EndToEndIdentityCertificateItem(
isE2eiCertificateActivated = state.isE2eiCertificateActivated,
Expand Down Expand Up @@ -363,8 +363,8 @@ private fun DeviceDetailsTopBar(
maxLines = 2
)

if (shouldShowE2EIInfo) {
MLSVerificationIcon(device.mlsClientIdentity?.e2eiStatus)
if (shouldShowE2EIInfo && device.mlsClientIdentity != null) {
MLSVerificationIcon(device.mlsClientIdentity.e2eiStatus)
}

if (!isCurrentDevice && device.isVerifiedProteus) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,13 @@
private fun getE2eiCertificate() {
viewModelScope.launch {
state = when (val result = mlsClientIdentity(deviceId)) {
is GetMLSClientIdentityResult.Failure.E2EINotAvailable -> {
state.copy(
isE2eiCertificateActivated = false,
isLoadingCertificate = false,
isE2eiCertificateDataAvailable = false

Check warning on line 149 in app/src/main/kotlin/com/wire/android/ui/settings/devices/DeviceDetailsViewModel.kt

View check run for this annotation

Codecov / codecov/patch

app/src/main/kotlin/com/wire/android/ui/settings/devices/DeviceDetailsViewModel.kt#L146-L149

Added lines #L146 - L149 were not covered by tests
)
}
is GetMLSClientIdentityResult.Failure -> {
state.copy(isE2eiCertificateActivated = false, isLoadingCertificate = false)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,4 +40,5 @@ data class DeviceDetailsState(
val startGettingE2EICertificate: Boolean = false,
val mlsCipherSuiteSignature: String? = null,
val deviceRemoved: Boolean = false,
val isE2eiCertificateDataAvailable: Boolean = true,
)
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ internal class MessageComposerViewModelArrangement {
every { savedStateHandle.navArgs<ConversationNavArgs>() } returns ConversationNavArgs(conversationId = conversationId)

// Default empty values
every { isFileSharingEnabledUseCase() } returns FileSharingStatus(FileSharingStatus.Value.EnabledAll, null)
coEvery { isFileSharingEnabledUseCase() } returns FileSharingStatus(FileSharingStatus.Value.EnabledAll, null)
coEvery { observeOngoingCallsUseCase() } returns flowOf(listOf())
coEvery { observeEstablishedCallsUseCase() } returns flowOf(listOf())
coEvery { observeSyncState() } returns flowOf(SyncState.Live)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ class EditGuestAccessViewModelTest {
coEvery { observeGuestRoomLinkFeatureFlag() } returns flowOf()
coEvery { canCreatePasswordProtectedLinks() } returns true
coEvery { observeSelfUserUseCase() } returns flowOf(TestUser.SELF_USER)
every { getDefaultProtocolUseCase() } returns SupportedProtocol.PROTEUS
coEvery { getDefaultProtocolUseCase() } returns SupportedProtocol.PROTEUS
}

fun withSyncConversationCodeSuccess() = apply {
Expand Down Expand Up @@ -355,7 +355,7 @@ class EditGuestAccessViewModelTest {
}

fun withDefaultProtocol(protocol: SupportedProtocol) = apply {
every { getDefaultProtocolUseCase() } returns protocol
coEvery { getDefaultProtocolUseCase() } returns protocol
}

fun arrange() = this to editGuestAccessViewModel
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ import com.wire.android.config.CoroutineTestExtension
import com.wire.kalium.logic.configuration.FileSharingStatus
import com.wire.kalium.logic.feature.user.IsFileSharingEnabledUseCase
import io.mockk.MockKAnnotations
import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
import io.mockk.impl.annotations.MockK
import org.junit.jupiter.api.Assertions.assertFalse
import org.junit.jupiter.api.Assertions.assertTrue
Expand Down Expand Up @@ -80,7 +80,7 @@ class IsFileSharingEnabledViewModelTest {
}

fun withFileSharingStatus(result: FileSharingStatus.Value) = apply {
every { isFileSharingEnabledUseCase() } returns FileSharingStatus(
coEvery { isFileSharingEnabledUseCase() } returns FileSharingStatus(
result,
true
)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,6 @@ import com.wire.kalium.logic.feature.user.GetSelfUserUseCase
import com.wire.kalium.logic.feature.user.IsMLSEnabledUseCase
import io.mockk.MockKAnnotations
import io.mockk.coEvery
import io.mockk.every
import io.mockk.impl.annotations.MockK
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flowOf
Expand All @@ -61,7 +60,7 @@ internal class NewConversationViewModelArrangement {
coEvery { isMLSEnabledUseCase() } returns true
coEvery { createRegularGroup(any(), any(), any()) } returns ConversationCreationResult.Success(CONVERSATION)
coEvery { observeChannelsCreationPermissionUseCase() } returns flowOf(ChannelCreationPermission.Forbidden)
every { getDefaultProtocol() } returns SupportedProtocol.PROTEUS
coEvery { getDefaultProtocol() } returns SupportedProtocol.PROTEUS
coEvery { isWireCellsEnabled() } returns false
withAppsAllowedResult(false)
}
Expand Down Expand Up @@ -209,7 +208,7 @@ internal class NewConversationViewModelArrangement {
}

fun withDefaultProtocol(supportedProtocol: SupportedProtocol) = apply {
every { getDefaultProtocol() } returns supportedProtocol
coEvery { getDefaultProtocol() } returns supportedProtocol
}

fun withAppsAllowedResult(result: Boolean) = apply {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ import io.mockk.coEvery
import io.mockk.coVerify
import io.mockk.every
import io.mockk.impl.annotations.MockK
import io.mockk.verify
import kotlinx.coroutines.ExperimentalCoroutinesApi
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.MutableSharedFlow
Expand Down Expand Up @@ -98,7 +97,7 @@ class FeatureFlagNotificationViewModelTest {
viewModel.dismissGuestRoomLinkDialog()
advanceUntilIdle()

verify(exactly = 1) { arrangement.markGuestLinkFeatureFlagAsNotChanged() }
coVerify(exactly = 1) { arrangement.markGuestLinkFeatureFlagAsNotChanged() }
assertEquals(
false,
viewModel.featureFlagState.shouldShowGuestRoomLinkDialog
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -333,7 +333,7 @@ internal class DebugDataOptionsHiltArrangement {
)
)
)
every {
coEvery {
getDefaultProtocolUseCase()
} returns SupportedProtocol.PROTEUS

Expand Down Expand Up @@ -378,13 +378,13 @@ internal class DebugDataOptionsHiltArrangement {
}

fun withProteusProtocolSetup() = apply {
every {
coEvery {
getDefaultProtocolUseCase()
} returns SupportedProtocol.PROTEUS
}

fun withMlsProtocolSetup() = apply {
every {
coEvery {
getDefaultProtocolUseCase()
} returns SupportedProtocol.MLS
}
Expand Down
Loading