mirror of
https://github.com/yattee/yattee.git
synced 2024-12-13 22:00:31 +05:30
Favorited playlists belong to account
This commit is contained in:
parent
115f9fea67
commit
09ff16d464
@ -7,7 +7,7 @@ struct FavoriteItem: Codable, Equatable, Identifiable, Defaults.Serializable {
|
|||||||
case popular
|
case popular
|
||||||
case trending(String, String?)
|
case trending(String, String?)
|
||||||
case channel(String, String, String)
|
case channel(String, String, String)
|
||||||
case playlist(String)
|
case playlist(String, String)
|
||||||
case channelPlaylist(String, String, String)
|
case channelPlaylist(String, String, String)
|
||||||
case searchQuery(String, String, String, String)
|
case searchQuery(String, String, String, String)
|
||||||
|
|
||||||
|
@ -124,7 +124,7 @@ struct FavoriteItemView: View {
|
|||||||
ChannelVideosView(channel: .init(id: id, name: name))
|
ChannelVideosView(channel: .init(id: id, name: name))
|
||||||
case let .channelPlaylist(_, id, title):
|
case let .channelPlaylist(_, id, title):
|
||||||
ChannelPlaylistView(playlist: .init(id: id, title: title))
|
ChannelPlaylistView(playlist: .init(id: id, title: title))
|
||||||
case let .playlist(id):
|
case let .playlist(_, id):
|
||||||
ChannelPlaylistView(playlist: .init(id: id, title: label))
|
ChannelPlaylistView(playlist: .init(id: id, title: label))
|
||||||
case .subscriptions:
|
case .subscriptions:
|
||||||
SubscriptionsView()
|
SubscriptionsView()
|
||||||
@ -157,7 +157,7 @@ struct FavoriteItemView: View {
|
|||||||
case let .searchQuery(text, _, _, _):
|
case let .searchQuery(text, _, _, _):
|
||||||
navigation.hideViewsAboveBrowser()
|
navigation.hideViewsAboveBrowser()
|
||||||
navigation.openSearchQuery(text)
|
navigation.openSearchQuery(text)
|
||||||
case let .playlist(id):
|
case let .playlist(_, id):
|
||||||
navigation.tabSelection = .playlist(id)
|
navigation.tabSelection = .playlist(id)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -193,6 +193,8 @@ struct FavoriteItemView: View {
|
|||||||
case let .channelPlaylist(appType, _, _):
|
case let .channelPlaylist(appType, _, _):
|
||||||
guard let appType = VideosApp.AppType(rawValue: appType) else { return false }
|
guard let appType = VideosApp.AppType(rawValue: appType) else { return false }
|
||||||
return accounts.app.appType == appType
|
return accounts.app.appType == appType
|
||||||
|
case let .playlist(accountID, _):
|
||||||
|
return accounts.current?.id == accountID
|
||||||
default:
|
default:
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
@ -222,7 +224,7 @@ struct FavoriteItemView: View {
|
|||||||
case let .channelPlaylist(_, id, _):
|
case let .channelPlaylist(_, id, _):
|
||||||
return accounts.api.channelPlaylist(id)
|
return accounts.api.channelPlaylist(id)
|
||||||
|
|
||||||
case let .playlist(id):
|
case let .playlist(_, id):
|
||||||
return accounts.api.playlist(id)
|
return accounts.api.playlist(id)
|
||||||
|
|
||||||
case let .searchQuery(text, date, duration, order):
|
case let .searchQuery(text, date, duration, order):
|
||||||
@ -241,12 +243,13 @@ struct FavoriteItemView: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private var label: String {
|
private var label: String {
|
||||||
if case let .playlist(id) = item.section {
|
switch item.section {
|
||||||
|
case let .playlist(_, id):
|
||||||
return playlists.find(id: id)?.title ?? "Playlist".localized()
|
return playlists.find(id: id)?.title ?? "Playlist".localized()
|
||||||
}
|
default:
|
||||||
|
|
||||||
return item.section.label.localized()
|
return item.section.label.localized()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct FavoriteItemView_Previews: PreviewProvider {
|
struct FavoriteItemView_Previews: PreviewProvider {
|
||||||
|
@ -197,10 +197,12 @@ struct PlaylistsView: View {
|
|||||||
|
|
||||||
editPlaylistButton
|
editPlaylistButton
|
||||||
|
|
||||||
FavoriteButton(item: FavoriteItem(section: .playlist(currentPlaylist.id)))
|
if let account = accounts.current {
|
||||||
|
FavoriteButton(item: FavoriteItem(section: .playlist(account.id, currentPlaylist.id)))
|
||||||
.labelStyle(.iconOnly)
|
.labelStyle(.iconOnly)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if accounts.signedIn {
|
if accounts.signedIn {
|
||||||
newPlaylistButton
|
newPlaylistButton
|
||||||
|
@ -102,12 +102,13 @@ struct EditFavorites: View {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func label(_ item: FavoriteItem) -> String {
|
func label(_ item: FavoriteItem) -> String {
|
||||||
if case let .playlist(id) = item.section {
|
switch item.section {
|
||||||
|
case let .playlist(_, id):
|
||||||
return playlistsModel.find(id: id)?.title ?? "Playlist".localized()
|
return playlistsModel.find(id: id)?.title ?? "Playlist".localized()
|
||||||
}
|
default:
|
||||||
|
|
||||||
return item.section.label.localized()
|
return item.section.label.localized()
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
struct EditFavorites_Previews: PreviewProvider {
|
struct EditFavorites_Previews: PreviewProvider {
|
||||||
|
Loading…
Reference in New Issue
Block a user