|
|
@ -3,6 +3,7 @@
|
|
|
|
final class ConversationTitleView : UIView {
|
|
|
|
final class ConversationTitleView : UIView {
|
|
|
|
private let thread: TSThread
|
|
|
|
private let thread: TSThread
|
|
|
|
private var currentStatus: Status? { didSet { updateSubtitleForCurrentStatus() } }
|
|
|
|
private var currentStatus: Status? { didSet { updateSubtitleForCurrentStatus() } }
|
|
|
|
|
|
|
|
private var handledMessageTimestamps: Set<NSNumber> = []
|
|
|
|
|
|
|
|
|
|
|
|
// MARK: Types
|
|
|
|
// MARK: Types
|
|
|
|
private enum Status : Int {
|
|
|
|
private enum Status : Int {
|
|
|
@ -112,6 +113,7 @@ final class ConversationTitleView : UIView {
|
|
|
|
@objc private func handleMessageSentNotification(_ notification: Notification) {
|
|
|
|
@objc private func handleMessageSentNotification(_ notification: Notification) {
|
|
|
|
guard let timestamp = notification.object as? NSNumber else { return }
|
|
|
|
guard let timestamp = notification.object as? NSNumber else { return }
|
|
|
|
setStatusIfNeeded(to: .messageSent, forMessageWithTimestamp: timestamp)
|
|
|
|
setStatusIfNeeded(to: .messageSent, forMessageWithTimestamp: timestamp)
|
|
|
|
|
|
|
|
handledMessageTimestamps.insert(timestamp)
|
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
|
|
|
|
self.clearStatusIfNeededForMessageWithTimestamp(timestamp)
|
|
|
|
self.clearStatusIfNeededForMessageWithTimestamp(timestamp)
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -123,6 +125,7 @@ final class ConversationTitleView : UIView {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private func setStatusIfNeeded(to status: Status, forMessageWithTimestamp timestamp: NSNumber) {
|
|
|
|
private func setStatusIfNeeded(to status: Status, forMessageWithTimestamp timestamp: NSNumber) {
|
|
|
|
|
|
|
|
guard !handledMessageTimestamps.contains(timestamp) else { return }
|
|
|
|
var uncheckedTargetInteraction: TSInteraction? = nil
|
|
|
|
var uncheckedTargetInteraction: TSInteraction? = nil
|
|
|
|
thread.enumerateInteractions { interaction in
|
|
|
|
thread.enumerateInteractions { interaction in
|
|
|
|
guard interaction.timestamp == timestamp.uint64Value else { return }
|
|
|
|
guard interaction.timestamp == timestamp.uint64Value else { return }
|
|
|
|