From 789bc180ecc1be7857c3e35c3955b43d3a41775b Mon Sep 17 00:00:00 2001 From: Kateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com> Date: Thu, 28 Nov 2024 15:11:13 -0500 Subject: [PATCH] misc: fix new API usage for profile Change-Id: I5d6731296e80ff5985540b5e22ab92424c7164b2 --- Ring/Ring/Bridging/AccountCreation/AccountAdapter.h | 4 +++- Ring/Ring/Bridging/AccountCreation/AccountAdapter.mm | 7 ++++--- Ring/Ring/Features/Settings/Me/AccountSummaryView.swift | 7 +------ Ring/Ring/Features/Settings/Me/EditProfileVM.swift | 2 +- Ring/Ring/Features/Settings/Me/EditProfileView.swift | 9 ++++++--- Ring/Ring/Features/Walkthrough/Models/WelcomeVM.swift | 2 +- Ring/Ring/Services/AccountsService.swift | 4 ++-- 7 files changed, 18 insertions(+), 17 deletions(-) diff --git a/Ring/Ring/Bridging/AccountCreation/AccountAdapter.h b/Ring/Ring/Bridging/AccountCreation/AccountAdapter.h index 9ff185b34..4109aefc4 100644 --- a/Ring/Ring/Bridging/AccountCreation/AccountAdapter.h +++ b/Ring/Ring/Bridging/AccountCreation/AccountAdapter.h @@ -91,6 +91,8 @@ password:(NSString *)password; -(void)updateProfile:(NSString *)accountId displayName:(NSString *)displayName - avatar:(NSString *)avatar; + avatar:(NSString *)avatar + fileType:(NSString *)fileType; + @end diff --git a/Ring/Ring/Bridging/AccountCreation/AccountAdapter.mm b/Ring/Ring/Bridging/AccountCreation/AccountAdapter.mm index cbfb8e091..ee0c93476 100644 --- a/Ring/Ring/Bridging/AccountCreation/AccountAdapter.mm +++ b/Ring/Ring/Bridging/AccountCreation/AccountAdapter.mm @@ -227,11 +227,12 @@ static id <AccountAdapterDelegate> _delegate; -(void)updateProfile:(NSString *)accountId displayName:(NSString *)displayName - avatar:(NSString *)avatar { + avatar:(NSString *)avatar + fileType:(NSString *)fileType { updateProfile(std::string([accountId UTF8String]), std::string([displayName UTF8String]), - "", - std::string([avatar UTF8String]), 1); + std::string([avatar UTF8String]), + std::string([fileType UTF8String]), 1); } -(void)setAccountsActive:(BOOL) active { diff --git a/Ring/Ring/Features/Settings/Me/AccountSummaryView.swift b/Ring/Ring/Features/Settings/Me/AccountSummaryView.swift index 254a71660..e08e110f4 100644 --- a/Ring/Ring/Features/Settings/Me/AccountSummaryView.swift +++ b/Ring/Ring/Features/Settings/Me/AccountSummaryView.swift @@ -144,12 +144,7 @@ struct AccountSummaryView: View { showEditPrpofile = true } .sheet(isPresented: $showEditPrpofile) { - EditProfileView(injectionBag: model.injectionBag, - account: model.account, - profileImage: model.profileImage, - profileName: model.profileName, - username: model.username, - avatarSize: model.avatarSize, + EditProfileView(accountModel: model, isPresented: $showEditPrpofile) } } diff --git a/Ring/Ring/Features/Settings/Me/EditProfileVM.swift b/Ring/Ring/Features/Settings/Me/EditProfileVM.swift index a103f2e67..41bfb612c 100644 --- a/Ring/Ring/Features/Settings/Me/EditProfileVM.swift +++ b/Ring/Ring/Features/Settings/Me/EditProfileVM.swift @@ -53,7 +53,7 @@ class EditProfileVM: ObservableObject, AvatarViewDataModel { let avatar: String = photo ?? "" - await self.accountService.updateProfile(accountId: self.account.id, displayName: self.profileName, avatar: avatar) + await self.accountService.updateProfile(accountId: self.account.id, displayName: self.profileName, avatar: avatar, fileType: "JPEG") } } } diff --git a/Ring/Ring/Features/Settings/Me/EditProfileView.swift b/Ring/Ring/Features/Settings/Me/EditProfileView.swift index f829032fd..1347bef5f 100644 --- a/Ring/Ring/Features/Settings/Me/EditProfileView.swift +++ b/Ring/Ring/Features/Settings/Me/EditProfileView.swift @@ -24,11 +24,13 @@ struct EditProfileView: View { @Binding var isPresented: Bool @StateObject var model: EditProfileVM var avatarSize: CGFloat + @ObservedObject var accountModel: AccountSummaryVM - init(injectionBag: InjectionBag, account: AccountModel, profileImage: UIImage?, profileName: String, username: String?, avatarSize: CGFloat, isPresented: Binding<Bool>) { - _model = StateObject(wrappedValue: EditProfileVM(injectionBag: injectionBag, account: account, profileImage: profileImage, profileName: profileName, username: username)) + init(accountModel: AccountSummaryVM, isPresented: Binding<Bool>) { + _model = StateObject(wrappedValue: EditProfileVM(injectionBag: accountModel.injectionBag, account: accountModel.account, profileImage: accountModel.profileImage, profileName: accountModel.profileName, username: accountModel.username)) + self.accountModel = accountModel _isPresented = isPresented - self.avatarSize = avatarSize + self.avatarSize = accountModel.avatarSize } @SwiftUI.State private var profileImage: Image? = Image(systemName: "person.circle") @@ -100,6 +102,7 @@ struct EditProfileView: View { }), trailing: Button(action: { model.updateProfile() + accountModel.profileImage = model.profileImage isPresented = false }, label: { Text(L10n.Global.save) diff --git a/Ring/Ring/Features/Walkthrough/Models/WelcomeVM.swift b/Ring/Ring/Features/Walkthrough/Models/WelcomeVM.swift index 93f7181d4..d52559e07 100644 --- a/Ring/Ring/Features/Walkthrough/Models/WelcomeVM.swift +++ b/Ring/Ring/Features/Walkthrough/Models/WelcomeVM.swift @@ -243,7 +243,7 @@ extension WelcomeVM { let avatar: String = photo ?? "" - await self.accountService.updateProfile(accountId: account.id, displayName: self.profileName, avatar: avatar) + await self.accountService.updateProfile(accountId: account.id, displayName: self.profileName, avatar: avatar, fileType: "JPEG") } } diff --git a/Ring/Ring/Services/AccountsService.swift b/Ring/Ring/Services/AccountsService.swift index 94d3f215f..a7ea0a809 100644 --- a/Ring/Ring/Services/AccountsService.swift +++ b/Ring/Ring/Services/AccountsService.swift @@ -382,8 +382,8 @@ class AccountsService: AccountAdapterDelegate { accountAdapter.revokeDevice(account, password: password, deviceId: deviceId) } - func updateProfile(accountId: String, displayName: String, avatar: String) async { - accountAdapter.updateProfile(accountId, displayName: displayName, avatar: avatar) + func updateProfile(accountId: String, displayName: String, avatar: String, fileType: String) async { + accountAdapter.updateProfile(accountId, displayName: displayName, avatar: avatar, fileType: fileType) } /** -- GitLab