Fix crash duplicate main status and crash when conversation context is preloaded

For expand thread cells, the main status needs to be the one above the selected cell
This commit is contained in:
Shadowfacts 2023-02-23 10:02:05 -05:00
parent 8deb502140
commit 2252b6d09e
1 changed files with 3 additions and 2 deletions

View File

@ -336,8 +336,9 @@ extension ConversationCollectionViewController: UICollectionViewDelegate {
selected(status: id, state: state.copy())
}
case .expandThread(childThreads: let childThreads, inline: _):
if case .status(id: _, node: let node, state: let state, _, _) = dataSource.itemIdentifier(for: IndexPath(row: indexPath.row - 1, section: indexPath.section)) {
let tree = ConversationTree(ancestors: buildNewAncestors(above: indexPath), mainStatus: node)
let indexPathBeforeExpandThread = IndexPath(row: indexPath.row - 1, section: indexPath.section)
if case .status(id: _, node: let node, state: let state, _, _) = dataSource.itemIdentifier(for: indexPathBeforeExpandThread) {
let tree = ConversationTree(ancestors: buildNewAncestors(above: indexPathBeforeExpandThread), mainStatus: node)
let conv = ConversationViewController(preloadedTree: tree, state: state.copy(), mastodonController: mastodonController)
conv.statusIDToScrollToOnLoad = childThreads.first!.status.id
conv.showStatusesAutomatically = showStatusesAutomatically