diff --git a/Yep/ViewControllers/Conversation/ConversationViewController.swift b/Yep/ViewControllers/Conversation/ConversationViewController.swift index b00f681c..897ef8c9 100644 --- a/Yep/ViewControllers/Conversation/ConversationViewController.swift +++ b/Yep/ViewControllers/Conversation/ConversationViewController.swift @@ -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 } } diff --git a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift index f5ec730a..15641756 100644 --- a/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift +++ b/Yep/Views/Cells/ChatRightText/ChatRightTextCell.swift @@ -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:")