Fix crash if ContentTextView asked for context menu config w/o mastodon controller

This commit is contained in:
Shadowfacts 2023-11-10 14:20:33 -05:00
parent b40d815274
commit de946be008
1 changed files with 6 additions and 4 deletions

View File

@ -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