From ef56935228ecaee1c5162371f1976a4e3dc09fe8 Mon Sep 17 00:00:00 2001 From: Christophe Deschamps Date: Mon, 1 Jul 2024 09:35:40 +0200 Subject: [PATCH] Collect side menu account info on core thread --- Linphone/UI/Main/Fragments/SideMenuAccountRow.swift | 6 +++--- Linphone/UI/Main/Viewmodel/AccountModel.swift | 6 ++++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/Linphone/UI/Main/Fragments/SideMenuAccountRow.swift b/Linphone/UI/Main/Fragments/SideMenuAccountRow.swift index 32c3f9f5b..18a7e34da 100644 --- a/Linphone/UI/Main/Fragments/SideMenuAccountRow.swift +++ b/Linphone/UI/Main/Fragments/SideMenuAccountRow.swift @@ -28,14 +28,14 @@ struct SideMenuAccountRow: View { Avatar(contactAvatarModel: ContactAvatarModel(friend: nil, - name: model.account.displayName(), - address: model.account.params!.identityAddress!.asString(), + name: model.displayName, + address: model.address, withPresence: true), avatarSize: 45) .padding(.leading, 6) VStack { - Text(model.account.displayName()) + Text(model.displayName) .default_text_style_grey_400(styleSize: 14) .lineLimit(1) .frame(maxWidth: .infinity, alignment: .leading) diff --git a/Linphone/UI/Main/Viewmodel/AccountModel.swift b/Linphone/UI/Main/Viewmodel/AccountModel.swift index 29f1055fe..6ef1607b1 100644 --- a/Linphone/UI/Main/Viewmodel/AccountModel.swift +++ b/Linphone/UI/Main/Viewmodel/AccountModel.swift @@ -27,6 +27,8 @@ class AccountModel: ObservableObject { @Published var registrationStateAssociatedUIColor: Color = .clear @Published var notificationsCount: Int = 0 @Published var isDefaultAccount: Bool = false + @Published var displayName: String = "" + @Published var address: String = "" init(account: Account, corePublisher: CoreDelegatePublisher?) { self.account = account @@ -56,6 +58,8 @@ class AccountModel: ObservableObject { if let defaultAccount = account.core?.defaultAccount { isDefault = (defaultAccount == account) } + let displayName = account.displayName() + let address = account.params?.identityAddress?.asString() DispatchQueue.main.async { [self] in switch state { case .Cleared, .None: @@ -75,6 +79,8 @@ class AccountModel: ObservableObject { registrationStateAssociatedUIColor = .grayMain2c500 } isDefaultAccount = isDefault + self.displayName = displayName + address.map {self.address = $0} } }