From 8bdb784a14f302506aef10455b42840e2abcc70d Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Wed, 7 Dec 2022 12:57:23 +0300 Subject: [PATCH] android: Added rememberSaveable in pref screens (fix merge) (#1517) --- .../java/chat/simplex/app/views/chat/ContactPreferences.kt | 4 ++-- .../chat/simplex/app/views/chat/group/GroupPreferences.kt | 4 ++-- .../java/chat/simplex/app/views/usersettings/Preferences.kt | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ContactPreferences.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ContactPreferences.kt index a309a8a3f..299ae6e49 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/ContactPreferences.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/ContactPreferences.kt @@ -30,8 +30,8 @@ fun ContactPreferencesView( ) { val contact = remember { derivedStateOf { (m.getContactChat(contactId)?.chatInfo as? ChatInfo.Direct)?.contact } } val ct = contact.value ?: return - var featuresAllowed by remember(ct) { mutableStateOf(contactUserPrefsToFeaturesAllowed(ct.mergedPreferences)) } - var currentFeaturesAllowed by remember(ct) { mutableStateOf(featuresAllowed) } + var featuresAllowed by rememberSaveable(ct, stateSaver = serializableSaver()) { mutableStateOf(contactUserPrefsToFeaturesAllowed(ct.mergedPreferences)) } + var currentFeaturesAllowed by rememberSaveable(ct, stateSaver = serializableSaver()) { mutableStateOf(featuresAllowed) } fun savePrefs(afterSave: () -> Unit = {}) { withApi { diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt index 550ccd16c..a753df056 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/chat/group/GroupPreferences.kt @@ -24,8 +24,8 @@ import chat.simplex.app.views.helpers.* fun GroupPreferencesView(m: ChatModel, chatId: String, close: () -> Unit,) { val groupInfo = remember { derivedStateOf { (m.getChat(chatId)?.chatInfo as? ChatInfo.Group)?.groupInfo } } val gInfo = groupInfo.value ?: return - var preferences by remember(gInfo) { mutableStateOf(gInfo.fullGroupPreferences) } - var currentPreferences by remember(gInfo) { mutableStateOf(preferences) } + var preferences by rememberSaveable(gInfo, stateSaver = serializableSaver()) { mutableStateOf(gInfo.fullGroupPreferences) } + var currentPreferences by rememberSaveable(gInfo, stateSaver = serializableSaver()) { mutableStateOf(preferences) } fun savePrefs(afterSave: () -> Unit = {}) { withApi { diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/Preferences.kt b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/Preferences.kt index b1d1d5fde..9ac0b43ea 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/Preferences.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/Preferences.kt @@ -21,8 +21,8 @@ import chat.simplex.app.views.helpers.* @Composable fun PreferencesView(m: ChatModel, user: User, close: () -> Unit,) { - var preferences by remember { mutableStateOf(user.fullPreferences) } - var currentPreferences by remember { mutableStateOf(preferences) } + var preferences by rememberSaveable(stateSaver = serializableSaver()) { mutableStateOf(user.fullPreferences) } + var currentPreferences by rememberSaveable(stateSaver = serializableSaver()) { mutableStateOf(preferences) } fun savePrefs(afterSave: () -> Unit = {}) { withApi {