mirror of
https://github.com/metabolist/metatext.git
synced 2025-01-18 09:25:25 +00:00
Don't send non-HTTP URLs to SFSafariViewController
This commit is contained in:
parent
a21e597339
commit
c50a77ddd0
3 changed files with 14 additions and 2 deletions
|
@ -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 }
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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) }
|
||||
|
|
Loading…
Reference in a new issue