don't force unwrap optionals that may be nil
This commit is contained in:
parent
bbfbd32f34
commit
cf5e311ed7
|
@ -70,8 +70,8 @@ struct EpisodeItemView: View {
|
|||
.resizable()
|
||||
}
|
||||
.contentMode(.aspectFill)
|
||||
.opacity(0.3)
|
||||
.shadow(radius: 5)
|
||||
.opacity(0.4)
|
||||
.blur(radius: 2.0)
|
||||
}
|
||||
|
||||
var portraitHeaderOverlayView: some View {
|
||||
|
|
|
@ -42,13 +42,13 @@ struct LatestMediaView: View {
|
|||
LazyHStack() {
|
||||
Spacer().frame(width:16)
|
||||
ForEach(items, id: \.id) { item in
|
||||
if(item.type == "Series" || item.type == "Movie" || item.type == "Episode") {
|
||||
if(item.type == "Series" || item.type == "Movie") {
|
||||
NavigationLink(destination: ItemView(item: item)) {
|
||||
VStack(alignment: .leading) {
|
||||
Spacer().frame(height:10)
|
||||
LazyImage(source: (item.type != "Episode" ? item.getPrimaryImage(baseURL: globalData.server.baseURI!, maxWidth: 100) : item.getSeriesPrimaryImage(baseURL: globalData.server.baseURI!, maxWidth: 100)))
|
||||
LazyImage(source: item.getSeriesPrimaryImage(baseURL: globalData.server.baseURI!, maxWidth: 100))
|
||||
.placeholderAndFailure {
|
||||
Image(uiImage: UIImage(blurHash: item.getPrimaryImageBlurHash(), size: CGSize(width: 16, height: 20))!)
|
||||
Image(uiImage: UIImage(blurHash: item.getSeriesPrimaryImageBlurHash(), size: CGSize(width: 16, height: 20))!)
|
||||
.resizable()
|
||||
.frame(width: 100, height: 150)
|
||||
.cornerRadius(10)
|
||||
|
@ -61,19 +61,11 @@ struct LatestMediaView: View {
|
|||
.fontWeight(.semibold)
|
||||
.foregroundColor(.primary)
|
||||
.lineLimit(1)
|
||||
if(item.type == "Episode") {
|
||||
Text("S\(String(item.parentIndexNumber ?? 0)):E\(String(item.indexNumber ?? 0))")
|
||||
.font(.caption)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.secondary)
|
||||
.lineLimit(1)
|
||||
} else {
|
||||
Text(String(item.productionYear ?? 0))
|
||||
.font(.caption)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.secondary)
|
||||
.lineLimit(1)
|
||||
}
|
||||
Text(String(item.productionYear ?? 0))
|
||||
.font(.caption)
|
||||
.fontWeight(.semibold)
|
||||
.foregroundColor(.secondary)
|
||||
.lineLimit(1)
|
||||
}.frame(width: 100)
|
||||
Spacer().frame(width: 15)
|
||||
}
|
||||
|
|
|
@ -27,6 +27,7 @@ struct LibraryView: View {
|
|||
@State private var totalPages: Int = 0;
|
||||
@State private var currentPage: Int = 0;
|
||||
@State private var isSearching: String? = "";
|
||||
@State private var viewDidLoad: Bool = false;
|
||||
|
||||
init(usingParentID: String, title: String) {
|
||||
self.usingParentID = usingParentID
|
||||
|
@ -59,6 +60,11 @@ struct LibraryView: View {
|
|||
|
||||
func onAppear() {
|
||||
recalcTracks()
|
||||
|
||||
if(viewDidLoad) {
|
||||
return
|
||||
}
|
||||
|
||||
isLoading = true
|
||||
items = []
|
||||
|
||||
|
@ -72,6 +78,7 @@ struct LibraryView: View {
|
|||
totalPages = Int(x)
|
||||
items = response.items ?? []
|
||||
isLoading = false
|
||||
viewDidLoad = true
|
||||
})
|
||||
.store(in: &globalData.pendingAPIRequests)
|
||||
}
|
||||
|
|
|
@ -70,8 +70,8 @@ struct MovieItemView: View {
|
|||
.resizable()
|
||||
}
|
||||
.contentMode(.aspectFill)
|
||||
.opacity(0.3)
|
||||
.shadow(radius: 5)
|
||||
.opacity(0.4)
|
||||
.blur(radius: 2.0)
|
||||
}
|
||||
|
||||
var portraitHeaderOverlayView: some View {
|
||||
|
|
|
@ -29,7 +29,7 @@ struct SeasonItemView: View {
|
|||
}
|
||||
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
TvShowsAPI.getEpisodes(seriesId: item.seriesId!, userId: globalData.user.user_id!, fields: [.primaryImageAspectRatio,.seriesPrimaryImage,.seasonUserData,.overview,.genres,.people], seasonId: item.id!)
|
||||
TvShowsAPI.getEpisodes(seriesId: item.seriesId ?? "", userId: globalData.user.user_id!, fields: [.primaryImageAspectRatio,.seriesPrimaryImage,.seasonUserData,.overview,.genres,.people], seasonId: item.id ?? "")
|
||||
.sink(receiveCompletion: { completion in
|
||||
HandleAPIRequestCompletion(globalData: globalData, completion: completion)
|
||||
isLoading = false
|
||||
|
|
|
@ -28,7 +28,7 @@ struct SeriesItemView: View {
|
|||
isLoading = true
|
||||
|
||||
DispatchQueue.global(qos: .userInitiated).async {
|
||||
TvShowsAPI.getSeasons(seriesId: item.id ?? "", fields: [.primaryImageAspectRatio,.seriesPrimaryImage,.seasonUserData,.overview,.genres,.people])
|
||||
TvShowsAPI.getSeasons(seriesId: item.id ?? "", fields: [.primaryImageAspectRatio,.seriesPrimaryImage,.seasonUserData,.overview,.genres,.people], isMissing: false)
|
||||
.sink(receiveCompletion: { completion in
|
||||
HandleAPIRequestCompletion(globalData: globalData, completion: completion)
|
||||
}, receiveValue: { response in
|
||||
|
@ -74,7 +74,7 @@ struct SeriesItemView: View {
|
|||
.fontWeight(.semibold)
|
||||
.foregroundColor(.primary)
|
||||
.lineLimit(1)
|
||||
if(season.productionYear != 0) {
|
||||
if(season.productionYear != nil) {
|
||||
Text(String(season.productionYear!))
|
||||
.foregroundColor(.secondary)
|
||||
.font(.caption)
|
||||
|
|
Loading…
Reference in New Issue