mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-03 01:39:22 +02:00
Improve logic for syncing installed apps
This commit is contained in:
parent
fe3a8f7153
commit
1121bb6aad
1 changed files with 11 additions and 4 deletions
|
@ -36,7 +36,7 @@ class SyncInstalledAppsLogic(val appLogic: AppLogic) {
|
|||
init {
|
||||
appLogic.platformIntegration.installedAppsChangeListener = Runnable { requestSync() }
|
||||
appLogic.deviceEntryIfEnabled.map {
|
||||
it?.id + it?.currentUserId + it?.enableActivityLevelBlocking
|
||||
it?.id + it?.currentUserId + it?.defaultUser + it?.enableActivityLevelBlocking
|
||||
}.ignoreUnchanged().observeForever { requestSync() }
|
||||
|
||||
runAsyncExpectForever { syncLoop() }
|
||||
|
@ -62,10 +62,17 @@ class SyncInstalledAppsLogic(val appLogic: AppLogic) {
|
|||
return
|
||||
}
|
||||
|
||||
val userEntry = appLogic.deviceUserEntry.waitForNullableValue()
|
||||
if (appLogic.database.config().getDeviceAuthTokenAsync().waitForNullableValue().isNullOrEmpty()) {
|
||||
// local mode -> sync always
|
||||
} else {
|
||||
// connected mode -> don't sync always
|
||||
|
||||
if (userEntry == null || userEntry.type != UserType.Child) {
|
||||
return@withLock
|
||||
val userEntry = appLogic.deviceUserEntry.waitForNullableValue()
|
||||
val defaultUserEntry = appLogic.database.user().getUserByIdLive(deviceEntry.defaultUser).waitForNullableValue()
|
||||
|
||||
if (userEntry?.type != UserType.Child && defaultUserEntry?.type != UserType.Child) {
|
||||
return@withLock
|
||||
}
|
||||
}
|
||||
|
||||
val deviceId = deviceEntry.id
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue