Skip to content
Snippets Groups Projects
Commit bf4354d9 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk
Browse files

profile: use new API

Change-Id: I754836e4b73bfdb2181dc21879e54a2a753b688a
parent 2be718cc
No related branches found
No related tags found
No related merge requests found
......@@ -89,5 +89,8 @@
destinationPath:(NSString *)destinationPath
scheme:(NSString *)scheme
password:(NSString *)password;
-(void)updateProfile:(NSString *)accountId
displayName:(NSString *)displayName
avatar:(NSString *)avatar;
@end
......@@ -225,6 +225,14 @@ static id <AccountAdapterDelegate> _delegate;
std::string([newPassword UTF8String]));
}
-(void)updateProfile:(NSString *)accountId
displayName:(NSString *)displayName
avatar:(NSString *)avatar {
updateProfile(std::string([accountId UTF8String]),
std::string([displayName UTF8String]),
std::string([avatar UTF8String]), 1);
}
-(void)setAccountsActive:(BOOL) active {
auto accounts = getAccountList();
for(auto account: accounts) {
......
......@@ -42,18 +42,18 @@ class EditProfileVM: ObservableObject, AvatarViewDataModel {
}
func updateProfile() {
var photo: String?
if let image = self.profileImage?.fixOrientation(),
let imageData = image.convertToData(ofMaxSize: 40000) {
photo = imageData.base64EncodedString()
// Run on a background thread
Task {
var photo: String?
if let image = self.profileImage?.fixOrientation(),
let imageData = image.convertToData(ofMaxSize: 40000) {
photo = imageData.base64EncodedString()
}
let avatar: String = photo ?? ""
await self.accountService.updateProfile(accountId: self.account.id, displayName: self.profileName, avatar: avatar)
}
guard let details = self.account.details else { return }
details.set(withConfigKeyModel: ConfigKeyModel(withKey: ConfigKey.displayName), withValue: self.profileName)
account.details = details
self.accountService.setAccountDetails(forAccountId: account.id, withDetails: details)
let accountUri = AccountModelHelper.init(withAccount: account).uri ?? ""
self.profileService.updateAccountProfile(accountId: account.id,
alias: self.profileName,
photo: photo, accountURI: accountUri)
}
}
......@@ -229,21 +229,22 @@ extension WelcomeVM {
}
private func saveProfile(accountId: String) {
guard let account = self.accountService.getAccount(fromAccountId: accountId) else {
return
}
let photo = convertProfileImageToBase64()
// Run on a background thread
Task {
guard let account = self.accountService.getAccount(fromAccountId: accountId) else {
return
}
let photo = convertProfileImageToBase64()
if photo == nil && profileName.isEmpty {
// No changes for profile
return
}
if photo == nil && profileName.isEmpty {
// No changes for profile
return
}
let accountURI = AccountModelHelper(withAccount: account).uri ?? ""
profileService.updateAccountProfile(accountId: accountId,
alias: profileName,
photo: photo,
accountURI: accountURI)
let avatar: String = photo ?? ""
await self.accountService.updateProfile(accountId: account.id, displayName: self.profileName, avatar: avatar)
}
}
private func convertProfileImageToBase64() -> String? {
......
......@@ -382,6 +382,10 @@ 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)
}
/**
Gathers all the initial default details contained by any accounts, Ring or SIP.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment