From 5bf3c2d35d40703e276ae9d1670cfaeec07bc608 Mon Sep 17 00:00:00 2001 From: Morgan Pretty Date: Fri, 7 Oct 2022 18:46:13 +1100 Subject: [PATCH] Fixed a minor animation glitch --- Session/Conversations/ConversationVC.swift | 20 ++++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/Session/Conversations/ConversationVC.swift b/Session/Conversations/ConversationVC.swift index a84eb33ff..f19f9e58f 100644 --- a/Session/Conversations/ConversationVC.swift +++ b/Session/Conversations/ConversationVC.swift @@ -622,15 +622,19 @@ final class ConversationVC: BaseVC, ConversationSearchControllerDelegate, UITabl } private func handleInteractionUpdates(_ updatedData: [ConversationViewModel.SectionModel], initialLoad: Bool = false) { - // Ensure the first load or a load when returning from a child screen runs without animations (if - // we don't do this the cells will animate in from a frame of CGRect.zero or have a buggy transition) + // Ensure the first load or a load when returning from a child screen runs without + // animations (if we don't do this the cells will animate in from a frame of + // CGRect.zero or have a buggy transition) guard self.hasLoadedInitialInteractionData else { - self.hasLoadedInitialInteractionData = true - self.viewModel.updateInteractionData(updatedData) - - UIView.performWithoutAnimation { - self.tableView.reloadData() - self.performInitialScrollIfNeeded() + // Need to dispatch async to prevent this from causing glitches in the push animation + DispatchQueue.main.async { + self.hasLoadedInitialInteractionData = true + self.viewModel.updateInteractionData(updatedData) + + UIView.performWithoutAnimation { + self.tableView.reloadData() + self.performInitialScrollIfNeeded() + } } return }