fix(messaging): unread badge not shown – observeValue now reads sensitive keys from SecureTokenStorage

This commit is contained in:
Jens Reinemann 2026-05-19 22:06:27 +02:00
parent 16576045a0
commit f3c440b5a9

View file

@ -8,6 +8,7 @@ import de.bollwerk.app.domain.model.SettingsKeys
import de.bollwerk.app.domain.repository.SettingsRepository
import kotlinx.coroutines.Dispatchers
import kotlinx.coroutines.flow.Flow
import kotlinx.coroutines.flow.flow
import kotlinx.coroutines.flow.map
import kotlinx.coroutines.withContext
import javax.inject.Inject
@ -37,7 +38,15 @@ internal class SettingsRepositoryImpl @Inject constructor(
withContext(Dispatchers.IO) { dao.upsert(SettingsEntity(key = key, value = value)) }
}
override fun observeValue(key: String): Flow<String?> = dao.observeValue(key)
override fun observeValue(key: String): Flow<String?> =
if (key in SettingsKeys.SENSITIVE_KEYS) {
// Sensitive values live in SecureTokenStorage, not in Room.
// Emit once when subscribed; re-subscription happens naturally on
// login/logout because the ViewModel is recreated at that point.
flow { emit(secureTokenStorage.get(key)) }
} else {
dao.observeValue(key)
}
override fun getAll(): Flow<List<SettingsEntity>> = dao.getAll()