Show new notification sound banner logic
This commit is contained in:
parent
df384f6365
commit
98637b8fc5
11 changed files with 150 additions and 2 deletions
|
|
@ -37,5 +37,8 @@ interface AppPreferencesStore {
|
|||
suspend fun setTracingLogPacks(targets: Set<TraceLogPack>)
|
||||
fun getTracingLogPacksFlow(): Flow<Set<TraceLogPack>>
|
||||
|
||||
suspend fun setShowNewNotificationSoundBanner(show: Boolean)
|
||||
fun showNewNotificationSoundBanner(): Flow<Boolean>
|
||||
|
||||
suspend fun reset()
|
||||
}
|
||||
|
|
|
|||
|
|
@ -30,6 +30,7 @@ private val hideInviteAvatarsKey = booleanPreferencesKey("hideInviteAvatars")
|
|||
private val timelineMediaPreviewValueKey = stringPreferencesKey("timelineMediaPreviewValue")
|
||||
private val logLevelKey = stringPreferencesKey("logLevel")
|
||||
private val traceLogPacksKey = stringPreferencesKey("traceLogPacks")
|
||||
private val showNewNotificationSoundBannerKey = booleanPreferencesKey("showNewNotificationSoundBanner")
|
||||
|
||||
@ContributesBinding(AppScope::class)
|
||||
@Inject
|
||||
|
|
@ -145,6 +146,19 @@ class DefaultAppPreferencesStore(
|
|||
}
|
||||
}
|
||||
|
||||
override suspend fun setShowNewNotificationSoundBanner(show: Boolean) {
|
||||
store.edit { prefs ->
|
||||
prefs[showNewNotificationSoundBannerKey] = show
|
||||
}
|
||||
}
|
||||
|
||||
override fun showNewNotificationSoundBanner(): Flow<Boolean> {
|
||||
return store.data.map { prefs ->
|
||||
// Default is false, but a migration will set it to true on application upgrade (see AppMigration08)
|
||||
prefs[showNewNotificationSoundBannerKey] ?: false
|
||||
}
|
||||
}
|
||||
|
||||
override suspend fun reset() {
|
||||
store.edit { it.clear() }
|
||||
}
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ class InMemoryAppPreferencesStore(
|
|||
theme: String? = null,
|
||||
logLevel: LogLevel = LogLevel.INFO,
|
||||
traceLockPacks: Set<TraceLogPack> = emptySet(),
|
||||
showNewNotificationSoundBanner: Boolean = false,
|
||||
) : AppPreferencesStore {
|
||||
private val isDeveloperModeEnabled = MutableStateFlow(isDeveloperModeEnabled)
|
||||
private val customElementCallBaseUrl = MutableStateFlow(customElementCallBaseUrl)
|
||||
|
|
@ -30,6 +31,7 @@ class InMemoryAppPreferencesStore(
|
|||
private val tracingLogPacks = MutableStateFlow(traceLockPacks)
|
||||
private val hideInviteAvatars = MutableStateFlow(hideInviteAvatars)
|
||||
private val timelineMediaPreviewValue = MutableStateFlow(timelineMediaPreviewValue)
|
||||
private val showNewNotificationSoundBanner = MutableStateFlow(showNewNotificationSoundBanner)
|
||||
|
||||
override suspend fun setDeveloperModeEnabled(enabled: Boolean) {
|
||||
isDeveloperModeEnabled.value = enabled
|
||||
|
|
@ -91,6 +93,14 @@ class InMemoryAppPreferencesStore(
|
|||
return tracingLogPacks
|
||||
}
|
||||
|
||||
override suspend fun setShowNewNotificationSoundBanner(show: Boolean) {
|
||||
showNewNotificationSoundBanner.value = show
|
||||
}
|
||||
|
||||
override fun showNewNotificationSoundBanner(): Flow<Boolean> {
|
||||
return showNewNotificationSoundBanner
|
||||
}
|
||||
|
||||
override suspend fun reset() {
|
||||
// No op
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue