Fix crash when restoring state for timeline VC

This commit is contained in:
Shadowfacts 2023-02-25 16:44:36 -05:00
parent 38ac5858a9
commit e042754be1
1 changed files with 6 additions and 5 deletions

View File

@ -213,25 +213,26 @@ class UserActivityManager {
func handleShowTimeline(activity: NSUserActivity) {
guard let (timeline, positionInfo) = Self.getTimeline(from: activity) else { return }
let timelineVC: TimelineViewController
var timelineVC: TimelineViewController?
if let pinned = PinnedTimeline(timeline: timeline),
mastodonController.accountPreferences.pinnedTimelines.contains(pinned) {
context.select(route: .timelines)
context.popToRoot()
let pageController = context.topViewController as! TimelinesPageViewController
pageController.selectTimeline(pinned, animated: false)
timelineVC = pageController.currentViewController as! TimelineViewController
timelineVC = pageController.currentViewController as? TimelineViewController
} else if case .list(let id) = timeline {
context.select(route: .list(id: id))
timelineVC = context.topViewController! as! TimelineViewController
timelineVC = context.topViewController as? TimelineViewController
} else {
context.select(route: .explore)
context.popToRoot()
timelineVC = TimelineViewController(for: timeline, mastodonController: mastodonController)
context.push(timelineVC)
context.push(timelineVC!)
}
if let positionInfo,
if let timelineVC,
let positionInfo,
context.isHandoff {
Task {
await timelineVC.restoreStateFromHandoff(statusIDs: positionInfo.statusIDs, centerStatusID: positionInfo.centerStatusID)