From cfc69627e5d9fdfa1c1f2391fda5de62c615fea9 Mon Sep 17 00:00:00 2001 From: Shadowfacts Date: Tue, 18 Apr 2023 10:19:53 -0400 Subject: [PATCH] Fix crash when creating menu actions for status w/o URL --- Tusker/Screens/Utilities/Previewing.swift | 19 ++++++++++++------- 1 file changed, 12 insertions(+), 7 deletions(-) diff --git a/Tusker/Screens/Utilities/Previewing.swift b/Tusker/Screens/Utilities/Previewing.swift index b72d555f..e10bed66 100644 --- a/Tusker/Screens/Utilities/Previewing.swift +++ b/Tusker/Screens/Utilities/Previewing.swift @@ -176,13 +176,18 @@ extension MenuActionProvider { guard let accountID = mastodonController.accountInfo?.id, let account = mastodonController.account else { // user is logged out - return [ - openInSafariAction(url: status.url!), - createAction(identifier: "share", title: "Share", systemImageName: "square.and.arrow.up", handler: { [weak self] (_) in - guard let self = self else { return } - self.navigationDelegate?.showMoreOptions(forStatus: status.id, source: source) - }) - ] + // i don't know why exactly a status wouldn't have a url, but apparently it happens, so: + if let url = status.url { + return [ + openInSafariAction(url: url), + createAction(identifier: "share", title: "Share", systemImageName: "square.and.arrow.up", handler: { [weak self] (_) in + guard let self = self else { return } + self.navigationDelegate?.showMoreOptions(forStatus: status.id, source: source) + }), + ] + } else { + return [] + } } let bookmarked = status.bookmarked ?? false