mirror of
https://gitlab.linphone.org/BC/public/linphone-iphone.git
synced 2026-01-21 13:08:08 +00:00
Add presence delegate in ChatConversationViewSwift
Fix presence delegate not removed from Avatar class
This commit is contained in:
parent
cb9707a231
commit
4ec3d89d42
3 changed files with 27 additions and 5 deletions
|
|
@ -148,7 +148,8 @@ class ChatConversationTableViewSwift: UIViewController, UICollectionViewDataSour
|
|||
let isDisplayingBottomOfTable = collectionView.contentOffset.y <= 20
|
||||
|
||||
if ChatConversationTableViewModel.sharedModel.getNBMessages() < 4 {
|
||||
collectionView.reloadData()
|
||||
collectionView.reloadData()
|
||||
ChatConversationViewSwift.markAsRead(ChatConversationViewModel.sharedModel.chatRoom?.getCobject)
|
||||
} else if isDisplayingBottomOfTable {
|
||||
self.collectionView.scrollToItem(at: IndexPath(item: 1, section: 0), at: .top, animated: false)
|
||||
collectionView.reloadData()
|
||||
|
|
|
|||
|
|
@ -47,6 +47,9 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
|
|||
let loadingView = UIView()
|
||||
let loading = RotatingSpinner(color: VoipTheme.primary_color)
|
||||
let loadingText = StyledLabel(VoipTheme.chat_conversation_operation_in_progress_wait)
|
||||
|
||||
var friend: Friend? = nil
|
||||
var friendDelegate: FriendDelegate? = nil
|
||||
|
||||
var collectionViewMedia: UICollectionView = {
|
||||
let top_bar_height = 66.0
|
||||
|
|
@ -532,13 +535,13 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
|
|||
|
||||
|
||||
let participantFriend = participants?.first?.address?.contact()?.friend
|
||||
let friend = Friend.getSwiftObject(cObject: participantFriend!)
|
||||
friend = Friend.getSwiftObject(cObject: participantFriend!)
|
||||
|
||||
var presenceModel : PresenceModel?
|
||||
var hasPresence : Bool? = false
|
||||
|
||||
if friend.address?.asStringUriOnly() != nil {
|
||||
presenceModel = friend.getPresenceModelForUriOrTel(uriOrTel: (friend.address?.asStringUriOnly())!)
|
||||
if friend?.address?.asStringUriOnly() != nil {
|
||||
presenceModel = friend!.getPresenceModelForUriOrTel(uriOrTel: (friend?.address?.asStringUriOnly())!)
|
||||
hasPresence = presenceModel != nil && presenceModel!.basicStatus == PresenceBasicStatus.Open
|
||||
}
|
||||
|
||||
|
|
@ -569,6 +572,14 @@ class ChatConversationViewSwift: BackActionsNavigationView, PHPickerViewControll
|
|||
participantsGroupLabel.text = VoipTexts.chat_room_presence_last_seen_online + dateString;
|
||||
}
|
||||
}
|
||||
|
||||
friendDelegate = FriendDelegateStub(
|
||||
onPresenceReceived: { (linphoneFriend: Friend) -> Void in
|
||||
self.friend?.removeDelegate(delegate: self.friendDelegate!)
|
||||
self.updateParticipantLabel()
|
||||
}
|
||||
)
|
||||
friend?.addDelegate(delegate: friendDelegate!)
|
||||
|
||||
titleParticipants.isHidden = false
|
||||
}else{
|
||||
|
|
|
|||
|
|
@ -150,10 +150,20 @@ class Avatar : UIView {
|
|||
friend.append(Friend.getSwiftObject(cObject: (contactAddress.friend)!))
|
||||
let newFriendDelegate = FriendDelegateStub(
|
||||
onPresenceReceived: { (linphoneFriend: Friend) -> Void in
|
||||
print("onPresenceReceivedonPresenceReceived")
|
||||
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])
|
||||
|
||||
var i = 0
|
||||
self.friend.forEach { friendForEach in
|
||||
if friendForEach.address?.asStringUriOnly() == linphoneFriend.address?.asStringUriOnly() {
|
||||
self.friend[i].removeDelegate(delegate: self.friendDelegate[i])
|
||||
self.friendDelegate.remove(at: i)
|
||||
self.friend.remove(at: i)
|
||||
}
|
||||
i += 1;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue