Fix instance public timelines crashing

The instance timeline controller needs to store a strong reference to
the instance-specific MastodonController since the timeline VC only
holds a weak reference, and unlike normal screens, the scene session
doesn't hold onto the MastodonController for other instances.
This commit is contained in:
Shadowfacts 2020-01-20 11:18:55 -05:00
parent 3aa5aa1bc0
commit c99a724bf3
Signed by: shadowfacts
GPG Key ID: 94A5AB95422746E5
1 changed files with 4 additions and 2 deletions

View File

@ -18,6 +18,7 @@ class InstanceTimelineViewController: TimelineTableViewController {
weak var delegate: InstanceTimelineViewControllerDelegate?
let instanceURL: URL
let instanceMastodonController: MastodonController
var toggleSaveButton: UIBarButtonItem!
var toggleSaveButtonTitle: String {
@ -31,9 +32,10 @@ class InstanceTimelineViewController: TimelineTableViewController {
init(for url: URL) {
self.instanceURL = url
let mastodonController = MastodonController(instanceURL: url)
// the timeline VC only stores a weak reference to it, so we need to store a strong reference to make sure it's not released immediately
instanceMastodonController = MastodonController(instanceURL: url)
super.init(for: .instance(instanceURL: url), mastodonController: mastodonController)
super.init(for: .instance(instanceURL: url), mastodonController: instanceMastodonController)
}
required init?(coder aDecoder: NSCoder) {