/* JellyfinPlayer/Swiftfin is subject to the terms of the Mozilla Public * License, v2.0. If a copy of the MPL was not distributed with this * file, you can obtain one at https://mozilla.org/MPL/2.0/. * * Copyright 2021 Aiden Vigue & Jellyfin Contributors */ import SwiftUI import JellyfinAPI struct SeriesItemView: View { @EnvironmentObject private var orientationInfo: OrientationInfo var item: BaseItemDto @State private var seasons: [BaseItemDto] = [] @State private var isLoading: Bool = true @State private var viewDidLoad: Bool = false func onAppear() { recalcTracks() if viewDidLoad { return } isLoading = true DispatchQueue.global(qos: .userInitiated).async { TvShowsAPI.getSeasons(seriesId: item.id ?? "", fields: [.primaryImageAspectRatio, .seriesPrimaryImage, .seasonUserData, .overview, .genres, .people]) .sink(receiveCompletion: { completion in HandleAPIRequestCompletion(globalData: globalData, completion: completion) }, receiveValue: { response in isLoading = false viewDidLoad = true seasons = response.items ?? [] }) .store(in: &globalData.pendingAPIRequests) } } // MARK: Grid tracks func recalcTracks() { let trkCnt: Int = Int(floor(UIScreen.main.bounds.size.width / 125)) tracks = [] for _ in (0..