Make link previews tappable & mark sent messages as read

pull/347/head
Niels Andriesse 4 years ago
parent 8804b05ae6
commit 2fd1707cba

@ -22,7 +22,7 @@ final class ContextMenuVC : UIViewController {
let result = UILabel()
result.text = DateUtil.formatTimestamp(asTime: viewItem.interaction.timestampForUI())
result.font = .systemFont(ofSize: Values.verySmallFontSize)
result.textColor = Colors.text
result.textColor = isLightMode ? .black : .white
return result
}()

@ -56,8 +56,10 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
MessageSender.send(message, with: [], in: thread, using: transaction as! YapDatabaseReadWriteTransaction)
}
// TODO: Sent handling
self?.snInputView.text = ""
self?.snInputView.quoteDraftInfo = nil
guard let self = self else { return }
self.snInputView.text = ""
self.snInputView.quoteDraftInfo = nil
self.markAllAsRead()
// TODO: Reset mentions
})
}
@ -113,6 +115,9 @@ extension ConversationVC : InputViewDelegate, MessageCellDelegate, ContextMenuAc
guard let url = viewItem.attachmentStream?.originalMediaURL else { return }
let shareVC = UIActivityViewController(activityItems: [ url ], applicationActivities: nil)
navigationController!.present(shareVC, animated: true, completion: nil)
case .textOnlyMessage:
guard let preview = viewItem.linkPreview, let urlAsString = preview.urlString, let url = URL(string: urlAsString) else { return }
openURL(url)
default: break
}
}

@ -134,8 +134,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, UITableViewD
override func viewDidAppear(_ animated: Bool) {
super.viewDidAppear(animated)
guard let lastSortID = viewItems.last?.interaction.sortId else { return }
OWSReadReceiptManager.shared().markAsReadLocally(beforeSortId: lastSortID, thread: thread)
markAllAsRead()
}
override func viewDidDisappear(_ animated: Bool) {
@ -305,6 +304,11 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, UITableViewD
}
// MARK: General
func markAllAsRead() {
guard let lastSortID = viewItems.last?.interaction.sortId else { return }
OWSReadReceiptManager.shared().markAsReadLocally(beforeSortId: lastSortID, thread: thread)
}
func tableView(_ tableView: UITableView, estimatedHeightForRowAt indexPath: IndexPath) -> CGFloat {
return UITableView.automaticDimension
}

@ -34,7 +34,7 @@ final class LinkPreviewViewV2 : UIView {
guard let preview = viewItem.linkPreview else { return }
let hStackViewContainer = UIView()
hStackViewContainer.backgroundColor = .black
hStackViewContainer.backgroundColor = isDarkMode ? .black : UIColor.black.withAlphaComponent(0.06)
let hStackView = UIStackView()
hStackView.axis = .horizontal
@ -86,8 +86,4 @@ final class LinkPreviewViewV2 : UIView {
addSubview(vStackView)
vStackView.pin(to: self)
}
func handleLongPress() {
}
}

Loading…
Cancel
Save