From 03eb36636d46bd07092f353c002dc7964923ef35 Mon Sep 17 00:00:00 2001 From: Adam Brown Date: Tue, 21 Sep 2021 15:26:51 +0100 Subject: [PATCH] capturing the original switch state at the point of clicking the switch rather than when the listener is initially set --- .../VectorSettingsNotificationPreferenceFragment.kt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt index 0a123b8281..28564389f2 100644 --- a/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt +++ b/vector/src/main/java/im/vector/app/features/settings/notifications/VectorSettingsNotificationPreferenceFragment.kt @@ -386,8 +386,8 @@ class VectorSettingsNotificationPreferenceFragment @Inject constructor( } private fun SwitchPreference.setTransactionalSwitchChangeListener(scope: CoroutineScope, transaction: suspend (Boolean) -> Unit) { - val originalState = this.isChecked this.setOnPreferenceChangeListener { switchPreference, isChecked -> + val originalState = this.isChecked scope.launch { try { transaction(isChecked as Boolean)