dimensionhub/dimensionhub/Views/FollowList/FollowDramaModel.swift
2025-06-10 13:10:00 +08:00

41 lines
918 B
Swift

//
// FollowListModel.swift
// dimensionhub
//
// Created by on 2025/4/8.
//
import Foundation
import Observation
@Observable
final class FollowDramaModel {
@ObservationIgnored
var drama: FollowListModel.DramaItem
//
var checkedChannelId: Int = 0
var episodes: [FollowListModel.DramaItem.Channel.Episode]
init(drama: FollowListModel.DramaItem) {
self.drama = drama
self.checkedChannelId = 0
if let channel = drama.channels.first {
self.episodes = channel.episodes
} else {
self.episodes = []
}
}
func changeChannel(channelId: Int) {
self.checkedChannelId = channelId
if drama.channels.indices.contains(channelId) {
self.episodes = drama.channels[channelId].episodes
} else {
self.episodes = []
}
}
}