mirror of
https://github.com/twofas/2fas-android.git
synced 2024-11-24 19:30:05 +01:00
Fix cloud sync
This commit is contained in:
parent
97b546007b
commit
e64542d90c
@ -252,10 +252,7 @@ class BackupRepositoryImpl(
|
||||
try {
|
||||
val backupContent = json.decodeFromString<BackupContent>(result.fileContent)
|
||||
remoteBackupStatusPreference.put {
|
||||
it.copy(
|
||||
reference = backupContent.reference,
|
||||
lastSyncMillis = backupContent.updatedAt,
|
||||
)
|
||||
it.copy(reference = backupContent.reference)
|
||||
}
|
||||
|
||||
// Decrypt backup
|
||||
|
@ -1,10 +1,14 @@
|
||||
package com.twofasapp.data.services
|
||||
|
||||
import com.twofasapp.common.coroutines.Dispatchers
|
||||
import com.twofasapp.data.services.domain.CloudSyncTrigger
|
||||
import com.twofasapp.data.services.domain.Group
|
||||
import com.twofasapp.data.services.local.GroupsLocalSource
|
||||
import com.twofasapp.data.services.local.ServicesLocalSource
|
||||
import com.twofasapp.data.services.mapper.asDomain
|
||||
import com.twofasapp.data.services.remote.CloudSyncWorkDispatcher
|
||||
import com.twofasapp.prefs.model.RemoteBackupStatusEntity
|
||||
import com.twofasapp.prefs.usecase.RemoteBackupStatusPreference
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.first
|
||||
import kotlinx.coroutines.flow.map
|
||||
@ -14,6 +18,8 @@ internal class GroupsRepositoryImpl(
|
||||
private val dispatchers: Dispatchers,
|
||||
private val local: GroupsLocalSource,
|
||||
private val localServices: ServicesLocalSource,
|
||||
private val cloudSyncWorkDispatcher: CloudSyncWorkDispatcher,
|
||||
private val remoteBackupStatusPreference: RemoteBackupStatusPreference,
|
||||
) : GroupsRepository {
|
||||
|
||||
override fun observeGroups(): Flow<List<Group>> {
|
||||
@ -41,6 +47,10 @@ internal class GroupsRepositoryImpl(
|
||||
local.addGroup(name)
|
||||
localServices.cleanUpGroups(local.getGroups().ids)
|
||||
}
|
||||
|
||||
if (remoteBackupStatusPreference.get().state == RemoteBackupStatusEntity.State.ACTIVE) {
|
||||
cloudSyncWorkDispatcher.tryDispatch(CloudSyncTrigger.GroupsChanged)
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun addGroup(group: Group) {
|
||||
|
Loading…
Reference in New Issue
Block a user