library: removeKeys deletes every stored type (#tests)
- Commit
0d4e5ba16f1051e7c3d2bcd1d8a5f902ac837d4d- Author
- Vayun Mathur <[email protected]>
- When
- 2026-11-15 00:06 UTC (21 days ago)
- Parents
deed149
DataStoreUtils.removeKeys documented 'whatever type they hold' but only removed string-set and long keys. Callers deleting string session keys (communicate line sessions) and double calibration offsets (measure level) therefore left the values behind to resurrect on reload. Remove all six preference types. Verified: :measure:testDevUnitTest MeasureViewModelTest green with the measure IO-write fix that exercises this path.
Diff
library/src/main/java/com/vayunmathur/library/util/DataStoreUtils.kt
diff --git a/library/src/main/java/com/vayunmathur/library/util/DataStoreUtils.kt b/library/src/main/java/com/vayunmathur/library/util/DataStoreUtils.ktindex 9e6ecf14ad..8f6fc2d5e4 100644--- a/library/src/main/java/com/vayunmathur/library/util/DataStoreUtils.kt+++ b/library/src/main/java/com/vayunmathur/library/util/DataStoreUtils.kt@@ -217,8 +217,16 @@ class DataStoreUtils internal constructor(private val dataStore: DataStore<Prefe suspend fun removeKeys(names: Collection<String>) { dataStore.edit { prefs -> for (name in names) {+ // Every stored type, as documented above: callers+ // remove string session keys and double calibration+ // offsets, neither of which the old two-type removal+ // touched, so "cleared" values resurrected on reload. prefs.remove(stringSetPreferencesKey(name)) prefs.remove(longPreferencesKey(name))+ prefs.remove(booleanPreferencesKey(name))+ prefs.remove(doublePreferencesKey(name))+ prefs.remove(stringPreferencesKey(name))+ prefs.remove(byteArrayPreferencesKey(name)) } } }