Fix message status indicator bug
This commit is contained in:
parent
50d17be43b
commit
e311d2878f
|
@ -205,6 +205,7 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|||
notificationCenter.addObserver(self, selector: #selector(addOrRemoveBlockedBanner), name: NSNotification.Name(rawValue: kNSNotificationName_BlockListDidChange), object: nil)
|
||||
notificationCenter.addObserver(self, selector: #selector(handleGroupUpdatedNotification), name: .groupThreadUpdated, object: nil)
|
||||
notificationCenter.addObserver(self, selector: #selector(sendScreenshotNotificationIfNeeded), name: UIApplication.userDidTakeScreenshotNotification, object: nil)
|
||||
notificationCenter.addObserver(self, selector: #selector(handleMessageSentStatusChanged), name: .messageSentStatusDidChange, object: nil)
|
||||
// Mentions
|
||||
MentionsManager.populateUserPublicKeyCacheIfNeeded(for: thread.uniqueId!)
|
||||
// Draft
|
||||
|
@ -319,7 +320,6 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|||
baselineKeyboardHeight = newHeight
|
||||
self.messagesTableView.keyboardHeight = newHeight
|
||||
}
|
||||
let margin = (self.lastPageTop - self.messagesTableView.contentOffset.y)
|
||||
scrollButtonConstraint?.constant = -(newHeight + 16)
|
||||
let newContentOffsetY = max(self.messagesTableView.contentOffset.y + min(lastPageTop, 0) + newHeight - self.messagesTableView.keyboardHeight, 0.0)
|
||||
self.messagesTableView.contentOffset.y = newContentOffsetY
|
||||
|
@ -353,7 +353,6 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|||
case .delete:
|
||||
self.messagesTableView.deleteRows(at: [ IndexPath(row: Int(update.oldIndex), section: 0) ], with: .none)
|
||||
case .insert:
|
||||
print("[Test] INSERT")
|
||||
// Perform inserts before updates
|
||||
self.messagesTableView.insertRows(at: [ IndexPath(row: Int(update.newIndex), section: 0) ], with: .none)
|
||||
if update.viewItem?.interaction is TSOutgoingMessage {
|
||||
|
@ -362,7 +361,6 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|||
shouldScrollToBottom = self.isCloseToBottom
|
||||
}
|
||||
case .update:
|
||||
print("[Test] UPDATE")
|
||||
self.messagesTableView.reloadRows(at: [ IndexPath(row: Int(update.oldIndex), section: 0) ], with: .none)
|
||||
default: preconditionFailure()
|
||||
}
|
||||
|
@ -411,6 +409,24 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
|
|||
reloadInputViews()
|
||||
}
|
||||
|
||||
@objc private func handleMessageSentStatusChanged() {
|
||||
DispatchQueue.main.async {
|
||||
guard let indexPaths = self.messagesTableView.indexPathsForVisibleRows else { return }
|
||||
var indexPathsToReload: [IndexPath] = []
|
||||
for indexPath in indexPaths {
|
||||
guard let cell = self.messagesTableView.cellForRow(at: indexPath) as? VisibleMessageCell else { continue }
|
||||
let isLast = (indexPath.item == (self.messagesTableView.numberOfRows(inSection: 0) - 1))
|
||||
guard !isLast else { continue }
|
||||
if !cell.messageStatusImageView.isHidden {
|
||||
indexPathsToReload.append(indexPath)
|
||||
}
|
||||
}
|
||||
UIView.performWithoutAnimation {
|
||||
self.messagesTableView.reloadRows(at: indexPathsToReload, with: .none)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// MARK: General
|
||||
@objc func addOrRemoveBlockedBanner() {
|
||||
func detach() {
|
||||
|
|
|
@ -81,7 +81,7 @@ final class VisibleMessageCell : MessageCell, LinkPreviewViewDelegate {
|
|||
|
||||
private lazy var snContentView = UIView()
|
||||
|
||||
private lazy var messageStatusImageView: UIImageView = {
|
||||
internal lazy var messageStatusImageView: UIImageView = {
|
||||
let result = UIImageView()
|
||||
result.contentMode = .scaleAspectFit
|
||||
result.layer.cornerRadius = VisibleMessageCell.messageStatusImageViewSize / 2
|
||||
|
|
|
@ -340,6 +340,7 @@ public final class MessageSender : NSObject {
|
|||
tsMessage.update(withSentRecipient: recipient, wasSentByUD: true, transaction: transaction)
|
||||
}
|
||||
tsMessage.save(with: transaction)
|
||||
NotificationCenter.default.post(name: .messageSentStatusDidChange, object: nil, userInfo: nil)
|
||||
// Start the disappearing messages timer if needed
|
||||
OWSDisappearingMessagesJob.shared().startAnyExpiration(for: tsMessage, expirationStartedAt: NSDate.millisecondTimestamp(), transaction: transaction)
|
||||
}
|
||||
|
|
|
@ -3,10 +3,12 @@ public extension Notification.Name {
|
|||
|
||||
static let groupThreadUpdated = Notification.Name("groupThreadUpdated")
|
||||
static let muteSettingUpdated = Notification.Name("muteSettingUpdated")
|
||||
static let messageSentStatusDidChange = Notification.Name("messageSentStatusDidChange")
|
||||
}
|
||||
|
||||
@objc public extension NSNotification {
|
||||
|
||||
@objc static let groupThreadUpdated = Notification.Name.groupThreadUpdated.rawValue as NSString
|
||||
@objc static let muteSettingUpdated = Notification.Name.muteSettingUpdated.rawValue as NSString
|
||||
@objc static let messageSentStatusDidChange = Notification.Name.messageSentStatusDidChange.rawValue as NSString
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue