Ensure the sync is started when receiving a Push, to ensure that the encryption loop is running.

Fixes notification with endecrypted content (#1178)
This commit is contained in:
Benoit Marty 2023-09-04 12:50:37 +02:00
parent 4fd44131f6
commit 74a444966e
6 changed files with 75 additions and 16 deletions

View file

@ -60,6 +60,7 @@ import io.element.android.libraries.di.SessionScope
import io.element.android.libraries.matrix.api.MatrixClient
import io.element.android.libraries.matrix.api.core.MAIN_SPACE
import io.element.android.libraries.matrix.api.core.RoomId
import io.element.android.libraries.matrix.api.sync.StartSyncReason
import io.element.android.libraries.matrix.api.sync.SyncState
import io.element.android.libraries.push.api.notifications.NotificationDrawerManager
import io.element.android.services.appnavstate.api.AppNavigationStateService
@ -124,7 +125,7 @@ class LoggedInFlowNode @AssistedInject constructor(
onStop = {
//Counterpart startSync is done in observeSyncStateAndNetworkStatus method.
coroutineScope.launch {
syncService.stopSync()
syncService.stopSync(StartSyncReason.AppInForeground)
}
},
onDestroy = {
@ -150,7 +151,7 @@ class LoggedInFlowNode @AssistedInject constructor(
.collect { (syncState, networkStatus) ->
Timber.d("Sync state: $syncState, network status: $networkStatus")
if (syncState != SyncState.Running && networkStatus == NetworkStatus.Online) {
syncService.startSync()
syncService.startSync(StartSyncReason.AppInForeground)
}
}
}