mirror of
https://github.com/Novaloop-AG/element-x-android.git
synced 2026-11-02 21:32:34 +00:00
Add persistent account provider history to app preferences
This commit is contained in:
+15
@@ -16,6 +16,7 @@ import io.element.android.libraries.preferences.api.store.NotificationSound
|
||||
import io.element.android.libraries.preferences.api.store.NotificationSoundChannelConfig
|
||||
import kotlinx.coroutines.flow.Flow
|
||||
import kotlinx.coroutines.flow.MutableStateFlow
|
||||
import kotlinx.coroutines.flow.update
|
||||
import kotlinx.coroutines.flow.updateAndGet
|
||||
|
||||
class InMemoryAppPreferencesStore(
|
||||
@@ -27,6 +28,7 @@ class InMemoryAppPreferencesStore(
|
||||
liveLocationMinimumDistanceUpdate: Int = 10,
|
||||
logLevel: LogLevel = LogLevel.INFO,
|
||||
traceLogPacks: Set<TraceLogPack> = emptySet(),
|
||||
homeserverHistory: List<String> = emptyList(),
|
||||
messageSound: NotificationSound = NotificationSound.SystemDefault,
|
||||
messageSoundChannelVersion: Int = 0,
|
||||
messageSoundDisplayName: String? = null,
|
||||
@@ -40,6 +42,7 @@ class InMemoryAppPreferencesStore(
|
||||
private val liveLocationMinimumDistanceUpdate = MutableStateFlow(liveLocationMinimumDistanceUpdate)
|
||||
private val logLevel = MutableStateFlow(logLevel)
|
||||
private val tracingLogPacks = MutableStateFlow(traceLogPacks)
|
||||
private val homeserverHistory = MutableStateFlow(homeserverHistory)
|
||||
private val hideInviteAvatars = MutableStateFlow(hideInviteAvatars)
|
||||
private val timelineMediaPreviewValue = MutableStateFlow(timelineMediaPreviewValue)
|
||||
private val messageSound = MutableStateFlow(messageSound)
|
||||
@@ -117,6 +120,18 @@ class InMemoryAppPreferencesStore(
|
||||
return tracingLogPacks
|
||||
}
|
||||
|
||||
override fun getHomeserverHistoryFlow(): Flow<List<String>> {
|
||||
return homeserverHistory
|
||||
}
|
||||
|
||||
override suspend fun addHomeserverToHistory(url: String) {
|
||||
val normalized = url.trim().lowercase()
|
||||
if (normalized.isEmpty()) return
|
||||
homeserverHistory.update { current ->
|
||||
(listOf(normalized) + current.filter { it != normalized }).take(10)
|
||||
}
|
||||
}
|
||||
|
||||
override fun getMessageSoundFlow(): Flow<NotificationSound> {
|
||||
return messageSound
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user