Commit 778b262c authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Kateryna Kostiuk
Browse files

smartlist: display avatar image in for conversation recipient

- Loads the vcard and stores a reference to the image data of each of
  the conversation recipients when instantiating the conversation
  section's conversation view models.

- Points each cell's profile image to its item's image data (if any).

- Removes the default profile image.

Change-Id: I300fc0107f9353e8aadc15b2ad23604039ae4c59
Reviewed-by: Kateryna Kostiuk's avatarKateryna Kostiuk <>
parent c8af47bf
......@@ -68,9 +68,21 @@ class ConversationViewModel: ViewModel {
let contact = self.conversation.recipientRingId)
let contactRingId = self.conversation.recipientRingId
if let contact = contact {
let contact = contactRingId)
self.contactsService.loadVCard(forContactWithRingId: contactRingId)
.subscribe(onSuccess: { vCard in
guard let imageData = vCard.imageData else {
self.log.warning("vCard for ringId: \(contactRingId) has no image")
self.profileImageData = imageData
.disposed(by: self.disposeBag)
if let contact = contact {
self.contactsService.contactStatus.subscribe(onNext: { contact in
......@@ -136,6 +148,8 @@ class ConversationViewModel: ViewModel {
var userName = BehaviorSubject(value: "")
var profileImageData: Data?
var inviteButtonIsAvailable = BehaviorSubject(value: true)
var contactPresence = BehaviorSubject(value: false)
......@@ -15,10 +15,10 @@
<rect key="frame" x="0.0" y="0.0" width="358" height="76"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<tableViewCellContentView key="contentView" opaque="NO" clipsSubviews="YES" multipleTouchEnabled="YES" contentMode="center" tableViewCell="KGk-i7-Jjw" id="H2p-sc-9uM">
<rect key="frame" x="0.0" y="0.0" width="358" height="76"/>
<rect key="frame" x="0.0" y="0.0" width="358" height="75.5"/>
<autoresizingMask key="autoresizingMask"/>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_contact_picture" translatesAutoresizingMaskIntoConstraints="NO" id="pFB-Jn-TNP">
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="pFB-Jn-TNP">
<rect key="frame" x="16" y="18" width="40" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
......@@ -140,7 +140,4 @@
<point key="canvasLocation" x="70" y="-92"/>
<image name="ic_contact_picture" width="128" height="128"/>
......@@ -153,6 +153,16 @@ class SmartlistViewController: UIViewController, StoryboardBased, ViewModelBased
.disposed(by: self.disposeBag)
// Set image if any
cell.fallbackAvatar.isHidden = false
cell.profileImage.image = nil
if let imageData = item.profileImageData {
if let image = UIImage(data: imageData) {
cell.profileImage.image = image
cell.fallbackAvatar.isHidden = true
cell.newMessagesLabel.text = item.unreadMessages
cell.lastMessageDateLabel.text = item.lastMessageReceivedDate
cell.newMessagesIndicator.isHidden = item.hideNewMessagesLabel
Supports Markdown
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