Enable Offline mode of the SyncService, so that the sync starts automatically when the network is back.

Also rely on the sync state to render the "Offline" banner.
This commit is contained in:
Benoit Marty 2025-02-03 17:47:35 +01:00
parent f4afda119b
commit f84aa03605
20 changed files with 91 additions and 74 deletions

View file

@ -74,6 +74,7 @@ class RustMatrixClientFactory @Inject constructor(
val syncService = client.syncService()
.withUtdHook(UtdTracker(analyticsService))
.withOfflineMode()
.finish()
return RustMatrixClient(

View file

@ -19,6 +19,7 @@ import io.element.android.libraries.matrix.api.notificationsettings.Notification
import io.element.android.libraries.matrix.api.room.RoomMembershipObserver
import io.element.android.libraries.matrix.api.roomdirectory.RoomDirectoryService
import io.element.android.libraries.matrix.api.roomlist.RoomListService
import io.element.android.libraries.matrix.api.sync.SyncService
import io.element.android.libraries.matrix.api.verification.SessionVerificationService
import kotlinx.coroutines.CoroutineScope
@ -45,6 +46,11 @@ object SessionMatrixModule {
return matrixClient.roomListService
}
@Provides
fun providesSyncService(matrixClient: MatrixClient): SyncService {
return matrixClient.syncService()
}
@Provides
fun providesEncryptionService(matrixClient: MatrixClient): EncryptionService {
return matrixClient.encryptionService()

View file

@ -14,5 +14,6 @@ import org.matrix.rustcomponents.sdk.UnableToDecryptDelegate
class FakeRustSyncServiceBuilder : SyncServiceBuilder(NoPointer) {
override suspend fun withUtdHook(delegate: UnableToDecryptDelegate): SyncServiceBuilder = this
override fun withOfflineMode(): SyncServiceBuilder = this
override suspend fun finish(): SyncService = FakeRustSyncService()
}