Skip to content

Commit 27e841a

Browse files
committed
Remove SyncOrchestrator interface, rename DefaultSyncOrchestrator to it, remove the existing provider interface.
1 parent d1afcb4 commit 27e841a

File tree

6 files changed

+15
-52
lines changed

6 files changed

+15
-52
lines changed

appnav/src/main/kotlin/io/element/android/appnav/di/MatrixSessionCache.kt

+5-6
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
package io.element.android.appnav.di
99

10+
import androidx.annotation.VisibleForTesting
1011
import com.bumble.appyx.core.state.MutableSavedStateMap
1112
import com.bumble.appyx.core.state.SavedStateMap
1213
import com.squareup.anvil.annotations.ContributesBinding
@@ -16,8 +17,6 @@ import io.element.android.libraries.matrix.api.MatrixClient
1617
import io.element.android.libraries.matrix.api.MatrixClientProvider
1718
import io.element.android.libraries.matrix.api.auth.MatrixAuthenticationService
1819
import io.element.android.libraries.matrix.api.core.SessionId
19-
import io.element.android.services.appnavstate.api.SyncOrchestrator
20-
import io.element.android.services.appnavstate.api.SyncOrchestratorProvider
2120
import kotlinx.coroutines.runBlocking
2221
import kotlinx.coroutines.sync.Mutex
2322
import kotlinx.coroutines.sync.withLock
@@ -34,11 +33,10 @@ private const val SAVE_INSTANCE_KEY = "io.element.android.x.di.MatrixClientsHold
3433
*/
3534
@SingleIn(AppScope::class)
3635
@ContributesBinding(AppScope::class, boundType = MatrixClientProvider::class)
37-
@ContributesBinding(AppScope::class, boundType = SyncOrchestratorProvider::class)
3836
class MatrixSessionCache @Inject constructor(
3937
private val authenticationService: MatrixAuthenticationService,
40-
private val syncOrchestratorFactory: DefaultSyncOrchestrator.Factory,
41-
) : MatrixClientProvider, SyncOrchestratorProvider {
38+
private val syncOrchestratorFactory: SyncOrchestrator.Factory,
39+
) : MatrixClientProvider {
4240
private val sessionIdsToMatrixSession = ConcurrentHashMap<SessionId, InMemoryMatrixSession>()
4341
private val restoreMutex = Mutex()
4442

@@ -74,7 +72,8 @@ class MatrixSessionCache @Inject constructor(
7472
}
7573
}
7674

77-
override fun getSyncOrchestrator(sessionId: SessionId): SyncOrchestrator? {
75+
@VisibleForTesting(otherwise = VisibleForTesting.PRIVATE)
76+
internal fun getSyncOrchestrator(sessionId: SessionId): SyncOrchestrator? {
7877
return sessionIdsToMatrixSession[sessionId]?.syncOrchestrator
7978
}
8079

appnav/src/main/kotlin/io/element/android/appnav/di/DefaultSyncOrchestrator.kt appnav/src/main/kotlin/io/element/android/appnav/di/SyncOrchestrator.kt

+4-5
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ import io.element.android.libraries.core.coroutine.CoroutineDispatchers
1616
import io.element.android.libraries.matrix.api.MatrixClient
1717
import io.element.android.libraries.matrix.api.sync.SyncState
1818
import io.element.android.services.appnavstate.api.AppForegroundStateService
19-
import io.element.android.services.appnavstate.api.SyncOrchestrator
2019
import kotlinx.coroutines.CoroutineName
2120
import kotlinx.coroutines.CoroutineScope
2221
import kotlinx.coroutines.FlowPreview
@@ -30,16 +29,16 @@ import java.util.concurrent.atomic.AtomicBoolean
3029
import kotlin.time.Duration.Companion.milliseconds
3130
import kotlin.time.Duration.Companion.seconds
3231

33-
class DefaultSyncOrchestrator @AssistedInject constructor(
32+
class SyncOrchestrator @AssistedInject constructor(
3433
@Assisted matrixClient: MatrixClient,
3534
sessionCoroutineScope: CoroutineScope = matrixClient.sessionCoroutineScope,
3635
private val appForegroundStateService: AppForegroundStateService,
3736
private val networkMonitor: NetworkMonitor,
3837
dispatchers: CoroutineDispatchers,
39-
) : SyncOrchestrator {
38+
) {
4039
@AssistedFactory
4140
interface Factory {
42-
fun create(matrixClient: MatrixClient): DefaultSyncOrchestrator
41+
fun create(matrixClient: MatrixClient): SyncOrchestrator
4342
}
4443

4544
private val syncService = matrixClient.syncService()
@@ -56,7 +55,7 @@ class DefaultSyncOrchestrator @AssistedInject constructor(
5655
* Before observing the state, a first attempt at starting the sync service will happen if it's not already running.
5756
*/
5857
@OptIn(FlowPreview::class)
59-
override fun start() {
58+
fun start() {
6059
if (!started.compareAndSet(false, true)) {
6160
Timber.tag(tag).d("already started, exiting early")
6261
return

appnav/src/test/kotlin/io/element/android/appnav/DefaultSyncOrchestratorTest.kt appnav/src/test/kotlin/io/element/android/appnav/SyncOrchestratorTest.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
package io.element.android.appnav
99

10-
import io.element.android.appnav.di.DefaultSyncOrchestrator
10+
import io.element.android.appnav.di.SyncOrchestrator
1111
import io.element.android.features.networkmonitor.api.NetworkStatus
1212
import io.element.android.features.networkmonitor.test.FakeNetworkMonitor
1313
import io.element.android.libraries.matrix.api.sync.SyncState
@@ -30,7 +30,7 @@ import kotlin.time.Duration.Companion.milliseconds
3030
import kotlin.time.Duration.Companion.seconds
3131

3232
@OptIn(ExperimentalCoroutinesApi::class)
33-
class DefaultSyncOrchestratorTest {
33+
class SyncOrchestratorTest {
3434
@get:Rule
3535
val warmUpRule = WarmUpRule()
3636

@@ -302,7 +302,7 @@ class DefaultSyncOrchestratorTest {
302302
networkMonitor: FakeNetworkMonitor = FakeNetworkMonitor(),
303303
appForegroundStateService: FakeAppForegroundStateService = FakeAppForegroundStateService(),
304304
baseCoroutineScope: CoroutineScope = CoroutineScope(coroutineContext + SupervisorJob()),
305-
) = DefaultSyncOrchestrator(
305+
) = SyncOrchestrator(
306306
matrixClient = FakeMatrixClient(syncService = syncService),
307307
networkMonitor = networkMonitor,
308308
appForegroundStateService = appForegroundStateService,

appnav/src/test/kotlin/io/element/android/appnav/di/MatrixSessionCacheTest.kt

+3-3
Original file line numberDiff line numberDiff line change
@@ -141,9 +141,9 @@ class MatrixSessionCacheTest {
141141

142142
private fun TestScope.createSyncOrchestratorFactory(
143143
baseCoroutineScope: CoroutineScope = this,
144-
) = object : DefaultSyncOrchestrator.Factory {
145-
override fun create(matrixClient: MatrixClient): DefaultSyncOrchestrator {
146-
return DefaultSyncOrchestrator(
144+
) = object : SyncOrchestrator.Factory {
145+
override fun create(matrixClient: MatrixClient): SyncOrchestrator {
146+
return SyncOrchestrator(
147147
matrixClient,
148148
sessionCoroutineScope = baseCoroutineScope,
149149
appForegroundStateService = FakeAppForegroundStateService(),

services/appnavstate/api/src/main/kotlin/io/element/android/services/appnavstate/api/SyncOrchestrator.kt

-15
This file was deleted.

services/appnavstate/api/src/main/kotlin/io/element/android/services/appnavstate/api/SyncOrchestratorProvider.kt

-20
This file was deleted.

0 commit comments

Comments
 (0)