diff --git a/app/src/main/kotlin/app/dapk/st/SharedPreferencesDelegate.kt b/app/src/main/kotlin/app/dapk/st/SharedPreferencesDelegate.kt index f9fb86e..2fb5fe4 100644 --- a/app/src/main/kotlin/app/dapk/st/SharedPreferencesDelegate.kt +++ b/app/src/main/kotlin/app/dapk/st/SharedPreferencesDelegate.kt @@ -19,24 +19,12 @@ internal class SharedPreferencesDelegate( } } - override suspend fun store(key: String, value: Set) { - coroutineDispatchers.withIoContext { - preferences.edit().putStringSet(key, value).apply() - } - } - override suspend fun readString(key: String): String? { return coroutineDispatchers.withIoContext { preferences.getString(key, null) } } - override suspend fun readStrings(key: String): Set? { - return coroutineDispatchers.withIoContext { - preferences.getStringSet(key, null) - } - } - override suspend fun remove(key: String) { coroutineDispatchers.withIoContext { preferences.edit().remove(key).apply() diff --git a/core/src/main/kotlin/app/dapk/st/core/Preferences.kt b/core/src/main/kotlin/app/dapk/st/core/Preferences.kt index 3d461e7..510290c 100644 --- a/core/src/main/kotlin/app/dapk/st/core/Preferences.kt +++ b/core/src/main/kotlin/app/dapk/st/core/Preferences.kt @@ -3,9 +3,7 @@ package app.dapk.st.core interface Preferences { suspend fun store(key: String, value: String) - suspend fun store(key: String, value: Set) suspend fun readString(key: String): String? - suspend fun readStrings(key: String): Set? suspend fun clear() suspend fun remove(key: String) } @@ -20,13 +18,4 @@ suspend fun CachedPreferences.readBoolean(key: String, defaultValue: Boolean) = suspend fun Preferences.readBoolean(key: String) = this.readString(key)?.toBooleanStrict() suspend fun Preferences.store(key: String, value: Boolean) = this.store(key, value.toString()) -suspend fun Preferences.append(key: String, value: String): Set { - val current = this.readStrings(key) ?: emptySet() - return (current + value).also { this.store(key, it) } -} - -suspend fun Preferences.removeFromSet(key: String, value: String): Set { - val current = this.readStrings(key) ?: emptySet() - return (current - value).also { this.store(key, it) } -} diff --git a/domains/store/src/main/kotlin/app/dapk/st/domain/preference/CachingPreferences.kt b/domains/store/src/main/kotlin/app/dapk/st/domain/preference/CachingPreferences.kt index f873df1..7b9ef84 100644 --- a/domains/store/src/main/kotlin/app/dapk/st/domain/preference/CachingPreferences.kt +++ b/domains/store/src/main/kotlin/app/dapk/st/domain/preference/CachingPreferences.kt @@ -10,17 +10,6 @@ class CachingPreferences(private val cache: PropertyCache, private val preferenc preferences.store(key, value) } - override suspend fun store(key: String, value: Set) { - cache.setValue(key, value) - preferences.store(key, value) - } - - override suspend fun readStrings(key: String): Set? { - return cache.getValue(key) ?: preferences.readStrings(key)?.also { - cache.setValue(key, it) - } - } - override suspend fun readString(key: String): String? { return cache.getValue(key) ?: preferences.readString(key)?.also { cache.setValue(key, it) diff --git a/test-harness/src/test/kotlin/test/impl/InMemoryPreferences.kt b/test-harness/src/test/kotlin/test/impl/InMemoryPreferences.kt index b6ec8ca..3390155 100644 --- a/test-harness/src/test/kotlin/test/impl/InMemoryPreferences.kt +++ b/test-harness/src/test/kotlin/test/impl/InMemoryPreferences.kt @@ -5,27 +5,19 @@ import app.dapk.st.core.Preferences class InMemoryPreferences : Preferences { private val prefs = mutableMapOf() - private val setPrefs = mutableMapOf>() override suspend fun store(key: String, value: String) { prefs[key] = value } - override suspend fun store(key: String, value: Set) { - setPrefs[key] = value - } - override suspend fun readString(key: String): String? = prefs[key] - override suspend fun readStrings(key: String): Set? = setPrefs[key] - + override suspend fun remove(key: String) { prefs.remove(key) - setPrefs.remove(key) } override suspend fun clear() { prefs.clear() - setPrefs.clear() } } \ No newline at end of file