Change syntax to overcome compiler issue

This commit is contained in:
Arkadiusz Fal 2023-02-28 22:13:39 +01:00
parent 5bac92fdbf
commit f7b35925b4
2 changed files with 9 additions and 1 deletions

View File

@ -62,6 +62,10 @@ struct Channel: Identifiable, Hashable {
return "person.3" return "person.3"
} }
} }
var alwaysAvailable: Bool {
self == .videos || self == .playlists
}
} }
struct Tab: Identifiable, Hashable { struct Tab: Identifiable, Hashable {

View File

@ -322,7 +322,7 @@ struct ChannelVideosView: View {
Picker("Content type", selection: $contentType) { Picker("Content type", selection: $contentType) {
if let channel = presentedChannel { if let channel = presentedChannel {
ForEach(Channel.ContentType.allCases, id: \.self) { type in ForEach(Channel.ContentType.allCases, id: \.self) { type in
if type == .videos || type == .playlists || channel.hasData(for: type) { if typeAvailable(type) {
Label(type.description, systemImage: type.systemImage).tag(type) Label(type.description, systemImage: type.systemImage).tag(type)
} }
} }
@ -330,6 +330,10 @@ struct ChannelVideosView: View {
} }
} }
private func typeAvailable(_ type: Channel.ContentType) -> Bool {
type.alwaysAvailable || (presentedChannel?.hasData(for: type) ?? false)
}
private var resource: Resource? { private var resource: Resource? {
guard let channel = presentedChannel else { return nil } guard let channel = presentedChannel else { return nil }