Adds forceLoginFallback private setting
This commit is contained in:
parent
4ebaa349c3
commit
2917d4e4d6
|
@ -20,4 +20,5 @@ import im.vector.app.core.platform.VectorViewModelAction
|
|||
|
||||
sealed class DebugPrivateSettingsViewActions : VectorViewModelAction {
|
||||
data class SetDialPadVisibility(val force: Boolean) : DebugPrivateSettingsViewActions()
|
||||
data class SetForceLoginFallbackEnabled(val force: Boolean) : DebugPrivateSettingsViewActions()
|
||||
}
|
||||
|
|
|
@ -45,15 +45,18 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
|
|||
|
||||
private fun observeVectorDataStore() {
|
||||
vectorDataStore.forceDialPadDisplayFlow.setOnEach {
|
||||
copy(
|
||||
dialPadVisible = it
|
||||
)
|
||||
copy(dialPadVisible = it)
|
||||
}
|
||||
|
||||
vectorDataStore.forceLoginFallbackFlow.setOnEach {
|
||||
copy(forceLoginFallback = false)
|
||||
}
|
||||
}
|
||||
|
||||
override fun handle(action: DebugPrivateSettingsViewActions) {
|
||||
when (action) {
|
||||
is DebugPrivateSettingsViewActions.SetDialPadVisibility -> handleSetDialPadVisibility(action)
|
||||
is DebugPrivateSettingsViewActions.SetDialPadVisibility -> handleSetDialPadVisibility(action)
|
||||
is DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled -> handleSetForceLoginFallbackEnabled(action)
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -62,4 +65,10 @@ class DebugPrivateSettingsViewModel @AssistedInject constructor(
|
|||
vectorDataStore.setForceDialPadDisplay(action.force)
|
||||
}
|
||||
}
|
||||
|
||||
private fun handleSetForceLoginFallbackEnabled(action: DebugPrivateSettingsViewActions.SetForceLoginFallbackEnabled) {
|
||||
viewModelScope.launch {
|
||||
vectorDataStore.setForceLoginFallbackFlow(action.force)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,5 +19,6 @@ package im.vector.app.features.debug.settings
|
|||
import com.airbnb.mvrx.MavericksState
|
||||
|
||||
data class DebugPrivateSettingsViewState(
|
||||
val dialPadVisible: Boolean = false
|
||||
val dialPadVisible: Boolean = false,
|
||||
val forceLoginFallback: Boolean = false,
|
||||
) : MavericksState
|
||||
|
|
|
@ -59,4 +59,17 @@ class VectorDataStore @Inject constructor(
|
|||
settings[forceDialPadDisplay] = force
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private val forceLoginFallback = booleanPreferencesKey("force_login_fallback")
|
||||
|
||||
val forceLoginFallbackFlow: Flow<Boolean> = context.dataStore.data.map { preferences ->
|
||||
preferences[forceLoginFallback].orFalse()
|
||||
}
|
||||
|
||||
suspend fun setForceLoginFallbackFlow(force: Boolean) {
|
||||
context.dataStore.edit { settings ->
|
||||
settings[forceLoginFallback] = force
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue