mirror of
https://github.com/yattee/yattee.git
synced 2024-12-22 21:43:41 +00:00
Allow to add videos only to user created playlists
This commit is contained in:
parent
8c2ffa1b99
commit
d01b0f8275
@ -634,10 +634,12 @@ final class InvidiousAPI: Service, ObservableObject, VideosAPI {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private func extractPlaylist(from content: JSON) -> Playlist {
|
private func extractPlaylist(from content: JSON) -> Playlist {
|
||||||
.init(
|
let id = content["playlistId"].stringValue
|
||||||
id: content["playlistId"].stringValue,
|
return Playlist(
|
||||||
|
id: id,
|
||||||
title: content["title"].stringValue,
|
title: content["title"].stringValue,
|
||||||
visibility: content["isListed"].boolValue ? .public : .private,
|
visibility: content["isListed"].boolValue ? .public : .private,
|
||||||
|
editable: id.starts(with: "IV"),
|
||||||
updated: content["updated"].doubleValue,
|
updated: content["updated"].doubleValue,
|
||||||
videos: content["videos"].arrayValue.map { extractVideo(from: $0) }
|
videos: content["videos"].arrayValue.map { extractVideo(from: $0) }
|
||||||
)
|
)
|
||||||
|
@ -17,15 +17,17 @@ struct Playlist: Identifiable, Equatable, Hashable {
|
|||||||
let id: String
|
let id: String
|
||||||
var title: String
|
var title: String
|
||||||
var visibility: Visibility
|
var visibility: Visibility
|
||||||
|
var editable = true
|
||||||
|
|
||||||
var updated: TimeInterval?
|
var updated: TimeInterval?
|
||||||
|
|
||||||
var videos = [Video]()
|
var videos = [Video]()
|
||||||
|
|
||||||
init(id: String, title: String, visibility: Visibility, updated: TimeInterval? = nil, videos: [Video] = []) {
|
init(id: String, title: String, visibility: Visibility, editable: Bool = true, updated: TimeInterval? = nil, videos: [Video] = []) {
|
||||||
self.id = id
|
self.id = id
|
||||||
self.title = title
|
self.title = title
|
||||||
self.visibility = visibility
|
self.visibility = visibility
|
||||||
|
self.editable = editable
|
||||||
self.updated = updated
|
self.updated = updated
|
||||||
self.videos = videos
|
self.videos = videos
|
||||||
}
|
}
|
||||||
|
@ -94,7 +94,7 @@ struct AddToPlaylistView: View {
|
|||||||
selectPlaylistButton
|
selectPlaylistButton
|
||||||
#else
|
#else
|
||||||
Picker("Playlist", selection: $selectedPlaylistID) {
|
Picker("Playlist", selection: $selectedPlaylistID) {
|
||||||
ForEach(model.all) { playlist in
|
ForEach(model.all.filter(\.editable)) { playlist in
|
||||||
Text(playlist.title).tag(playlist.id)
|
Text(playlist.title).tag(playlist.id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user