feat(ui/features): better rule list management

This commit is contained in:
rhunk
2024-08-13 14:58:31 +02:00
parent 324eae8bfa
commit 4325e512ca
6 changed files with 248 additions and 7 deletions

View File

@@ -28,6 +28,7 @@
"routes": {
"tasks": "Tasks",
"features": "Features",
"manage_rule_feature": "Manage Rule Feature",
"home": "Home",
"home_settings": "Settings",
"home_logs": "Logs",
@@ -95,6 +96,18 @@
"config_export_failure_toast": "Failed to export config {error}",
"saved_config_snackbar": "Config saved"
},
"manage_rule_feature": {
"disable_state_option": "Disabled",
"disable_state_subtext": "No friends/groups will be affected",
"whitelist_state_option": "No one except ...",
"whitelist_state_subtext": "Only {count} friends/groups will be affected by this rule",
"whitelist_state_button": "Select allowed friends/groups",
"blacklist_state_option": "Everyone except ...",
"blacklist_state_subtext": "Everyone except {count} friends/groups will be affected by this rule",
"blacklist_state_button": "Select excluded friends/groups",
"clear_list_button": "Clear friends/groups list",
"dialog_clear_confirmation_text": "Are you sure you want to clear the list?"
},
"social": {
"friends_tab": "Friends",
"groups_tab": "Groups",

View File

@@ -70,11 +70,11 @@ class ModConfig(
}
}
fun writeConfig() {
writeConfigObject(root)
fun writeConfig(dispatchConfigListener: Boolean = true) {
writeConfigObject(root, dispatchConfigListener)
}
private fun writeConfigObject(config: RootConfig) {
private fun writeConfigObject(config: RootConfig, dispatchConfigListener: Boolean = true) {
var shouldRestart = false
var shouldCleanCache = false
var configChanged = false
@@ -113,7 +113,7 @@ class ModConfig(
val oldConfig = runCatching { fileWrapper.readBytes().toString(Charsets.UTF_8) }.getOrNull()
fileWrapper.writeBytes(exportToString(config = config).toByteArray(Charsets.UTF_8))
configStateListener?.takeIf { it.asBinder().pingBinder() }?.also {
configStateListener?.takeIf { dispatchConfigListener && it.asBinder().pingBinder() }?.also {
runCatching {
compareDiff(createRootConfig().apply {
fromJson(gson.fromJson(oldConfig ?: return@runCatching, JsonObject::class.java))