Skip to content

Commit

Permalink
Try to fix another TOC crash
Browse files Browse the repository at this point in the history
  • Loading branch information
tonisevener committed Mar 22, 2023
1 parent aa7ab4f commit 108d75e
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions Wikipedia/Code/ArticleTableOfContentsDisplayController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,14 @@ class ArticleTableOfContentsDisplayController: Themeable {
self.viewController.isVisible = true
self.selectAndScroll(to: sectionId, animated: false)

// Attempt to fix TOC presentation crashes.
guard !self.viewController.isBeingPresented && self.delegate !== self.viewController else {
// Attempts to fix TOC presentation crashes. Error message target is in comments.
guard
!self.viewController.isBeingPresented && // Application tried to present modally a view controller %@ that is already being presented by %@.
self.delegate?.presentedViewController == nil && // Attempt to present %@ on %@ (from %@) which is already presenting %@.
self.delegate !== self.viewController && // Application tried to present modal view controller on itself.
self.viewController.parent == nil && // Application tried to present modally a view controller %@ that has a parent view controller %@.
(self.delegate?.isViewLoaded ?? false) // Attempt to present %@ on %@ (from %@) whose view is not in the window hierarchy.
else {
return
}

Expand Down Expand Up @@ -180,5 +186,4 @@ class ArticleTableOfContentsDisplayController: Themeable {
viewController.selectItem(at: index)
viewController.scrollToItem(at: index)
}

}

0 comments on commit 108d75e

Please sign in to comment.