Fix crash when switching accounts

This commit is contained in:
Shadowfacts 2021-06-26 16:42:56 -04:00
parent dc1ea1bed9
commit b95819cada
1 changed files with 3 additions and 1 deletions

View File

@ -42,10 +42,12 @@ class TimelineTableViewController: DiffableTimelineLikeTableViewController<Timel
}
deinit {
guard let persistentContainer = mastodonController?.persistentContainer else { return }
guard let persistentContainer = mastodonController?.persistentContainer,
let dataSource = dataSource else { return }
// decrement reference counts of any statuses we still have
// if the app is currently being quit, this will not affect the persisted data because
// the persistent container would already have been saved in SceneDelegate.sceneDidEnterBackground(_:)
// todo: remove the whole reference count system
for case let .status(id: id, state: _) in dataSource.snapshot().itemIdentifiers {
persistentContainer.status(for: id)?.decrementReferenceCount()
}