mirror of
https://github.com/yattee/yattee.git
synced 2025-08-04 01:34:10 +00:00
Fix bookmarks
This commit is contained in:
@@ -2,5 +2,6 @@ import Foundation
|
||||
import SwiftUI
|
||||
|
||||
struct Constants {
|
||||
static let yatteeProtocol = "yattee://"
|
||||
static let overlayAnimation = Animation.linear(duration: 0.2)
|
||||
}
|
||||
|
@@ -10,7 +10,7 @@ struct DocumentsView: View {
|
||||
NoDocumentsView()
|
||||
} else {
|
||||
ForEach(model.sortedDirectoryContents, id: \.absoluteString) { url in
|
||||
let video = Video.local(model.replacePrivateVar(url) ?? url)
|
||||
let video = Video.local(model.standardizedURL(url) ?? url)
|
||||
PlayerQueueRow(
|
||||
item: PlayerQueueItem(video)
|
||||
)
|
||||
|
@@ -11,7 +11,7 @@ struct RecentDocumentsView: View {
|
||||
NoDocumentsView()
|
||||
} else {
|
||||
ForEach(recentDocuments, id: \.absoluteString) { url in
|
||||
let video = Video.local(model.replacePrivateVar(url) ?? url)
|
||||
let video = Video.local(model.standardizedURL(url) ?? url)
|
||||
PlayerQueueRow(
|
||||
item: PlayerQueueItem(video)
|
||||
)
|
||||
|
@@ -95,7 +95,10 @@ struct ContentView: View {
|
||||
|
||||
NavigationModel.shared.presentingOpenVideos = false
|
||||
}
|
||||
.onOpenURL(perform: OpenURLHandler.shared.handle)
|
||||
.onOpenURL { url in
|
||||
URLBookmarkModel.shared.saveBookmark(url)
|
||||
OpenURLHandler.shared.handle(url)
|
||||
}
|
||||
.background(
|
||||
EmptyView().sheet(isPresented: $navigation.presentingAddToPlaylist) {
|
||||
AddToPlaylistView(video: navigation.videoToAddToPlaylist)
|
||||
|
@@ -36,7 +36,7 @@ struct OpenURLHandler {
|
||||
}
|
||||
#endif
|
||||
|
||||
guard let url = urlByReplacingYatteeProtocol(url) else { return }
|
||||
guard let url = url.byReplacingYatteeProtocol() else { return }
|
||||
|
||||
let parser = URLParser(url: url)
|
||||
|
||||
@@ -93,21 +93,6 @@ struct OpenURLHandler {
|
||||
navigation.presentingOpenVideos = false
|
||||
}
|
||||
|
||||
private func urlByReplacingYatteeProtocol(_ url: URL, with urlProtocol: String = "https") -> URL! {
|
||||
var urlAbsoluteString = url.absoluteString
|
||||
|
||||
guard urlAbsoluteString.hasPrefix(Self.yatteeProtocol) else {
|
||||
return url
|
||||
}
|
||||
|
||||
urlAbsoluteString = String(urlAbsoluteString.dropFirst(Self.yatteeProtocol.count))
|
||||
if url.absoluteString.contains("://") {
|
||||
return URL(string: urlAbsoluteString)
|
||||
}
|
||||
|
||||
return URL(string: "\(urlProtocol)://\(urlAbsoluteString)")
|
||||
}
|
||||
|
||||
private func handleFileURLOpen(_ parser: URLParser) {
|
||||
guard let url = parser.fileURL else { return }
|
||||
|
||||
|
@@ -109,7 +109,10 @@ struct VideoPlayerView: View {
|
||||
}
|
||||
}
|
||||
.alert(isPresented: $navigation.presentingAlertInVideoPlayer) { navigation.alert }
|
||||
.onOpenURL(perform: OpenURLHandler.shared.handle)
|
||||
.onOpenURL { url in
|
||||
URLBookmarkModel.shared.saveBookmark(url)
|
||||
OpenURLHandler.shared.handle(url)
|
||||
}
|
||||
.frame(minWidth: 950, minHeight: 700)
|
||||
#else
|
||||
return GeometryReader { geometry in
|
||||
|
Reference in New Issue
Block a user