mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-06 11:59:57 +02:00
Add user limit login category feature
This commit is contained in:
parent
3f7e34a175
commit
7c8c00b539
40 changed files with 2502 additions and 187 deletions
|
@ -52,8 +52,24 @@ object ApplyServerDataStatus {
|
|||
run {
|
||||
// update/ create entries (first because there must be always one parent user)
|
||||
|
||||
newUserList.data.forEach {
|
||||
newData ->
|
||||
newUserList.data.forEach { newEntry ->
|
||||
val newData = User(
|
||||
id = newEntry.id,
|
||||
name = newEntry.name,
|
||||
password = newEntry.password,
|
||||
secondPasswordSalt = newEntry.secondPasswordSalt,
|
||||
type = newEntry.type,
|
||||
timeZone = newEntry.timeZone,
|
||||
disableLimitsUntil = newEntry.disableLimitsUntil,
|
||||
mail = newEntry.mail,
|
||||
currentDevice = newEntry.currentDevice,
|
||||
categoryForNotAssignedApps = newEntry.categoryForNotAssignedApps,
|
||||
relaxPrimaryDevice = newEntry.relaxPrimaryDevice,
|
||||
mailNotificationFlags = newEntry.mailNotificationFlags,
|
||||
blockedTimes = newEntry.blockedTimes,
|
||||
flags = newEntry.flags
|
||||
)
|
||||
|
||||
val oldEntry = oldUserList.find { it.id == newData.id }
|
||||
|
||||
if (oldEntry == null) {
|
||||
|
@ -460,6 +476,24 @@ object ApplyServerDataStatus {
|
|||
)
|
||||
}
|
||||
}
|
||||
|
||||
status.newUserList?.data?.forEach { user ->
|
||||
if (user.limitLoginCategory == null) {
|
||||
database.userLimitLoginCategoryDao().removeItemSync(user.id)
|
||||
} else {
|
||||
val oldItem = database.userLimitLoginCategoryDao().getByParentUserIdSync(user.id)
|
||||
|
||||
if (oldItem == null || oldItem.categoryId != user.limitLoginCategory) {
|
||||
database.userLimitLoginCategoryDao().removeItemSync(user.id)
|
||||
database.userLimitLoginCategoryDao().insertOrIgnoreItemSync(
|
||||
UserLimitLoginCategory(
|
||||
userId = user.id,
|
||||
categoryId = user.limitLoginCategory
|
||||
)
|
||||
)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue