Fix animation glitch

This commit is contained in:
Niels Andriesse 2021-08-05 10:11:20 +10:00
parent b8c4e6aa93
commit 50d17be43b
2 changed files with 14 additions and 15 deletions

View File

@ -351,11 +351,11 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
for update in conversationUpdate.updateItems! {
switch update.updateItemType {
case .delete:
self.messagesTableView.deleteRows(at: [ IndexPath(row: Int(update.oldIndex), section: 0) ], with: .fade)
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: .fade)
self.messagesTableView.insertRows(at: [ IndexPath(row: Int(update.newIndex), section: 0) ], with: .none)
if update.viewItem?.interaction is TSOutgoingMessage {
shouldScrollToBottom = true
} else {
@ -368,14 +368,16 @@ final class ConversationVC : BaseVC, ConversationViewModelDelegate, OWSConversat
}
}
}
messagesTableView.performBatchUpdates(batchUpdates) { _ in
if shouldScrollToBottom {
self.scrollToBottom(isAnimated: true)
UIView.performWithoutAnimation {
messagesTableView.performBatchUpdates(batchUpdates) { _ in
if shouldScrollToBottom {
self.scrollToBottom(isAnimated: false)
}
self.markAllAsRead()
}
if shouldScrollToBottom {
self.scrollToBottom(isAnimated: false)
}
self.markAllAsRead()
}
if shouldScrollToBottom {
self.scrollToBottom(isAnimated: false)
}
}

View File

@ -330,19 +330,16 @@ public final class MessageSender : NSObject {
if let tsMessage = TSOutgoingMessage.find(withTimestamp: message.sentTimestamp!) {
// Track the open group server message ID
tsMessage.openGroupServerMessageID = message.openGroupServerMessageID ?? 0
tsMessage.save(with: transaction)
// Mark the message as sent
var recipients = [ message.recipient! ]
if case .closedGroup(_) = destination, let threadID = message.threadID, // threadID should always be set at this point
let thread = TSGroupThread.fetch(uniqueId: threadID, transaction: transaction), thread.isClosedGroup {
recipients = thread.groupModel.groupMemberIds
}
if !tsMessage.wasSentToAnyRecipient {
recipients.forEach { recipient in
tsMessage.update(withSentRecipient: recipient, wasSentByUD: true, transaction: transaction)
}
MessageInvalidator.invalidate(tsMessage, with: transaction)
recipients.forEach { recipient in
tsMessage.update(withSentRecipient: recipient, wasSentByUD: true, transaction: transaction)
}
tsMessage.save(with: transaction)
// Start the disappearing messages timer if needed
OWSDisappearingMessagesJob.shared().startAnyExpiration(for: tsMessage, expirationStartedAt: NSDate.millisecondTimestamp(), transaction: transaction)
}