mirror of
https://github.com/metabolist/metatext.git
synced 2025-06-05 23:58:48 +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
|
import Foundation
|
||||||
|
|
||||||
|
extension URL {
|
||||||
|
var isHTTPURL: Bool {
|
||||||
|
guard let scheme = scheme else { return false }
|
||||||
|
|
||||||
|
return scheme == "http" || scheme == "https"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extension URL: Identifiable {
|
extension URL: Identifiable {
|
||||||
public var id: String { absoluteString }
|
public var id: String { absoluteString }
|
||||||
}
|
}
|
||||||
|
|
|
@ -451,7 +451,7 @@ private extension TableViewController {
|
||||||
|
|
||||||
func open(url: URL) {
|
func open(url: URL) {
|
||||||
func openWithRegardToBrowserSetting(url: URL) {
|
func openWithRegardToBrowserSetting(url: URL) {
|
||||||
if viewModel.identityContext.appPreferences.openLinksInDefaultBrowser {
|
if viewModel.identityContext.appPreferences.openLinksInDefaultBrowser || !url.isHTTPURL {
|
||||||
UIApplication.shared.open(url)
|
UIApplication.shared.open(url)
|
||||||
} else {
|
} else {
|
||||||
present(SFSafariViewController(url: url), animated: true)
|
present(SFSafariViewController(url: url), animated: true)
|
||||||
|
|
|
@ -54,7 +54,11 @@ public class CollectionItemsViewModel: ObservableObject {
|
||||||
markerScrollPositionItemId = identityContext.service.getLocalLastReadId(timeline: timeline)
|
markerScrollPositionItemId = identityContext.service.getLocalLastReadId(timeline: timeline)
|
||||||
}
|
}
|
||||||
|
|
||||||
lastReadId.compactMap { $0 }
|
lastReadId
|
||||||
|
.filter { _ in
|
||||||
|
identityContext.appPreferences.positionBehavior(timeline: timeline) == .localRememberPosition
|
||||||
|
}
|
||||||
|
.compactMap { $0 }
|
||||||
.removeDuplicates()
|
.removeDuplicates()
|
||||||
.debounce(for: .seconds(Self.lastReadIdDebounceInterval), scheduler: DispatchQueue.global())
|
.debounce(for: .seconds(Self.lastReadIdDebounceInterval), scheduler: DispatchQueue.global())
|
||||||
.flatMap { identityContext.service.setLocalLastReadId($0, timeline: timeline) }
|
.flatMap { identityContext.service.setLocalLastReadId($0, timeline: timeline) }
|
||||||
|
|
Loading…
Reference in a new issue