From 20cec4db119e4e3d48908fd4b81eacb2ba01cc3f Mon Sep 17 00:00:00 2001 From: Stanislav Dmitrenko <7953703+avently@users.noreply.github.com> Date: Fri, 13 Jan 2023 18:57:54 +0000 Subject: [PATCH] mobile: do not reset chat preferences on profile update (#1740) * android: Do not reset prefs on profile update * ios: Include prefs into Profile/LocalProfile --- .../chat/simplex/app/views/usersettings/UserProfileView.kt | 3 +-- apps/ios/SimpleXChat/ChatTypes.swift | 4 ++-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/UserProfileView.kt b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/UserProfileView.kt index 67f03033c7..b33a9548c5 100644 --- a/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/UserProfileView.kt +++ b/apps/android/app/src/main/java/chat/simplex/app/views/usersettings/UserProfileView.kt @@ -44,8 +44,7 @@ fun UserProfileView(chatModel: ChatModel, close: () -> Unit) { close, saveProfile = { displayName, fullName, image -> withApi { - val p = Profile(displayName, fullName, image) - val newProfile = chatModel.controller.apiUpdateProfile(p) + val newProfile = chatModel.controller.apiUpdateProfile(profile.copy(displayName = displayName, fullName = fullName, image = image)) if (newProfile != null) { chatModel.currentUser.value?.profile?.profileId?.let { chatModel.updateUserProfile(newProfile.toLocalProfile(it)) diff --git a/apps/ios/SimpleXChat/ChatTypes.swift b/apps/ios/SimpleXChat/ChatTypes.swift index dae0bbe08d..a007694e65 100644 --- a/apps/ios/SimpleXChat/ChatTypes.swift +++ b/apps/ios/SimpleXChat/ChatTypes.swift @@ -93,11 +93,11 @@ public struct LocalProfile: Codable, NamedChat { } public func toLocalProfile (_ profileId: Int64, _ profile: Profile, _ localAlias: String) -> LocalProfile { - LocalProfile(profileId: profileId, displayName: profile.displayName, fullName: profile.fullName, image: profile.image, localAlias: localAlias) + LocalProfile(profileId: profileId, displayName: profile.displayName, fullName: profile.fullName, image: profile.image, preferences: profile.preferences, localAlias: localAlias) } public func fromLocalProfile (_ profile: LocalProfile) -> Profile { - Profile(displayName: profile.displayName, fullName: profile.fullName, image: profile.image) + Profile(displayName: profile.displayName, fullName: profile.fullName, image: profile.image, preferences: profile.preferences) } public enum ChatType: String {