Promote "history sharing on invite" out of developer options (#6647)
* Enable history sharing by default, unconditionally * Remove feature-flag dep from history viz icons in room header * Remove feature-flag dep from warning on inviting new people * Remove feature-flag dep from warning on starting chat with new people * Remove `enableKeyShareOnInvite` feature flag * Update screenshots * Remove redundant `FakeFeatureFlagService()` invocation, per review comment --------- Co-authored-by: ElementBot <android@element.io>
This commit is contained in:
parent
92ee479e91
commit
289dfff50a
63 changed files with 106 additions and 206 deletions
|
|
@ -13,7 +13,6 @@ import androidx.compose.foundation.text.input.rememberTextFieldState
|
|||
import androidx.compose.runtime.Composable
|
||||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.derivedStateOf
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
|
|
@ -37,8 +36,6 @@ import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
|||
import io.element.android.libraries.designsystem.theme.components.SearchBarResultState
|
||||
import io.element.android.libraries.di.SessionScope
|
||||
import io.element.android.libraries.di.annotations.SessionCoroutineScope
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.encryption.identity.IdentityState
|
||||
|
|
@ -74,7 +71,6 @@ class DefaultInvitePeoplePresenter(
|
|||
private val coroutineDispatchers: CoroutineDispatchers,
|
||||
@SessionCoroutineScope private val sessionCoroutineScope: CoroutineScope,
|
||||
private val appErrorStateService: AppErrorStateService,
|
||||
private val featureFlagService: FeatureFlagService,
|
||||
private val matrixClient: MatrixClient,
|
||||
) : InvitePeoplePresenter {
|
||||
@AssistedFactory
|
||||
|
|
@ -93,8 +89,6 @@ class DefaultInvitePeoplePresenter(
|
|||
val showSearchLoader = rememberSaveable { mutableStateOf(false) }
|
||||
val sendInvitesAction = remember { mutableStateOf<AsyncAction<Unit>>(AsyncAction.Uninitialized) }
|
||||
|
||||
val enableKeyShareOnInvite by featureFlagService.isFeatureEnabledFlow(FeatureFlags.EnableKeyShareOnInvite).collectAsState(initial = false)
|
||||
|
||||
val recentDirectRooms by produceState(emptyList(), roomMembers.value) {
|
||||
if (roomMembers.value.isSuccess()) {
|
||||
val activeMemberIds = roomMembers.value.dataOrNull().orEmpty()
|
||||
|
|
@ -137,12 +131,7 @@ class DefaultInvitePeoplePresenter(
|
|||
val selectedUserIdentities = produceState(
|
||||
emptyMap<MatrixUser, IdentityState?>().toImmutableMap(),
|
||||
selectedUsers.value,
|
||||
enableKeyShareOnInvite,
|
||||
) {
|
||||
if (!enableKeyShareOnInvite) {
|
||||
return@produceState
|
||||
}
|
||||
|
||||
val selected = selectedUsers.value
|
||||
|
||||
val cached = value
|
||||
|
|
@ -213,7 +202,7 @@ class DefaultInvitePeoplePresenter(
|
|||
}
|
||||
}
|
||||
is InvitePeopleEvents.SendInvites -> {
|
||||
if (enableKeyShareOnInvite && unknownUsers.isNotEmpty() && sendInvitesAction.value !is ConfirmingUnknownUserInvitation) {
|
||||
if (unknownUsers.isNotEmpty() && sendInvitesAction.value !is ConfirmingUnknownUserInvitation) {
|
||||
sendInvitesAction.value = ConfirmingUnknownUserInvitation(
|
||||
unknownUsers
|
||||
)
|
||||
|
|
|
|||
|
|
@ -15,9 +15,6 @@ import io.element.android.features.invitepeople.api.InvitePeopleEvents
|
|||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
||||
import io.element.android.libraries.designsystem.theme.components.SearchBarResultState
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||
import io.element.android.libraries.featureflag.test.FakeFeatureFlagService
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
|
|
@ -405,10 +402,14 @@ internal class DefaultInvitePeoplePresenterTest {
|
|||
val inviteUserResult = lambdaRecorder<UserId, Result<Unit>> { userId: UserId ->
|
||||
Result.success(Unit)
|
||||
}
|
||||
val encryptionService = FakeEncryptionService(
|
||||
getUserIdentityResult = { _ -> Result.success(null) },
|
||||
)
|
||||
val presenter = createDefaultInvitePeoplePresenter(
|
||||
userRepository = repository,
|
||||
inviteUserResult = inviteUserResult,
|
||||
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true)
|
||||
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true),
|
||||
matrixClient = FakeMatrixClient(encryptionService = encryptionService),
|
||||
)
|
||||
presenter.test {
|
||||
val initialState = awaitItem()
|
||||
|
|
@ -451,13 +452,18 @@ internal class DefaultInvitePeoplePresenterTest {
|
|||
Result.failure(AN_EXCEPTION)
|
||||
}
|
||||
val showErrorResResult = lambdaRecorder<Int, Int, Unit> { _, _ -> }
|
||||
|
||||
val encryptionService = FakeEncryptionService(
|
||||
getUserIdentityResult = { _ -> Result.success(null) },
|
||||
)
|
||||
val presenter = createDefaultInvitePeoplePresenter(
|
||||
userRepository = repository,
|
||||
inviteUserResult = inviteUserResult,
|
||||
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true),
|
||||
appErrorStateService = FakeAppErrorStateService(
|
||||
showErrorResResult = showErrorResResult,
|
||||
)
|
||||
),
|
||||
matrixClient = FakeMatrixClient(encryptionService = encryptionService),
|
||||
)
|
||||
presenter.test {
|
||||
val initialState = awaitItem()
|
||||
|
|
@ -632,15 +638,11 @@ internal class DefaultInvitePeoplePresenterTest {
|
|||
val encryptionService = FakeEncryptionService(
|
||||
getUserIdentityResult = getUserIdentityResult
|
||||
)
|
||||
val featureFlagService = FakeFeatureFlagService().apply {
|
||||
setFeatureEnabled(FeatureFlags.EnableKeyShareOnInvite, true)
|
||||
}
|
||||
|
||||
val presenter = createDefaultInvitePeoplePresenter(
|
||||
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true),
|
||||
inviteUserResult = inviteUserResult,
|
||||
matrixClient = FakeMatrixClient(encryptionService = encryptionService),
|
||||
featureFlagService = featureFlagService
|
||||
)
|
||||
presenter.test {
|
||||
val initialState = awaitItem()
|
||||
|
|
@ -703,15 +705,11 @@ internal class DefaultInvitePeoplePresenterTest {
|
|||
val encryptionService = FakeEncryptionService(
|
||||
getUserIdentityResult = getUserIdentityResult
|
||||
)
|
||||
val featureFlagService = FakeFeatureFlagService().apply {
|
||||
setFeatureEnabled(FeatureFlags.EnableKeyShareOnInvite, true)
|
||||
}
|
||||
|
||||
val presenter = createDefaultInvitePeoplePresenter(
|
||||
userRepository = repository,
|
||||
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true),
|
||||
matrixClient = FakeMatrixClient(encryptionService = encryptionService),
|
||||
featureFlagService = featureFlagService
|
||||
)
|
||||
presenter.test {
|
||||
val initialState = awaitItemAsDefault()
|
||||
|
|
@ -790,14 +788,10 @@ internal class DefaultInvitePeoplePresenterTest {
|
|||
val encryptionService = FakeEncryptionService(
|
||||
getUserIdentityResult = getUserIdentityResult
|
||||
)
|
||||
val featureFlagService = FakeFeatureFlagService().apply {
|
||||
setFeatureEnabled(FeatureFlags.EnableKeyShareOnInvite, true)
|
||||
}
|
||||
|
||||
val presenter = createDefaultInvitePeoplePresenter(
|
||||
coroutineDispatchers = testCoroutineDispatchers(useUnconfinedTestDispatcher = true),
|
||||
matrixClient = FakeMatrixClient(encryptionService = encryptionService),
|
||||
featureFlagService = featureFlagService
|
||||
)
|
||||
presenter.test {
|
||||
val initialState = awaitItem()
|
||||
|
|
@ -878,7 +872,6 @@ fun TestScope.createDefaultInvitePeoplePresenter(
|
|||
userRepository: UserRepository = FakeUserRepository(),
|
||||
coroutineDispatchers: CoroutineDispatchers = testCoroutineDispatchers(),
|
||||
appErrorStateService: AppErrorStateService = FakeAppErrorStateService(),
|
||||
featureFlagService: FeatureFlagService = FakeFeatureFlagService(),
|
||||
matrixClient: MatrixClient = FakeMatrixClient(),
|
||||
): DefaultInvitePeoplePresenter {
|
||||
return DefaultInvitePeoplePresenter(
|
||||
|
|
@ -888,7 +881,6 @@ fun TestScope.createDefaultInvitePeoplePresenter(
|
|||
coroutineDispatchers = coroutineDispatchers,
|
||||
sessionCoroutineScope = backgroundScope,
|
||||
appErrorStateService = appErrorStateService,
|
||||
featureFlagService = featureFlagService,
|
||||
matrixClient = matrixClient,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -217,12 +217,10 @@ class MessagesPresenter(
|
|||
val dmRoomMember by room.getDirectRoomMember(membersState)
|
||||
val roomMemberIdentityStateChanges = identityChangeState.roomMemberIdentityStateChanges
|
||||
|
||||
val isKeyShareOnInviteEnabled by featureFlagService.isFeatureEnabledFlow(FeatureFlags.EnableKeyShareOnInvite).collectAsState(initial = false)
|
||||
// The top bar should show a "history" icon if:
|
||||
// * History sharing is enabled,
|
||||
// * The room is encrypted, and:
|
||||
// * The room's history_visibility allows future users to see content.
|
||||
val topBarSharedHistoryIcon = if (isKeyShareOnInviteEnabled) roomInfo.sharedHistoryIcon() else SharedHistoryIcon.NONE
|
||||
val topBarSharedHistoryIcon = roomInfo.sharedHistoryIcon()
|
||||
|
||||
LifecycleResumeEffect(dmRoomMember, roomInfo.isEncrypted) {
|
||||
if (roomInfo.isEncrypted == true) {
|
||||
|
|
|
|||
|
|
@ -1228,9 +1228,6 @@ class MessagesPresenterTest {
|
|||
initialRoomInfo = aRoomInfo(isEncrypted = true, historyVisibility = RoomHistoryVisibility.Shared),
|
||||
),
|
||||
),
|
||||
featureFlagService = FakeFeatureFlagService(
|
||||
initialState = mapOf(FeatureFlags.EnableKeyShareOnInvite.key to true)
|
||||
)
|
||||
)
|
||||
presenter.testWithLifecycleOwner {
|
||||
awaitItem()
|
||||
|
|
@ -1249,9 +1246,6 @@ class MessagesPresenterTest {
|
|||
initialRoomInfo = aRoomInfo(isEncrypted = true, historyVisibility = RoomHistoryVisibility.WorldReadable),
|
||||
),
|
||||
),
|
||||
featureFlagService = FakeFeatureFlagService(
|
||||
initialState = mapOf(FeatureFlags.EnableKeyShareOnInvite.key to true)
|
||||
)
|
||||
)
|
||||
presenter.testWithLifecycleOwner {
|
||||
awaitItem()
|
||||
|
|
|
|||
|
|
@ -168,8 +168,6 @@ class RoomDetailsPresenter(
|
|||
|
||||
val canReportRoom by produceState(false) { value = client.canReportRoom() }
|
||||
|
||||
val enableKeyShareOnInvite by featureFlagService.isFeatureEnabledFlow(FeatureFlags.EnableKeyShareOnInvite).collectAsState(initial = false)
|
||||
|
||||
return RoomDetailsState(
|
||||
roomId = room.roomId,
|
||||
roomName = roomName,
|
||||
|
|
@ -199,7 +197,6 @@ class RoomDetailsPresenter(
|
|||
isTombstoned = roomInfo.successorRoom != null,
|
||||
showDebugInfo = isDeveloperModeEnabled,
|
||||
roomVersion = roomInfo.roomVersion,
|
||||
enableKeyShareOnInvite = enableKeyShareOnInvite,
|
||||
roomHistoryVisibility = roomInfo.historyVisibility,
|
||||
eventSink = ::handleEvent,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -51,7 +51,6 @@ data class RoomDetailsState(
|
|||
val isTombstoned: Boolean,
|
||||
val showDebugInfo: Boolean,
|
||||
val roomVersion: String?,
|
||||
val enableKeyShareOnInvite: Boolean,
|
||||
val roomHistoryVisibility: RoomHistoryVisibility,
|
||||
val eventSink: (RoomDetailsEvent) -> Unit
|
||||
) {
|
||||
|
|
@ -64,7 +63,7 @@ data class RoomDetailsState(
|
|||
if (isPublic) {
|
||||
add(RoomBadge.PUBLIC)
|
||||
}
|
||||
if (enableKeyShareOnInvite && isEncrypted) {
|
||||
if (isEncrypted) {
|
||||
when (roomHistoryVisibility) {
|
||||
RoomHistoryVisibility.Invited, RoomHistoryVisibility.Joined -> add(RoomBadge.SHARED_HISTORY_HIDDEN)
|
||||
RoomHistoryVisibility.Shared -> add(RoomBadge.SHARED_HISTORY_SHARED)
|
||||
|
|
|
|||
|
|
@ -121,7 +121,6 @@ fun aRoomDetailsState(
|
|||
canReportRoom: Boolean = true,
|
||||
isTombstoned: Boolean = false,
|
||||
showDebugInfo: Boolean = false,
|
||||
enableKeyShareOnInvite: Boolean = false,
|
||||
roomHistoryVisibility: RoomHistoryVisibility = RoomHistoryVisibility.Shared,
|
||||
eventSink: (RoomDetailsEvent) -> Unit = {},
|
||||
) = RoomDetailsState(
|
||||
|
|
@ -153,7 +152,6 @@ fun aRoomDetailsState(
|
|||
isTombstoned = isTombstoned,
|
||||
showDebugInfo = showDebugInfo,
|
||||
roomVersion = "12",
|
||||
enableKeyShareOnInvite = enableKeyShareOnInvite,
|
||||
roomHistoryVisibility = roomHistoryVisibility,
|
||||
eventSink = eventSink,
|
||||
)
|
||||
|
|
@ -195,6 +193,5 @@ fun aSharedHistoryRoomDetailsState(
|
|||
roomHistoryVisibility: RoomHistoryVisibility
|
||||
) = aRoomDetailsState(
|
||||
isEncrypted = true,
|
||||
enableKeyShareOnInvite = true,
|
||||
roomHistoryVisibility = roomHistoryVisibility,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -37,24 +37,24 @@ class RoomDetailsStateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `room public encrypted should have encrypted and public badges`() {
|
||||
fun `room public encrypted should have encrypted, public, and history sharing shared badges`() {
|
||||
val sut = aRoomDetailsState(
|
||||
isPublic = true,
|
||||
isEncrypted = true,
|
||||
)
|
||||
assertThat(sut.roomBadges).isEqualTo(
|
||||
persistentListOf(RoomBadge.ENCRYPTED, RoomBadge.PUBLIC)
|
||||
persistentListOf(RoomBadge.ENCRYPTED, RoomBadge.PUBLIC, RoomBadge.SHARED_HISTORY_SHARED)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `room not public encrypted should have encrypted badges`() {
|
||||
fun `room not public encrypted should have encrypted and history sharing shared badges`() {
|
||||
val sut = aRoomDetailsState(
|
||||
isPublic = false,
|
||||
isEncrypted = true,
|
||||
)
|
||||
assertThat(sut.roomBadges).isEqualTo(
|
||||
persistentListOf(RoomBadge.ENCRYPTED)
|
||||
persistentListOf(RoomBadge.ENCRYPTED, RoomBadge.SHARED_HISTORY_SHARED)
|
||||
)
|
||||
}
|
||||
|
||||
|
|
@ -62,7 +62,6 @@ class RoomDetailsStateTest {
|
|||
fun `room public not encrypted should not have history sharing badges`() {
|
||||
val sut = aRoomDetailsState(
|
||||
isEncrypted = false,
|
||||
enableKeyShareOnInvite = true,
|
||||
roomHistoryVisibility = RoomHistoryVisibility.Shared
|
||||
)
|
||||
assertThat(sut.roomBadges).isEqualTo(
|
||||
|
|
@ -74,7 +73,6 @@ class RoomDetailsStateTest {
|
|||
fun `room public encrypted should have history sharing hidden badge`() {
|
||||
val sut = aRoomDetailsState(
|
||||
isEncrypted = true,
|
||||
enableKeyShareOnInvite = true,
|
||||
roomHistoryVisibility = RoomHistoryVisibility.Joined
|
||||
)
|
||||
assertThat(sut.roomBadges).isEqualTo(
|
||||
|
|
@ -83,22 +81,9 @@ class RoomDetailsStateTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `room public encrypted should have history sharing shared badge`() {
|
||||
fun `room public encrypted with world_readable visibility should have history sharing world_readable badge`() {
|
||||
val sut = aRoomDetailsState(
|
||||
isEncrypted = true,
|
||||
enableKeyShareOnInvite = true,
|
||||
roomHistoryVisibility = RoomHistoryVisibility.Shared
|
||||
)
|
||||
assertThat(sut.roomBadges).isEqualTo(
|
||||
persistentListOf(RoomBadge.ENCRYPTED, RoomBadge.PUBLIC, RoomBadge.SHARED_HISTORY_SHARED)
|
||||
)
|
||||
}
|
||||
|
||||
@Test
|
||||
fun `room public encrypted should have history sharing world_readable badge`() {
|
||||
val sut = aRoomDetailsState(
|
||||
isEncrypted = true,
|
||||
enableKeyShareOnInvite = true,
|
||||
roomHistoryVisibility = RoomHistoryVisibility.WorldReadable
|
||||
)
|
||||
assertThat(sut.roomBadges).isEqualTo(
|
||||
|
|
|
|||
|
|
@ -15,8 +15,6 @@ import io.element.android.features.startchat.api.ConfirmingStartDmWithMatrixUser
|
|||
import io.element.android.features.startchat.api.StartDMAction
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.di.SessionScope
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.room.StartDMResult
|
||||
|
|
@ -28,7 +26,6 @@ import io.element.android.services.analytics.api.AnalyticsService
|
|||
class DefaultStartDMAction(
|
||||
private val matrixClient: MatrixClient,
|
||||
private val analyticsService: AnalyticsService,
|
||||
private val featureFlagService: FeatureFlagService,
|
||||
) : StartDMAction {
|
||||
override suspend fun execute(
|
||||
matrixUser: MatrixUser,
|
||||
|
|
@ -50,7 +47,7 @@ class DefaultStartDMAction(
|
|||
val identityState = matrixClient.encryptionService.getUserIdentity(matrixUser.userId, fallbackToServer = false).getOrNull()
|
||||
actionState.value = ConfirmingStartDmWithMatrixUser(
|
||||
matrixUser = matrixUser,
|
||||
isUserIdentityUnknown = featureFlagService.isFeatureEnabled(FeatureFlags.EnableKeyShareOnInvite) && identityState == null
|
||||
isUserIdentityUnknown = identityState == null
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,8 +58,6 @@ class StartChatPresenter(
|
|||
featureFlagService.isFeatureEnabledFlow(FeatureFlags.RoomDirectorySearch)
|
||||
}.collectAsState(initial = false)
|
||||
|
||||
val enableKeyShareOnInvite = featureFlagService.isFeatureEnabledFlow(FeatureFlags.EnableKeyShareOnInvite).collectAsState(false)
|
||||
|
||||
fun handleEvent(event: StartChatEvents) {
|
||||
when (event) {
|
||||
is StartChatEvents.StartDM -> localCoroutineScope.launch {
|
||||
|
|
@ -78,7 +76,6 @@ class StartChatPresenter(
|
|||
userListState = userListState,
|
||||
startDmAction = startDmActionState.value,
|
||||
isRoomDirectorySearchEnabled = isRoomDirectorySearchEnabled,
|
||||
enableKeyShareOnInvite = enableKeyShareOnInvite.value,
|
||||
eventSink = ::handleEvent,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -17,6 +17,5 @@ data class StartChatState(
|
|||
val userListState: UserListState,
|
||||
val startDmAction: AsyncAction<RoomId>,
|
||||
val isRoomDirectorySearchEnabled: Boolean,
|
||||
val enableKeyShareOnInvite: Boolean,
|
||||
val eventSink: (StartChatEvents) -> Unit,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -82,6 +82,5 @@ fun aCreateRoomRootState(
|
|||
userListState = userListState,
|
||||
startDmAction = startDmAction,
|
||||
isRoomDirectorySearchEnabled = isRoomDirectorySearchEnabled,
|
||||
enableKeyShareOnInvite = false,
|
||||
eventSink = eventSink,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -130,7 +130,6 @@ fun StartChatView(
|
|||
if (data is ConfirmingStartDmWithMatrixUser) {
|
||||
CreateDmConfirmationBottomSheet(
|
||||
matrixUser = data.matrixUser,
|
||||
enableKeyShareOnInvite = state.enableKeyShareOnInvite,
|
||||
isUserIdentityUnknown = data.isUserIdentityUnknown,
|
||||
onSendInvite = {
|
||||
state.eventSink(StartChatEvents.StartDM(data.matrixUser))
|
||||
|
|
|
|||
|
|
@ -13,9 +13,6 @@ import com.google.common.truth.Truth.assertThat
|
|||
import im.vector.app.features.analytics.plan.CreatedRoom
|
||||
import io.element.android.features.startchat.api.ConfirmingStartDmWithMatrixUser
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||
import io.element.android.libraries.featureflag.test.FakeFeatureFlagService
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
|
|
@ -88,7 +85,7 @@ class DefaultStartDMActionTest {
|
|||
val state = mutableStateOf<AsyncAction<RoomId>>(AsyncAction.Uninitialized)
|
||||
val matrixUser = aMatrixUser()
|
||||
action.execute(matrixUser, false, state)
|
||||
assertThat(state.value).isEqualTo(ConfirmingStartDmWithMatrixUser(matrixUser, isUserIdentityUnknown = false))
|
||||
assertThat(state.value).isEqualTo(ConfirmingStartDmWithMatrixUser(matrixUser, isUserIdentityUnknown = true))
|
||||
assertThat(analyticsService.capturedEvents).isEmpty()
|
||||
}
|
||||
|
||||
|
|
@ -107,37 +104,31 @@ class DefaultStartDMActionTest {
|
|||
}
|
||||
|
||||
@Test
|
||||
fun `when history sharing enabled, user identity fetched and identity unknown`() = runTest {
|
||||
fun `when user identity fetched and identity unknown`() = runTest {
|
||||
val getUserIdentityResult = lambdaRecorder<UserId, Result<IdentityState?>> { _ -> Result.success(null) }
|
||||
val encryptionService = FakeEncryptionService(getUserIdentityResult = getUserIdentityResult)
|
||||
val matrixClient = FakeMatrixClient(encryptionService = encryptionService).apply {
|
||||
givenFindDmResult(Result.success(null))
|
||||
}
|
||||
val featureFlagService = FakeFeatureFlagService().apply {
|
||||
setFeatureEnabled(FeatureFlags.EnableKeyShareOnInvite, true)
|
||||
}
|
||||
|
||||
val action = createStartDMAction(
|
||||
matrixClient = matrixClient,
|
||||
featureFlagService = featureFlagService
|
||||
)
|
||||
val state = mutableStateOf<AsyncAction<RoomId>>(AsyncAction.Uninitialized)
|
||||
|
||||
action.execute(aMatrixUser(), false, state)
|
||||
|
||||
assertThat(getUserIdentityResult.assertions().isCalledOnce())
|
||||
getUserIdentityResult.assertions().isCalledOnce()
|
||||
assertThat(state.value).isEqualTo(ConfirmingStartDmWithMatrixUser(aMatrixUser(), isUserIdentityUnknown = true))
|
||||
}
|
||||
|
||||
private fun createStartDMAction(
|
||||
matrixClient: MatrixClient = FakeMatrixClient(),
|
||||
analyticsService: AnalyticsService = FakeAnalyticsService(),
|
||||
featureFlagService: FeatureFlagService = FakeFeatureFlagService()
|
||||
): DefaultStartDMAction {
|
||||
return DefaultStartDMAction(
|
||||
matrixClient = matrixClient,
|
||||
analyticsService = analyticsService,
|
||||
featureFlagService = featureFlagService,
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -26,7 +26,6 @@ data class UserProfileState(
|
|||
val dmRoomId: RoomId?,
|
||||
val canCall: Boolean,
|
||||
val snackbarMessage: SnackbarMessage?,
|
||||
val enableKeyShareOnInvite: Boolean,
|
||||
val eventSink: (UserProfileEvents) -> Unit
|
||||
) {
|
||||
enum class ConfirmationDialog {
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ import androidx.compose.runtime.Composable
|
|||
import androidx.compose.runtime.LaunchedEffect
|
||||
import androidx.compose.runtime.MutableState
|
||||
import androidx.compose.runtime.State
|
||||
import androidx.compose.runtime.collectAsState
|
||||
import androidx.compose.runtime.getValue
|
||||
import androidx.compose.runtime.mutableStateOf
|
||||
import androidx.compose.runtime.produceState
|
||||
|
|
@ -32,8 +31,6 @@ import io.element.android.libraries.architecture.AsyncAction
|
|||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.architecture.Presenter
|
||||
import io.element.android.libraries.core.bool.orFalse
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
|
|
@ -53,7 +50,6 @@ class UserProfilePresenter(
|
|||
private val client: MatrixClient,
|
||||
private val startDMAction: StartDMAction,
|
||||
private val sessionEnterpriseService: SessionEnterpriseService,
|
||||
private val featureFlagService: FeatureFlagService,
|
||||
) : Presenter<UserProfileState> {
|
||||
@AssistedFactory
|
||||
interface Factory {
|
||||
|
|
@ -105,8 +101,6 @@ class UserProfilePresenter(
|
|||
}
|
||||
val userProfile by produceState<MatrixUser?>(null) { value = client.getProfile(userId).getOrNull() }
|
||||
|
||||
val enableKeyShareOnInvite = featureFlagService.isFeatureEnabledFlow(FeatureFlags.EnableKeyShareOnInvite).collectAsState(false)
|
||||
|
||||
fun handleEvent(event: UserProfileEvents) {
|
||||
when (event) {
|
||||
is UserProfileEvents.BlockUser -> {
|
||||
|
|
@ -159,7 +153,6 @@ class UserProfilePresenter(
|
|||
dmRoomId = dmRoomId,
|
||||
canCall = canCall,
|
||||
snackbarMessage = null,
|
||||
enableKeyShareOnInvite = enableKeyShareOnInvite.value,
|
||||
eventSink = ::handleEvent,
|
||||
)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -24,7 +24,6 @@ import io.element.android.features.userprofile.api.UserProfileVerificationState
|
|||
import io.element.android.features.userprofile.impl.root.UserProfilePresenter
|
||||
import io.element.android.libraries.architecture.AsyncAction
|
||||
import io.element.android.libraries.architecture.AsyncData
|
||||
import io.element.android.libraries.featureflag.test.FakeFeatureFlagService
|
||||
import io.element.android.libraries.matrix.api.MatrixClient
|
||||
import io.element.android.libraries.matrix.api.core.RoomId
|
||||
import io.element.android.libraries.matrix.api.core.UserId
|
||||
|
|
@ -415,7 +414,6 @@ class UserProfilePresenterTest {
|
|||
sessionEnterpriseService = FakeSessionEnterpriseService(
|
||||
isElementCallAvailableResult = { isElementCallAvailable },
|
||||
),
|
||||
featureFlagService = FakeFeatureFlagService()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -61,6 +61,5 @@ fun aUserProfileState(
|
|||
dmRoomId = dmRoomId,
|
||||
canCall = canCall,
|
||||
snackbarMessage = snackbarMessage,
|
||||
enableKeyShareOnInvite = false,
|
||||
eventSink = eventSink,
|
||||
)
|
||||
|
|
|
|||
|
|
@ -114,7 +114,6 @@ fun UserProfileView(
|
|||
if (data is ConfirmingStartDmWithMatrixUser) {
|
||||
CreateDmConfirmationBottomSheet(
|
||||
matrixUser = data.matrixUser,
|
||||
enableKeyShareOnInvite = state.enableKeyShareOnInvite,
|
||||
isUserIdentityUnknown = data.isUserIdentityUnknown,
|
||||
onSendInvite = {
|
||||
state.eventSink(UserProfileEvents.StartDM)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue