Don't send non-HTTP URLs to SFSafariViewController

This commit is contained in:
Justin Mazzocchi 2021-02-08 12:36:54 -08:00
parent a21e597339
commit c50a77ddd0
No known key found for this signature in database
GPG key ID: E223E6937AAFB01C
3 changed files with 14 additions and 2 deletions

View file

@ -2,6 +2,14 @@
import Foundation
extension URL {
var isHTTPURL: Bool {
guard let scheme = scheme else { return false }
return scheme == "http" || scheme == "https"
}
}
extension URL: Identifiable {
public var id: String { absoluteString }
}

View file

@ -451,7 +451,7 @@ private extension TableViewController {
func open(url: URL) {
func openWithRegardToBrowserSetting(url: URL) {
if viewModel.identityContext.appPreferences.openLinksInDefaultBrowser {
if viewModel.identityContext.appPreferences.openLinksInDefaultBrowser || !url.isHTTPURL {
UIApplication.shared.open(url)
} else {
present(SFSafariViewController(url: url), animated: true)

View file

@ -54,7 +54,11 @@ public class CollectionItemsViewModel: ObservableObject {
markerScrollPositionItemId = identityContext.service.getLocalLastReadId(timeline: timeline)
}
lastReadId.compactMap { $0 }
lastReadId
.filter { _ in
identityContext.appPreferences.positionBehavior(timeline: timeline) == .localRememberPosition
}
.compactMap { $0 }
.removeDuplicates()
.debounce(for: .seconds(Self.lastReadIdDebounceInterval), scheduler: DispatchQueue.global())
.flatMap { identityContext.service.setLocalLastReadId($0, timeline: timeline) }