Fix crash when restoring state for timeline VC
This commit is contained in:
parent
38ac5858a9
commit
e042754be1
|
@ -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)
|
||||
|
|
Loading…
Reference in New Issue