Fix crash when creating menu actions for status w/o URL

This commit is contained in:
Shadowfacts 2023-04-18 10:19:53 -04:00
parent 160f48679b
commit cfc69627e5
1 changed files with 12 additions and 7 deletions

View File

@ -176,13 +176,18 @@ extension MenuActionProvider {
guard let accountID = mastodonController.accountInfo?.id, guard let accountID = mastodonController.accountInfo?.id,
let account = mastodonController.account else { let account = mastodonController.account else {
// user is logged out // user is logged out
// i don't know why exactly a status wouldn't have a url, but apparently it happens, so:
if let url = status.url {
return [ return [
openInSafariAction(url: status.url!), openInSafariAction(url: url),
createAction(identifier: "share", title: "Share", systemImageName: "square.and.arrow.up", handler: { [weak self] (_) in createAction(identifier: "share", title: "Share", systemImageName: "square.and.arrow.up", handler: { [weak self] (_) in
guard let self = self else { return } guard let self = self else { return }
self.navigationDelegate?.showMoreOptions(forStatus: status.id, source: source) self.navigationDelegate?.showMoreOptions(forStatus: status.id, source: source)
}) }),
] ]
} else {
return []
}
} }
let bookmarked = status.bookmarked ?? false let bookmarked = status.bookmarked ?? false