mobile: do not reset chat preferences on profile update (#1740)

* android: Do not reset prefs on profile update

* ios: Include prefs into Profile/LocalProfile
This commit is contained in:
Stanislav Dmitrenko
2023-01-13 18:57:54 +00:00
committed by GitHub
parent 2085dc5d60
commit 20cec4db11
2 changed files with 3 additions and 4 deletions

View File

@@ -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))

View File

@@ -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 {