Exclude tracker credentials in backups

This commit is contained in:
arkon
2023-10-08 11:07:42 -04:00
parent 72024aa44a
commit 730f3a6e52
6 changed files with 52 additions and 16 deletions

View File

@ -21,6 +21,24 @@ interface Preference<T> {
fun changes(): Flow<T>
fun stateIn(scope: CoroutineScope): StateFlow<T>
val isPrivate: Boolean
get() = key().startsWith(PRIVATE_PREFIX)
companion object {
/**
* A preference that should not be exposed in places like backups.
*/
fun isPrivate(key: String): Boolean {
return key.startsWith(PRIVATE_PREFIX)
}
fun privateKey(key: String): String {
return "${PRIVATE_PREFIX}$key"
}
private const val PRIVATE_PREFIX = "__PRIVATE_"
}
}
inline fun <reified T, R : T> Preference<T>.getAndSet(crossinline block: (T) -> R) = set(