fix(messaging): unread badge not shown – observeValue now reads sensitive keys from SecureTokenStorage
This commit is contained in:
parent
16576045a0
commit
f3c440b5a9
1 changed files with 10 additions and 1 deletions
|
|
@ -8,6 +8,7 @@ import de.bollwerk.app.domain.model.SettingsKeys
|
||||||
import de.bollwerk.app.domain.repository.SettingsRepository
|
import de.bollwerk.app.domain.repository.SettingsRepository
|
||||||
import kotlinx.coroutines.Dispatchers
|
import kotlinx.coroutines.Dispatchers
|
||||||
import kotlinx.coroutines.flow.Flow
|
import kotlinx.coroutines.flow.Flow
|
||||||
|
import kotlinx.coroutines.flow.flow
|
||||||
import kotlinx.coroutines.flow.map
|
import kotlinx.coroutines.flow.map
|
||||||
import kotlinx.coroutines.withContext
|
import kotlinx.coroutines.withContext
|
||||||
import javax.inject.Inject
|
import javax.inject.Inject
|
||||||
|
|
@ -37,7 +38,15 @@ internal class SettingsRepositoryImpl @Inject constructor(
|
||||||
withContext(Dispatchers.IO) { dao.upsert(SettingsEntity(key = key, value = value)) }
|
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()
|
override fun getAll(): Flow<List<SettingsEntity>> = dao.getAll()
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue