mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-05 19:42:20 +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 {
|
init {
|
||||||
appLogic.platformIntegration.installedAppsChangeListener = Runnable { requestSync() }
|
appLogic.platformIntegration.installedAppsChangeListener = Runnable { requestSync() }
|
||||||
appLogic.deviceEntryIfEnabled.map {
|
appLogic.deviceEntryIfEnabled.map {
|
||||||
it?.id + it?.currentUserId + it?.enableActivityLevelBlocking
|
it?.id + it?.currentUserId + it?.defaultUser + it?.enableActivityLevelBlocking
|
||||||
}.ignoreUnchanged().observeForever { requestSync() }
|
}.ignoreUnchanged().observeForever { requestSync() }
|
||||||
|
|
||||||
runAsyncExpectForever { syncLoop() }
|
runAsyncExpectForever { syncLoop() }
|
||||||
|
@ -62,11 +62,18 @@ class SyncInstalledAppsLogic(val appLogic: AppLogic) {
|
||||||
return
|
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) {
|
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
|
return@withLock
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
val deviceId = deviceEntry.id
|
val deviceId = deviceEntry.id
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue