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() let result = UILabel()
result.text = DateUtil.formatTimestamp(asTime: viewItem.interaction.timestampForUI()) result.text = DateUtil.formatTimestamp(asTime: viewItem.interaction.timestampForUI())
result.font = .systemFont(ofSize: Values.verySmallFontSize) result.font = .systemFont(ofSize: Values.verySmallFontSize)
result.textColor = Colors.text result.textColor = isLightMode ? .black : .white
return result return result
}() }()

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

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

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

Loading…
Cancel
Save