fix: 设置页面修改后不刷新

This commit is contained in:
HuanCheng65 2023-02-16 14:57:35 +08:00
parent 3ae3fcb96f
commit a9115bb520
No known key found for this signature in database
GPG Key ID: E9031EF91A805148
2 changed files with 4 additions and 8 deletions

View File

@ -65,10 +65,8 @@ fun ListPref(
prefs?.get(selectionKey)?.also { selected = it } // starting value if it exists in datastore prefs?.get(selectionKey)?.also { selected = it } // starting value if it exists in datastore
fun edit(current: Pair<String, String>) = run { fun edit(current: Pair<String, String>) = run {
scope.launch {
selected = current.first selected = current.first
onValueChange?.invoke(current.first) onValueChange?.invoke(current.first)
}
scope.launch { scope.launch {
try { try {
datastore.edit { preferences -> datastore.edit { preferences ->

View File

@ -39,10 +39,8 @@ fun SwitchPref(
prefs?.get(selectionKey)?.also { checked = it } // starting value if it exists in datastore prefs?.get(selectionKey)?.also { checked = it } // starting value if it exists in datastore
fun edit(newState: Boolean) = run { fun edit(newState: Boolean) = run {
scope.launch {
checked = newState checked = newState
onCheckedChange?.invoke(newState) onCheckedChange?.invoke(newState)
}
scope.launch { scope.launch {
try { try {
datastore.edit { preferences -> datastore.edit { preferences ->