Improve API, to avoid ignoring errors

This commit is contained in:
Benoit Marty 2024-05-06 23:06:25 +02:00 committed by Benoit Marty
parent 591df14450
commit 4bd01b6f4f
18 changed files with 143 additions and 107 deletions

View file

@ -24,7 +24,7 @@ interface UserPushStore {
suspend fun getPushProviderName(): String?
suspend fun setPushProviderName(value: String)
suspend fun getCurrentRegisteredPushKey(): String?
suspend fun setCurrentRegisteredPushKey(value: String)
suspend fun setCurrentRegisteredPushKey(value: String?)
fun getNotificationEnabledForDevice(): Flow<Boolean>
suspend fun setNotificationEnabledForDevice(enabled: Boolean)

View file

@ -76,9 +76,13 @@ class UserPushStoreDataStore(
return context.dataStore.data.first()[currentPushKey]
}
override suspend fun setCurrentRegisteredPushKey(value: String) {
override suspend fun setCurrentRegisteredPushKey(value: String?) {
context.dataStore.edit {
it[currentPushKey] = value
if (value == null) {
it.remove(currentPushKey)
} else {
it[currentPushKey] = value
}
}
}

View file

@ -36,7 +36,7 @@ class FakeUserPushStore : UserPushStore {
return currentRegisteredPushKey
}
override suspend fun setCurrentRegisteredPushKey(value: String) {
override suspend fun setCurrentRegisteredPushKey(value: String?) {
currentRegisteredPushKey = value
}