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()
|
.resizable()
|
||||||
}
|
}
|
||||||
.contentMode(.aspectFill)
|
.contentMode(.aspectFill)
|
||||||
.opacity(0.3)
|
.opacity(0.4)
|
||||||
.shadow(radius: 5)
|
.blur(radius: 2.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
var portraitHeaderOverlayView: some View {
|
var portraitHeaderOverlayView: some View {
|
||||||
|
|
|
@ -42,13 +42,13 @@ struct LatestMediaView: View {
|
||||||
LazyHStack() {
|
LazyHStack() {
|
||||||
Spacer().frame(width:16)
|
Spacer().frame(width:16)
|
||||||
ForEach(items, id: \.id) { item in
|
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)) {
|
NavigationLink(destination: ItemView(item: item)) {
|
||||||
VStack(alignment: .leading) {
|
VStack(alignment: .leading) {
|
||||||
Spacer().frame(height:10)
|
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 {
|
.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()
|
.resizable()
|
||||||
.frame(width: 100, height: 150)
|
.frame(width: 100, height: 150)
|
||||||
.cornerRadius(10)
|
.cornerRadius(10)
|
||||||
|
@ -61,19 +61,11 @@ struct LatestMediaView: View {
|
||||||
.fontWeight(.semibold)
|
.fontWeight(.semibold)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
.lineLimit(1)
|
.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))
|
Text(String(item.productionYear ?? 0))
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.fontWeight(.semibold)
|
.fontWeight(.semibold)
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
}
|
|
||||||
}.frame(width: 100)
|
}.frame(width: 100)
|
||||||
Spacer().frame(width: 15)
|
Spacer().frame(width: 15)
|
||||||
}
|
}
|
||||||
|
|
|
@ -27,6 +27,7 @@ struct LibraryView: View {
|
||||||
@State private var totalPages: Int = 0;
|
@State private var totalPages: Int = 0;
|
||||||
@State private var currentPage: Int = 0;
|
@State private var currentPage: Int = 0;
|
||||||
@State private var isSearching: String? = "";
|
@State private var isSearching: String? = "";
|
||||||
|
@State private var viewDidLoad: Bool = false;
|
||||||
|
|
||||||
init(usingParentID: String, title: String) {
|
init(usingParentID: String, title: String) {
|
||||||
self.usingParentID = usingParentID
|
self.usingParentID = usingParentID
|
||||||
|
@ -59,6 +60,11 @@ struct LibraryView: View {
|
||||||
|
|
||||||
func onAppear() {
|
func onAppear() {
|
||||||
recalcTracks()
|
recalcTracks()
|
||||||
|
|
||||||
|
if(viewDidLoad) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
isLoading = true
|
isLoading = true
|
||||||
items = []
|
items = []
|
||||||
|
|
||||||
|
@ -72,6 +78,7 @@ struct LibraryView: View {
|
||||||
totalPages = Int(x)
|
totalPages = Int(x)
|
||||||
items = response.items ?? []
|
items = response.items ?? []
|
||||||
isLoading = false
|
isLoading = false
|
||||||
|
viewDidLoad = true
|
||||||
})
|
})
|
||||||
.store(in: &globalData.pendingAPIRequests)
|
.store(in: &globalData.pendingAPIRequests)
|
||||||
}
|
}
|
||||||
|
|
|
@ -70,8 +70,8 @@ struct MovieItemView: View {
|
||||||
.resizable()
|
.resizable()
|
||||||
}
|
}
|
||||||
.contentMode(.aspectFill)
|
.contentMode(.aspectFill)
|
||||||
.opacity(0.3)
|
.opacity(0.4)
|
||||||
.shadow(radius: 5)
|
.blur(radius: 2.0)
|
||||||
}
|
}
|
||||||
|
|
||||||
var portraitHeaderOverlayView: some View {
|
var portraitHeaderOverlayView: some View {
|
||||||
|
|
|
@ -29,7 +29,7 @@ struct SeasonItemView: View {
|
||||||
}
|
}
|
||||||
|
|
||||||
DispatchQueue.global(qos: .userInitiated).async {
|
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
|
.sink(receiveCompletion: { completion in
|
||||||
HandleAPIRequestCompletion(globalData: globalData, completion: completion)
|
HandleAPIRequestCompletion(globalData: globalData, completion: completion)
|
||||||
isLoading = false
|
isLoading = false
|
||||||
|
|
|
@ -28,7 +28,7 @@ struct SeriesItemView: View {
|
||||||
isLoading = true
|
isLoading = true
|
||||||
|
|
||||||
DispatchQueue.global(qos: .userInitiated).async {
|
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
|
.sink(receiveCompletion: { completion in
|
||||||
HandleAPIRequestCompletion(globalData: globalData, completion: completion)
|
HandleAPIRequestCompletion(globalData: globalData, completion: completion)
|
||||||
}, receiveValue: { response in
|
}, receiveValue: { response in
|
||||||
|
@ -74,7 +74,7 @@ struct SeriesItemView: View {
|
||||||
.fontWeight(.semibold)
|
.fontWeight(.semibold)
|
||||||
.foregroundColor(.primary)
|
.foregroundColor(.primary)
|
||||||
.lineLimit(1)
|
.lineLimit(1)
|
||||||
if(season.productionYear != 0) {
|
if(season.productionYear != nil) {
|
||||||
Text(String(season.productionYear!))
|
Text(String(season.productionYear!))
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
|
|
Loading…
Reference in New Issue