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

account: follow daemon changes for profile updated

Change-Id: I4b2e064db732cf3f5606b2241a0d5d559891ba0b
parent 0374ad03
No related branches found
No related tags found
No related merge requests found
......@@ -91,11 +91,12 @@ static id <AccountAdapterDelegate> _delegate;
}));
confHandlers
.insert(exportable_callback<ConfigurationSignal::AccountAvatarReceived>([&](const std::string& account_id, const std::string& photo) {
.insert(exportable_callback<ConfigurationSignal::AccountProfileReceived>([&](const std::string& account_id, const std::string& displayName, const std::string& photo) {
if (AccountAdapter.delegate) {
NSString* accountId = [NSString stringWithUTF8String:account_id.c_str()];
NSString* avatarPhoto = [NSString stringWithUTF8String:photo.c_str()];
[AccountAdapter.delegate receivedAccountPhotoFor:accountId photo:avatarPhoto];
NSString* name = [NSString stringWithUTF8String:displayName.c_str()];
[AccountAdapter.delegate receivedAccountProfileFor:accountId displayName: name photo:avatarPhoto];
}
}));
confHandlers
......
......@@ -25,6 +25,6 @@
func knownDevicesChanged(for account: String, devices: [String: String])
func exportOnRingEnded(for account: String, state: Int, pin: String)
func deviceRevocationEnded(for account: String, state: Int, deviceId: String)
func receivedAccountPhoto(for account: String, photo: String)
func receivedAccountProfile(for account: String, displayName: String, photo: String)
func migrationEnded(for account: String, status: String)
}
......@@ -831,7 +831,7 @@ class AccountsService: AccountAdapterDelegate {
self.responseStream.onNext(event)
}
func receivedAccountPhoto(for account: String, photo: String) {
func receivedAccountProfile(for account: String, displayName: String, photo: String) {
do {
if try !self.dbManager.createDatabaseForAccount(accountId: account) {
return
......@@ -839,13 +839,16 @@ class AccountsService: AccountAdapterDelegate {
} catch {
return
}
let accountDetails = getAccountDetails(fromAccountId: account)
let displayName: String? = accountDetails.get(withConfigKeyModel: ConfigKeyModel(withKey: ConfigKey.displayName))
var name = displayName
if name.isEmpty {
let accountDetails = getAccountDetails(fromAccountId: account)
name = accountDetails.get(withConfigKeyModel: ConfigKeyModel(withKey: ConfigKey.displayName))
}
guard let accountToUpdate = self.getAccount(fromAccountId: account),
let accountURI = AccountModelHelper
.init(withAccount: accountToUpdate).uri else {return}
_ = self.dbManager.saveAccountProfile(alias: displayName, photo: photo, accountId: account, accountURI: accountURI)
_ = self.dbManager.saveAccountProfile(alias: name, photo: photo, accountId: account, accountURI: accountURI)
}
// MARK: Push Notifications
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment