Fixed infinite loops introduced by the last change >_>

This commit is contained in:
Morgan Pretty 2023-07-03 12:33:26 +10:00
parent f45568644e
commit f976d85c27
2 changed files with 21 additions and 7 deletions

View File

@ -233,7 +233,15 @@ class MessageRequestsViewController: BaseVC, SessionUtilRespondingViewController
// in from a frame of CGRect.zero)
guard hasLoadedInitialThreadData else {
UIView.performWithoutAnimation {
handleThreadUpdates(updatedData, changeset: changeset, initialLoad: true)
// Hide the 'loading conversations' label (now that we have received conversation data)
loadingConversationsLabel.isHidden = true
// Show the empty state if there is no data
clearAllButton.isHidden = !(updatedData.first?.elements.isEmpty == false)
emptyStateLabel.isHidden = !clearAllButton.isHidden
// Update the content
viewModel.updateThreadData(updatedData)
tableView.reloadData()
hasLoadedInitialThreadData = true
}

View File

@ -224,22 +224,28 @@ class SessionTableViewController<NavItemId: Equatable, Section: SessionTableSect
changeset: StagedChangeset<[SectionModel]>,
initialLoad: Bool = false
) {
// Determine if we have any items for the empty state
let itemCount: Int = updatedData
.map { $0.elements.count }
.reduce(0, +)
// Ensure the first load runs without animations (if we don't do this the cells will animate
// in from a frame of CGRect.zero)
guard hasLoadedInitialTableData else {
UIView.performWithoutAnimation {
handleDataUpdates(updatedData, changeset: changeset, initialLoad: true)
// Update the empty state
emptyStateLabel.isHidden = (itemCount > 0)
// Update the content
viewModel.updateTableData(updatedData)
tableView.reloadData()
hasLoadedInitialTableData = true
}
return
}
// Show the empty state if there is no data
let itemCount: Int = updatedData
.map { $0.elements.count }
.reduce(0, +)
emptyStateLabel.isHidden = (itemCount > 0)
// Update the empty state
self.emptyStateLabel.isHidden = (itemCount > 0)
CATransaction.begin()
CATransaction.setCompletionBlock { [weak self] in