Commit bf018b15 authored by Kateryna Kostiuk's avatar Kateryna Kostiuk

UI: display avatar

Update avatar photo when contact request is accepted

Change-Id: I57deab3beece6ab9b8f6483fc1731d9283c1bd08
parent df2c6cdf
......@@ -120,6 +120,9 @@ class ContactsService {
event.addEventInput(.accountId, value: account.id)
event.addEventInput(.uri, value: contactRequest.ringId)
self.responseStream.onNext(event)
var data = [String: Any]()
data[ProfileNotificationsKeys.ringID.rawValue] = contactRequest.ringId
NotificationCenter.default.post(name: NSNotification.Name(ProfileNotifications.contactAdded.rawValue), object: nil, userInfo: data)
observable.on(.completed)
} else {
observable.on(.error(ContactServiceError.acceptTrustRequestFailed))
......
......@@ -25,6 +25,7 @@ import SwiftyBeaver
enum ProfileNotifications: String {
case messageReceived
case contactAdded
}
enum ProfileNotificationsKeys: String {
......@@ -55,6 +56,16 @@ class ProfilesService {
NotificationCenter.default.addObserver(self, selector: #selector(self.messageReceived(_:)),
name: NSNotification.Name(rawValue: ProfileNotifications.messageReceived.rawValue),
object: nil)
NotificationCenter.default.addObserver(self, selector: #selector(self.contactAdded(_:)),
name: NSNotification.Name(rawValue: ProfileNotifications.contactAdded.rawValue),
object: nil)
}
@objc private func contactAdded(_ notification: NSNotification) {
guard let ringId = notification.userInfo?[ProfileNotificationsKeys.ringID.rawValue] as? String else {
return
}
self.updateProfileFor(ringId: ringId, createIfNotexists: false)
}
// swiftlint:disable cyclomatic_complexity
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment