Fix addDelegate crash in Avatar class (Check if presenceModel is not nil)

This commit is contained in:
Benoit Martins 2023-06-14 12:06:27 +02:00 committed by benoit.martins
parent 2e0fd1f898
commit 989471fca2

View file

@ -152,7 +152,9 @@ class Avatar : UIView {
onPresenceReceived: { (linphoneFriend: Friend) -> Void in
if (linphoneFriend.address?.asStringUriOnly()) != nil {
let presenceModel = linphoneFriend.getPresenceModelForUriOrTel(uriOrTel: (linphoneFriend.address?.asStringUriOnly())!)
NotificationCenter.default.post(name: Notification.Name("LinphoneFriendPresenceUpdate"), object: nil, userInfo: ["friend": linphoneFriend.address?.asStringUriOnly() ?? "", "isOnline": presenceModel!.consolidatedPresence.rawValue == LinphoneConsolidatedPresenceOnline.rawValue])
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])
}
}
}
)