mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-04 02:09:19 +02:00
Add action to configure blocking all notifications
This commit is contained in:
parent
9dc8a6caab
commit
7ae4c30e3e
3 changed files with 33 additions and 0 deletions
|
@ -877,6 +877,28 @@ data class UpdateCategoryBlockedTimesAction(val categoryId: String, val blockedT
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
data class UpdateCategoryBlockAllNotificationsAction(val categoryId: String, val blocked: Boolean): ParentAction() {
|
||||||
|
companion object {
|
||||||
|
private const val TYPE_VALUE = "UPDATE_CATEGORY_BLOCK_ALL_NOTIFICATIONS"
|
||||||
|
private const val CATEGORY_ID = "categoryId"
|
||||||
|
private const val BLOCK = "blocked"
|
||||||
|
}
|
||||||
|
|
||||||
|
init {
|
||||||
|
IdGenerator.assertIdValid(categoryId)
|
||||||
|
}
|
||||||
|
|
||||||
|
override fun serialize(writer: JsonWriter) {
|
||||||
|
writer.beginObject()
|
||||||
|
|
||||||
|
writer.name(TYPE).value(TYPE_VALUE)
|
||||||
|
writer.name(CATEGORY_ID).value(categoryId)
|
||||||
|
writer.name(BLOCK).value(blocked)
|
||||||
|
|
||||||
|
writer.endObject()
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
data class CreateTimeLimitRuleAction(val rule: TimeLimitRule): ParentAction() {
|
data class CreateTimeLimitRuleAction(val rule: TimeLimitRule): ParentAction() {
|
||||||
companion object {
|
companion object {
|
||||||
const val TYPE_VALUE = "CREATE_TIMELIMIT_RULE"
|
const val TYPE_VALUE = "CREATE_TIMELIMIT_RULE"
|
||||||
|
|
|
@ -60,6 +60,7 @@ object ActionParser {
|
||||||
// SetConsiderRebootManipulationAction
|
// SetConsiderRebootManipulationAction
|
||||||
// RenameChildAction
|
// RenameChildAction
|
||||||
// UpdateParentNotificationFlagsAction
|
// UpdateParentNotificationFlagsAction
|
||||||
|
// UpdateCategoryBlockAllNotificationsAction
|
||||||
else -> throw IllegalStateException()
|
else -> throw IllegalStateException()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -454,6 +454,16 @@ object LocalDatabaseParentActionDispatcher {
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
is UpdateCategoryBlockAllNotificationsAction -> {
|
||||||
|
val categoryEntry = database.category().getCategoryByIdSync(action.categoryId)
|
||||||
|
?: throw IllegalArgumentException("can not update notification blocking for non exsistent category")
|
||||||
|
|
||||||
|
database.category().updateCategorySync(
|
||||||
|
categoryEntry.copy(
|
||||||
|
blockAllNotifications = action.blocked
|
||||||
|
)
|
||||||
|
)
|
||||||
|
}
|
||||||
}.let { }
|
}.let { }
|
||||||
|
|
||||||
database.setTransactionSuccessful()
|
database.setTransactionSuccessful()
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue