Fix custom emojis in display namesnot showing in conversation main

statuses

Caused by the cell updating it's UI multiple times in quick succession.
As a workaround, prevent the main cell from being reloaded.
This commit is contained in:
Shadowfacts 2020-03-01 20:06:27 -05:00
parent 2cebb6bd7d
commit de02c73957
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 7 additions and 7 deletions

View File

@ -19,13 +19,7 @@ class ConversationTableViewController: EnhancedTableViewController {
let mainStatusID: String
let mainStatusState: StatusState
var statuses: [(id: String, state: StatusState)] = [] {
didSet {
DispatchQueue.main.async {
self.tableView.reloadData()
}
}
}
var statuses: [(id: String, state: StatusState)] = []
var showStatusesAutomatically = false
var visibilityBarButtonItem: UIBarButtonItem!
@ -69,6 +63,12 @@ class ConversationTableViewController: EnhancedTableViewController {
self.statuses = parents.map { ($0.id, .unknown) } + self.statuses + context.descendants.map { ($0.id, .unknown) }
let indexPath = IndexPath(row: parents.count, section: 0)
DispatchQueue.main.async {
let ancestorsIndexPaths = (0..<parents.count).map { IndexPath(row: $0, section: 0) }
let descendantsIndexPaths = ((parents.count + 1)..<(self.statuses.count)).map { IndexPath(row: $0, section: 0) }
// despite its name, UITableView.RowAnimation.none actually uses the automatic animation, so we force-disable it
UIView.performWithoutAnimation {
self.tableView.insertRows(at: ancestorsIndexPaths + descendantsIndexPaths, with: .none)
}
self.tableView.scrollToRow(at: indexPath, at: .middle, animated: false)
}
}