mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 13:33:42 +00:00
Fix share URLs
This commit is contained in:
parent
6328bfbfab
commit
a70d4f3b38
@ -80,6 +80,6 @@ extension VideosAPI {
|
||||
urlComponents.queryItems = queryItems
|
||||
}
|
||||
|
||||
return urlComponents.url!
|
||||
return urlComponents.url
|
||||
}
|
||||
}
|
||||
|
@ -14,7 +14,7 @@ struct VideoDetails: View {
|
||||
@State private var confirmationShown = false
|
||||
@State private var presentingAddToPlaylist = false
|
||||
@State private var presentingShareSheet = false
|
||||
@State private var shareURL = ""
|
||||
@State private var shareURL: URL?
|
||||
|
||||
@State private var currentPage = Page.details
|
||||
|
||||
@ -309,7 +309,9 @@ struct VideoDetails: View {
|
||||
}
|
||||
#if os(iOS)
|
||||
.sheet(isPresented: $presentingShareSheet) {
|
||||
ShareSheet(activityItems: [shareURL])
|
||||
if let shareURL = shareURL {
|
||||
ShareSheet(activityItems: [shareURL])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ struct ChannelPlaylistView: View {
|
||||
var playlist: ChannelPlaylist
|
||||
|
||||
@State private var presentingShareSheet = false
|
||||
@State private var shareURL: URL?
|
||||
|
||||
@StateObject private var store = Store<ChannelPlaylist>()
|
||||
|
||||
@ -56,8 +57,8 @@ struct ChannelPlaylistView: View {
|
||||
}
|
||||
#if os(iOS)
|
||||
.sheet(isPresented: $presentingShareSheet) {
|
||||
if let url = accounts.api.shareURL(contentItem) {
|
||||
ShareSheet(activityItems: [url])
|
||||
if let shareURL = shareURL {
|
||||
ShareSheet(activityItems: [shareURL])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
@ -70,7 +71,8 @@ struct ChannelPlaylistView: View {
|
||||
ToolbarItem(placement: .navigation) {
|
||||
ShareButton(
|
||||
contentItem: contentItem,
|
||||
presentingShareSheet: $presentingShareSheet
|
||||
presentingShareSheet: $presentingShareSheet,
|
||||
shareURL: $shareURL
|
||||
)
|
||||
}
|
||||
|
||||
|
@ -5,6 +5,7 @@ struct ChannelVideosView: View {
|
||||
let channel: Channel
|
||||
|
||||
@State private var presentingShareSheet = false
|
||||
@State private var shareURL: URL?
|
||||
|
||||
@StateObject private var store = Store<Channel>()
|
||||
|
||||
@ -79,7 +80,8 @@ struct ChannelVideosView: View {
|
||||
ToolbarItem(placement: .navigation) {
|
||||
ShareButton(
|
||||
contentItem: contentItem,
|
||||
presentingShareSheet: $presentingShareSheet
|
||||
presentingShareSheet: $presentingShareSheet,
|
||||
shareURL: $shareURL
|
||||
)
|
||||
}
|
||||
|
||||
@ -100,8 +102,8 @@ struct ChannelVideosView: View {
|
||||
#endif
|
||||
#if os(iOS)
|
||||
.sheet(isPresented: $presentingShareSheet) {
|
||||
if let url = accounts.api.shareURL(contentItem) {
|
||||
ShareSheet(activityItems: [url])
|
||||
if let shareURL = shareURL {
|
||||
ShareSheet(activityItems: [shareURL])
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -3,7 +3,7 @@ import SwiftUI
|
||||
struct ShareButton: View {
|
||||
let contentItem: ContentItem
|
||||
@Binding var presentingShareSheet: Bool
|
||||
@Binding var shareURL: String
|
||||
@Binding var shareURL: URL?
|
||||
|
||||
@EnvironmentObject<AccountsModel> private var accounts
|
||||
@EnvironmentObject<PlayerModel> private var player
|
||||
@ -11,11 +11,11 @@ struct ShareButton: View {
|
||||
init(
|
||||
contentItem: ContentItem,
|
||||
presentingShareSheet: Binding<Bool>,
|
||||
shareURL: Binding<String>? = nil
|
||||
shareURL: Binding<URL?>? = nil
|
||||
) {
|
||||
self.contentItem = contentItem
|
||||
_presentingShareSheet = presentingShareSheet
|
||||
_shareURL = shareURL ?? .constant("")
|
||||
_shareURL = shareURL ?? .constant(nil)
|
||||
}
|
||||
|
||||
var body: some View {
|
||||
@ -81,7 +81,7 @@ struct ShareButton: View {
|
||||
NSPasteboard.general.clearContents()
|
||||
NSPasteboard.general.setString(url.absoluteString, forType: .string)
|
||||
#else
|
||||
shareURL = url.absoluteString
|
||||
shareURL = url
|
||||
presentingShareSheet = true
|
||||
#endif
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user