1
0
mirror of https://github.com/yattee/yattee.git synced 2024-12-14 06:10:32 +05:30
yattee/Shared/Favorites/FavoriteResourceObserver.swift

23 lines
743 B
Swift
Raw Normal View History

2021-11-06 04:14:52 +05:30
import Foundation
import Siesta
final class FavoriteResourceObserver: ObservableObject, ResourceObserver {
@Published var videos = [Video]()
func resourceChanged(_ resource: Resource, event _: ResourceEvent) {
if let videos: [Video] = resource.typedContent() {
self.videos = videos
} else if let channel: Channel = resource.typedContent() {
videos = channel.videos
} else if let playlist: ChannelPlaylist = resource.typedContent() {
videos = playlist.videos
} else if let playlist: Playlist = resource.typedContent() {
videos = playlist.videos
}
}
var contentItems: [ContentItem] {
videos.map { ContentItem(video: $0) }
}
}