Commit 85f3ac2a authored by Andreas Traczyk's avatar Andreas Traczyk Committed by Kateryna Kostiuk

contact requests: keep vcard data updated and hide fallback avatars when image exists

- Updates existing contactRequest's vcard and reception timestamp up to date.
- Removes the use of the original fallback avatar image.
- Hides the fallback avatar when image data is present while loading the contact requests.

Change-Id: If3048c9e496a437ee070b14438b55e48aebf3785
Reviewed-by: Kateryna Kostiuk's avatarKateryna Kostiuk <kateryna.kostiuk@savoirfairelinux.com>
parent 3b382a32
......@@ -18,7 +18,21 @@
<rect key="frame" x="0.0" y="0.0" width="470" height="72"/>
<autoresizingMask key="autoresizingMask"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="ic_contact_picture" translatesAutoresizingMaskIntoConstraints="NO" id="xS9-Kd-lrg">
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="R" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wjc-Nn-INi" userLabel="Fallback Avatar">
<rect key="frame" x="16" y="16" width="40" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="roundedCorners" value="YES"/>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="20"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleToFill" horizontalHuggingPriority="251" verticalHuggingPriority="251" translatesAutoresizingMaskIntoConstraints="NO" id="xS9-Kd-lrg">
<rect key="frame" x="16" y="16" width="40" height="40"/>
<color key="backgroundColor" white="0.0" alpha="0.0" colorSpace="calibratedWhite"/>
<constraints>
......@@ -104,20 +118,6 @@
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="R" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Wjc-Nn-INi" userLabel="Fallback Avatar">
<rect key="frame" x="16" y="16" width="40" height="40"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<color key="backgroundColor" red="1" green="0.5" blue="0.0" alpha="1" colorSpace="calibratedRGB"/>
<fontDescription key="fontDescription" type="system" weight="semibold" pointSize="17"/>
<color key="textColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
<userDefinedRuntimeAttributes>
<userDefinedRuntimeAttribute type="boolean" keyPath="roundedCorners" value="YES"/>
<userDefinedRuntimeAttribute type="number" keyPath="cornerRadius">
<real key="value" value="20"/>
</userDefinedRuntimeAttribute>
</userDefinedRuntimeAttributes>
</label>
</subviews>
<constraints>
<constraint firstItem="Pni-bm-rkr" firstAttribute="top" secondItem="Dla-OF-biH" secondAttribute="bottom" constant="8" id="0jS-6Q-w8N"/>
......@@ -147,7 +147,4 @@
<point key="canvasLocation" x="177" y="-50"/>
</tableViewCell>
</objects>
<resources>
<image name="ic_contact_picture" width="128" height="128"/>
</resources>
</document>
......@@ -96,6 +96,9 @@ class ContactRequestsViewController: UIViewController, StoryboardBased, ViewMode
if let imageData = item.profileImageData {
cell.profileImageView.image = UIImage(data: imageData)
if !imageData.isEmpty {
cell.fallbackAvatar.isHidden = true
}
}
//Accept button
......
......@@ -25,8 +25,8 @@ class ContactRequestModel {
let ringId: String
let accountId: String
let vCard: CNContact?
let receivedDate: Date
var vCard: CNContact?
var receivedDate: Date
enum ContactRequestKey: String {
case from
......
......@@ -192,6 +192,13 @@ extension ContactsService: ContactsAdapterDelegate {
receivedDate: receivedDate,
accountId: accountId)
self.contactRequests.value.append(contactRequest)
} else {
// If the contact request already exists, update it's relevant data
if let contactRequest = self.contactRequest(withRingId: senderAccount) {
let vCards = try CNContactVCardSerialization.contacts(with: payload)
contactRequest.vCard = vCards.first
contactRequest.receivedDate = receivedDate
}
}
log.debug("Incoming trust request received from :\(senderAccount)")
......
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