mirror of
https://github.com/yattee/yattee.git
synced 2024-12-15 06:40:32 +05:30
dbb7134eb7
Fix #329
23 lines
1018 B
Swift
23 lines
1018 B
Swift
import Foundation
|
|
import Siesta
|
|
|
|
final class FavoriteResourceObserver: ObservableObject, ResourceObserver {
|
|
@Published var contentItems = [ContentItem]()
|
|
|
|
func resourceChanged(_ resource: Resource, event _: ResourceEvent) {
|
|
if let videos: [Video] = resource.typedContent() {
|
|
contentItems = videos.map { ContentItem(video: $0) }
|
|
} else if let channel: Channel = resource.typedContent() {
|
|
contentItems = channel.videos.map { ContentItem(video: $0) }
|
|
} else if let playlist: ChannelPlaylist = resource.typedContent() {
|
|
contentItems = playlist.videos.map { ContentItem(video: $0) }
|
|
} else if let playlist: Playlist = resource.typedContent() {
|
|
contentItems = playlist.videos.map { ContentItem(video: $0) }
|
|
} else if let page: SearchPage = resource.typedContent() {
|
|
contentItems = page.results
|
|
} else if let items: [ContentItem] = resource.typedContent() {
|
|
contentItems = items
|
|
}
|
|
}
|
|
}
|