Check if contactAddress.friend is not nil

This commit is contained in:
Benoit Martins 2023-07-12 17:00:14 +02:00
parent 32f264d8e4
commit 91be4e530b

View file

@ -147,19 +147,21 @@ class Avatar : UIView {
}
}
if delegatePresence == false {
friend.append(Friend.getSwiftObject(cObject: (contactAddress.friend)!))
let newFriendDelegate = FriendDelegateStub(
onPresenceReceived: { (linphoneFriend: Friend) -> Void in
if (linphoneFriend.address?.asStringUriOnly()) != nil {
let presenceModel = linphoneFriend.getPresenceModelForUriOrTel(uriOrTel: (linphoneFriend.address?.asStringUriOnly())!)
if(presenceModel != nil && presenceModel?.consolidatedPresence != nil){
NotificationCenter.default.post(name: Notification.Name("LinphoneFriendPresenceUpdate"), object: nil, userInfo: ["friend": linphoneFriend.address?.asStringUriOnly() ?? "", "isOnline": presenceModel!.consolidatedPresence.rawValue == LinphoneConsolidatedPresenceOnline.rawValue])
if contactAddress.friend != nil {
friend.append(Friend.getSwiftObject(cObject: (contactAddress.friend)!))
let newFriendDelegate = FriendDelegateStub(
onPresenceReceived: { (linphoneFriend: Friend) -> Void in
if (linphoneFriend.address?.asStringUriOnly()) != nil {
let presenceModel = linphoneFriend.getPresenceModelForUriOrTel(uriOrTel: (linphoneFriend.address?.asStringUriOnly())!)
if(presenceModel != nil && presenceModel?.consolidatedPresence != nil){
NotificationCenter.default.post(name: Notification.Name("LinphoneFriendPresenceUpdate"), object: nil, userInfo: ["friend": linphoneFriend.address?.asStringUriOnly() ?? "", "isOnline": presenceModel!.consolidatedPresence.rawValue == LinphoneConsolidatedPresenceOnline.rawValue])
}
}
}
}
)
friendDelegate.append(newFriendDelegate)
friend.last?.addDelegate(delegate: friendDelegate.last!)
}
)
friendDelegate.append(newFriendDelegate)
friend.last?.addDelegate(delegate: friendDelegate.last!)
}
}
}
@ -202,12 +204,8 @@ class Avatar : UIView {
let contactAddress = Address.getSwiftObject(cObject: address).contact()
var iconPresenceView = UIImageView()
if (contactAddress != nil) {
shared?.addDelegate(contactAddress: contactAddress!)
iconPresenceView = updatePresenceImage(contact: contactAddress!)
avatarWithPresence.addSubview(avatarImageWihtoutPresence)
avatarWithPresence.addSubview(iconPresenceView)
iconPresenceView.frame = CGRect(x: 36, y: 36, width: 14, height: 14)