capturing the original switch state at the point of clicking the switch rather than when the listener is initially set

This commit is contained in:
Adam Brown 2021-09-21 15:26:51 +01:00
parent 710f2f92cb
commit 03eb36636d
1 changed files with 1 additions and 1 deletions

View File

@ -386,8 +386,8 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor(
} }
private fun SwitchPreference.setTransactionalSwitchChangeListener(scope: CoroutineScope, transaction: suspend (Boolean) -> Unit) { private fun SwitchPreference.setTransactionalSwitchChangeListener(scope: CoroutineScope, transaction: suspend (Boolean) -> Unit) {
val originalState = this.isChecked
this.setOnPreferenceChangeListener { switchPreference, isChecked -> this.setOnPreferenceChangeListener { switchPreference, isChecked ->
val originalState = this.isChecked
scope.launch { scope.launch {
try { try {
transaction(isChecked as Boolean) transaction(isChecked as Boolean)