Skip to content

Commit

Permalink
Fix crash on incompatible URL for Safari ViewController
Browse files Browse the repository at this point in the history
  • Loading branch information
XITRIX committed Jul 13, 2024
1 parent 44f9f2c commit 03fdce3
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions iTorrent/Screens/Rss/Details/RssDetailsViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,13 @@ class RssDetailsViewController<VM: RssDetailsViewModel>: BaseViewController<VM>
var webView: WKWebView!

override func loadView() {
let button = UIBarButtonItem(primaryAction: .init(image: .init(systemName: "safari"), handler: { [unowned self] _ in
let safariVC = BaseSafariViewController(url: viewModel.rssModel.link)
present(safariVC, animated: true)
}))
navigationItem.setRightBarButton(button, animated: false)
if UIApplication.shared.canOpenURL(viewModel.rssModel.link) {
let button = UIBarButtonItem(primaryAction: .init(image: .init(systemName: "safari"), handler: { [unowned self] _ in
let safariVC = BaseSafariViewController(url: viewModel.rssModel.link)
present(safariVC, animated: true)
}))
navigationItem.setRightBarButton(button, animated: false)
}

webView = WKWebView()
webView.backgroundColor = .secondarySystemBackground
Expand Down

0 comments on commit 03fdce3

Please sign in to comment.