mirror of
https://github.com/wahyd4/Yep.git
synced 2026-08-15 15:55:59 +10:00
deleteMessageAction
This commit is contained in:
@@ -2095,6 +2095,18 @@ extension ConversationViewController: UICollectionViewDataSource, UICollectionVi
|
||||
}
|
||||
}, collectionView: collectionView, indexPath: indexPath)
|
||||
|
||||
cell.deleteMessageAction = { [weak self] in
|
||||
dispatch_async(dispatch_get_main_queue()) {
|
||||
if let strongSelf = self, realm = message.realm {
|
||||
strongSelf.displayedMessagesRange.length -= 1
|
||||
realm.write {
|
||||
realm.delete(message)
|
||||
}
|
||||
strongSelf.conversationCollectionView.deleteItemsAtIndexPaths([indexPath])
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return cell
|
||||
}
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ class ChatRightTextCell: ChatRightBaseCell {
|
||||
@IBOutlet weak var textContentTextViewLeadingConstraint: NSLayoutConstraint!
|
||||
@IBOutlet weak var textContentTextViewWidthConstraint: NSLayoutConstraint!
|
||||
|
||||
var deleteMessageAction: (() -> Void)?
|
||||
typealias MediaTapAction = () -> Void
|
||||
var mediaTapAction: MediaTapAction?
|
||||
|
||||
@@ -43,8 +44,9 @@ class ChatRightTextCell: ChatRightBaseCell {
|
||||
]
|
||||
|
||||
textContentTextView.deleteEnabled = true
|
||||
textContentTextView.deleteAction = {
|
||||
textContentTextView.deleteAction = { [weak self] in
|
||||
println("delete text message?")
|
||||
self?.deleteMessageAction?()
|
||||
}
|
||||
|
||||
let longPress = UILongPressGestureRecognizer(target: self, action: "handleLongPress:")
|
||||
|
||||
Reference in New Issue
Block a user