From de946be0082620774b884bbd108102c2106e277f Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Fri, 10 Nov 2023 14:20:33 -0500 Subject: [PATCH] Fix crash if ContentTextView asked for context menu config w/o mastodon controller --- Tusker/Views/ContentTextView.swift | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/Tusker/Views/ContentTextView.swift b/Tusker/Views/ContentTextView.swift index 75b93de9..c736f739 100644 --- a/Tusker/Views/ContentTextView.swift +++ b/Tusker/Views/ContentTextView.swift @@ -207,10 +207,12 @@ class ContentTextView: LinkTextView, BaseEmojiLabel { func getViewController(forLink url: URL, inRange range: NSRange) -> UIViewController? { let text = (self.text as NSString).substring(with: range) - if let mention = getMention(for: url, text: text) { - return ProfileViewController(accountID: mention.id, mastodonController: mastodonController!) - } else if let tag = getHashtag(for: url, text: text) { - return HashtagTimelineViewController(for: tag, mastodonController: mastodonController!) + if let mention = getMention(for: url, text: text), + let mastodonController { + return ProfileViewController(accountID: mention.id, mastodonController: mastodonController) + } else if let tag = getHashtag(for: url, text: text), + let mastodonController { + return HashtagTimelineViewController(for: tag, mastodonController: mastodonController) } else if url.scheme == "https" || url.scheme == "http" { let vc = SFSafariViewController(url: url) vc.preferredControlTintColor = Preferences.shared.accentColor.color