Remove FeatureFlag.SyncOnPush
This commit is contained in:
parent
ebecc6652b
commit
45150de5b3
3 changed files with 4 additions and 39 deletions
|
|
@ -34,13 +34,6 @@ enum class FeatureFlags(
|
||||||
defaultValue = { false },
|
defaultValue = { false },
|
||||||
isFinished = false,
|
isFinished = false,
|
||||||
),
|
),
|
||||||
SyncOnPush(
|
|
||||||
key = "feature.syncOnPush",
|
|
||||||
title = "Sync on push",
|
|
||||||
description = "Subscribe to room sync when a push is received",
|
|
||||||
defaultValue = { true },
|
|
||||||
isFinished = false,
|
|
||||||
),
|
|
||||||
OnlySignedDeviceIsolationMode(
|
OnlySignedDeviceIsolationMode(
|
||||||
key = "feature.onlySignedDeviceIsolationMode",
|
key = "feature.onlySignedDeviceIsolationMode",
|
||||||
title = "Exclude insecure devices when sending/receiving messages",
|
title = "Exclude insecure devices when sending/receiving messages",
|
||||||
|
|
|
||||||
|
|
@ -8,8 +8,6 @@
|
||||||
package io.element.android.libraries.push.impl.push
|
package io.element.android.libraries.push.impl.push
|
||||||
|
|
||||||
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
import io.element.android.libraries.core.coroutine.CoroutineDispatchers
|
||||||
import io.element.android.libraries.featureflag.api.FeatureFlagService
|
|
||||||
import io.element.android.libraries.featureflag.api.FeatureFlags
|
|
||||||
import io.element.android.libraries.matrix.api.MatrixClientProvider
|
import io.element.android.libraries.matrix.api.MatrixClientProvider
|
||||||
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
import io.element.android.libraries.push.impl.notifications.model.NotifiableEvent
|
||||||
import io.element.android.services.appnavstate.api.AppForegroundStateService
|
import io.element.android.services.appnavstate.api.AppForegroundStateService
|
||||||
|
|
@ -21,15 +19,10 @@ import kotlin.time.Duration.Companion.seconds
|
||||||
|
|
||||||
class SyncOnNotifiableEvent @Inject constructor(
|
class SyncOnNotifiableEvent @Inject constructor(
|
||||||
private val matrixClientProvider: MatrixClientProvider,
|
private val matrixClientProvider: MatrixClientProvider,
|
||||||
private val featureFlagService: FeatureFlagService,
|
|
||||||
private val appForegroundStateService: AppForegroundStateService,
|
private val appForegroundStateService: AppForegroundStateService,
|
||||||
private val dispatchers: CoroutineDispatchers,
|
private val dispatchers: CoroutineDispatchers,
|
||||||
) {
|
) {
|
||||||
suspend operator fun invoke(notifiableEvents: List<NotifiableEvent>) = withContext(dispatchers.io) {
|
suspend operator fun invoke(notifiableEvents: List<NotifiableEvent>) = withContext(dispatchers.io) {
|
||||||
if (!featureFlagService.isFeatureEnabled(FeatureFlags.SyncOnPush)) {
|
|
||||||
return@withContext
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
val eventsBySession = notifiableEvents.groupBy { it.sessionId }
|
val eventsBySession = notifiableEvents.groupBy { it.sessionId }
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -9,8 +9,6 @@ package io.element.android.libraries.push.impl.push
|
||||||
|
|
||||||
import app.cash.turbine.test
|
import app.cash.turbine.test
|
||||||
import com.google.common.truth.Truth.assertThat
|
import com.google.common.truth.Truth.assertThat
|
||||||
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.MatrixClient
|
||||||
import io.element.android.libraries.matrix.api.sync.SyncState
|
import io.element.android.libraries.matrix.api.sync.SyncState
|
||||||
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
import io.element.android.libraries.matrix.test.A_ROOM_ID
|
||||||
|
|
@ -23,7 +21,6 @@ import io.element.android.libraries.matrix.test.sync.FakeSyncService
|
||||||
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableCallEvent
|
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableCallEvent
|
||||||
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
import io.element.android.libraries.push.impl.notifications.fixtures.aNotifiableMessageEvent
|
||||||
import io.element.android.services.appnavstate.test.FakeAppForegroundStateService
|
import io.element.android.services.appnavstate.test.FakeAppForegroundStateService
|
||||||
import io.element.android.tests.testutils.lambda.assert
|
|
||||||
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
import io.element.android.tests.testutils.lambda.lambdaRecorder
|
||||||
import io.element.android.tests.testutils.testCoroutineDispatchers
|
import io.element.android.tests.testutils.testCoroutineDispatchers
|
||||||
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
import kotlinx.coroutines.ExperimentalCoroutinesApi
|
||||||
|
|
@ -60,24 +57,13 @@ class SyncOnNotifiableEventTest {
|
||||||
private val notifiableEvent = aNotifiableMessageEvent()
|
private val notifiableEvent = aNotifiableMessageEvent()
|
||||||
private val incomingCallNotifiableEvent = aNotifiableCallEvent()
|
private val incomingCallNotifiableEvent = aNotifiableCallEvent()
|
||||||
|
|
||||||
@Test
|
|
||||||
fun `when feature flag is disabled, nothing happens`() = runTest {
|
|
||||||
val sut = createSyncOnNotifiableEvent(client = client, isSyncOnPushEnabled = false)
|
|
||||||
|
|
||||||
sut(listOf(notifiableEvent))
|
|
||||||
|
|
||||||
assert(startSyncLambda).isNeverCalled()
|
|
||||||
assert(stopSyncLambda).isNeverCalled()
|
|
||||||
assert(subscribeToSyncLambda).isNeverCalled()
|
|
||||||
}
|
|
||||||
|
|
||||||
@OptIn(ExperimentalCoroutinesApi::class)
|
@OptIn(ExperimentalCoroutinesApi::class)
|
||||||
@Test
|
@Test
|
||||||
fun `when feature flag is enabled, a ringing call waits until the room is in 'in-call' state`() = runTest {
|
fun `when feature flag is enabled, a ringing call waits until the room is in 'in-call' state`() = runTest {
|
||||||
val appForegroundStateService = FakeAppForegroundStateService(
|
val appForegroundStateService = FakeAppForegroundStateService(
|
||||||
initialForegroundValue = false,
|
initialForegroundValue = false,
|
||||||
)
|
)
|
||||||
val sut = createSyncOnNotifiableEvent(client = client, appForegroundStateService = appForegroundStateService, isSyncOnPushEnabled = true)
|
val sut = createSyncOnNotifiableEvent(client = client, appForegroundStateService = appForegroundStateService)
|
||||||
|
|
||||||
val unlocked = AtomicBoolean(false)
|
val unlocked = AtomicBoolean(false)
|
||||||
launch {
|
launch {
|
||||||
|
|
@ -97,7 +83,7 @@ class SyncOnNotifiableEventTest {
|
||||||
val appForegroundStateService = FakeAppForegroundStateService(
|
val appForegroundStateService = FakeAppForegroundStateService(
|
||||||
initialForegroundValue = false,
|
initialForegroundValue = false,
|
||||||
)
|
)
|
||||||
val sut = createSyncOnNotifiableEvent(client = client, appForegroundStateService = appForegroundStateService, isSyncOnPushEnabled = true)
|
val sut = createSyncOnNotifiableEvent(client = client, appForegroundStateService = appForegroundStateService)
|
||||||
|
|
||||||
val unlocked = AtomicBoolean(false)
|
val unlocked = AtomicBoolean(false)
|
||||||
launch {
|
launch {
|
||||||
|
|
@ -116,7 +102,7 @@ class SyncOnNotifiableEventTest {
|
||||||
val appForegroundStateService = FakeAppForegroundStateService(
|
val appForegroundStateService = FakeAppForegroundStateService(
|
||||||
initialForegroundValue = false,
|
initialForegroundValue = false,
|
||||||
)
|
)
|
||||||
val sut = createSyncOnNotifiableEvent(client = client, appForegroundStateService = appForegroundStateService, isSyncOnPushEnabled = true)
|
val sut = createSyncOnNotifiableEvent(client = client, appForegroundStateService = appForegroundStateService)
|
||||||
|
|
||||||
appForegroundStateService.isSyncingNotificationEvent.test {
|
appForegroundStateService.isSyncingNotificationEvent.test {
|
||||||
syncService.emitSyncState(SyncState.Running)
|
syncService.emitSyncState(SyncState.Running)
|
||||||
|
|
@ -138,7 +124,7 @@ class SyncOnNotifiableEventTest {
|
||||||
val appForegroundStateService = FakeAppForegroundStateService(
|
val appForegroundStateService = FakeAppForegroundStateService(
|
||||||
initialForegroundValue = false,
|
initialForegroundValue = false,
|
||||||
)
|
)
|
||||||
val sut = createSyncOnNotifiableEvent(client = client, appForegroundStateService = appForegroundStateService, isSyncOnPushEnabled = true)
|
val sut = createSyncOnNotifiableEvent(client = client, appForegroundStateService = appForegroundStateService)
|
||||||
|
|
||||||
appForegroundStateService.isSyncingNotificationEvent.test {
|
appForegroundStateService.isSyncingNotificationEvent.test {
|
||||||
launch { sut(listOf(notifiableEvent)) }
|
launch { sut(listOf(notifiableEvent)) }
|
||||||
|
|
@ -157,20 +143,13 @@ class SyncOnNotifiableEventTest {
|
||||||
|
|
||||||
private fun TestScope.createSyncOnNotifiableEvent(
|
private fun TestScope.createSyncOnNotifiableEvent(
|
||||||
client: MatrixClient = FakeMatrixClient(),
|
client: MatrixClient = FakeMatrixClient(),
|
||||||
isSyncOnPushEnabled: Boolean = true,
|
|
||||||
appForegroundStateService: FakeAppForegroundStateService = FakeAppForegroundStateService(
|
appForegroundStateService: FakeAppForegroundStateService = FakeAppForegroundStateService(
|
||||||
initialForegroundValue = true,
|
initialForegroundValue = true,
|
||||||
),
|
),
|
||||||
): SyncOnNotifiableEvent {
|
): SyncOnNotifiableEvent {
|
||||||
val featureFlagService = FakeFeatureFlagService(
|
|
||||||
initialState = mapOf(
|
|
||||||
FeatureFlags.SyncOnPush.key to isSyncOnPushEnabled
|
|
||||||
)
|
|
||||||
)
|
|
||||||
val matrixClientProvider = FakeMatrixClientProvider { Result.success(client) }
|
val matrixClientProvider = FakeMatrixClientProvider { Result.success(client) }
|
||||||
return SyncOnNotifiableEvent(
|
return SyncOnNotifiableEvent(
|
||||||
matrixClientProvider = matrixClientProvider,
|
matrixClientProvider = matrixClientProvider,
|
||||||
featureFlagService = featureFlagService,
|
|
||||||
appForegroundStateService = appForegroundStateService,
|
appForegroundStateService = appForegroundStateService,
|
||||||
dispatchers = testCoroutineDispatchers(),
|
dispatchers = testCoroutineDispatchers(),
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue