From a9115bb520cfcf6f8f72e3d753010a588c203684 Mon Sep 17 00:00:00 2001 From: HuanCheng65 <22636177+HuanCheng65@users.noreply.github.com> Date: Thu, 16 Feb 2023 14:57:35 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E8=AE=BE=E7=BD=AE=E9=A1=B5=E9=9D=A2?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=90=8E=E4=B8=8D=E5=88=B7=E6=96=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../tieba/post/ui/common/prefs/widgets/ListPref.kt | 6 ++---- .../tieba/post/ui/common/prefs/widgets/SwitchPref.kt | 6 ++---- 2 files changed, 4 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/common/prefs/widgets/ListPref.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/common/prefs/widgets/ListPref.kt index a17baf37..cad81606 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/common/prefs/widgets/ListPref.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/common/prefs/widgets/ListPref.kt @@ -65,10 +65,8 @@ fun ListPref( prefs?.get(selectionKey)?.also { selected = it } // starting value if it exists in datastore fun edit(current: Pair) = run { - scope.launch { - selected = current.first - onValueChange?.invoke(current.first) - } + selected = current.first + onValueChange?.invoke(current.first) scope.launch { try { datastore.edit { preferences -> diff --git a/app/src/main/java/com/huanchengfly/tieba/post/ui/common/prefs/widgets/SwitchPref.kt b/app/src/main/java/com/huanchengfly/tieba/post/ui/common/prefs/widgets/SwitchPref.kt index 3191113d..1c1264e9 100644 --- a/app/src/main/java/com/huanchengfly/tieba/post/ui/common/prefs/widgets/SwitchPref.kt +++ b/app/src/main/java/com/huanchengfly/tieba/post/ui/common/prefs/widgets/SwitchPref.kt @@ -39,10 +39,8 @@ fun SwitchPref( prefs?.get(selectionKey)?.also { checked = it } // starting value if it exists in datastore fun edit(newState: Boolean) = run { - scope.launch { - checked = newState - onCheckedChange?.invoke(newState) - } + checked = newState + onCheckedChange?.invoke(newState) scope.launch { try { datastore.edit { preferences ->