mirror of
https://github.com/cranci1/Sora.git
synced 2026-04-21 08:32:00 +00:00
added episodes refetching
Some checks are pending
Build and Release IPA / Build IPA (push) Waiting to run
Some checks are pending
Build and Release IPA / Build IPA (push) Waiting to run
This commit is contained in:
parent
19cb608934
commit
54a953a2ea
2 changed files with 46 additions and 12 deletions
|
|
@ -27,9 +27,11 @@ struct MediaInfoView: View {
|
||||||
@State var airdate: String = ""
|
@State var airdate: String = ""
|
||||||
@State var episodeLinks: [EpisodeLink] = []
|
@State var episodeLinks: [EpisodeLink] = []
|
||||||
@State var itemID: Int?
|
@State var itemID: Int?
|
||||||
|
|
||||||
@State var isLoading: Bool = true
|
@State var isLoading: Bool = true
|
||||||
@State var showFullSynopsis: Bool = false
|
@State var showFullSynopsis: Bool = false
|
||||||
@State var showedDrop: Bool = false
|
@State var hasFetched: Bool = false
|
||||||
|
@State var isRefetching: Bool = true
|
||||||
|
|
||||||
@AppStorage("externalPlayer") private var externalPlayer: String = "Default"
|
@AppStorage("externalPlayer") private var externalPlayer: String = "Default"
|
||||||
|
|
||||||
|
|
@ -179,6 +181,35 @@ struct MediaInfoView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
VStack(alignment: .leading, spacing: 10) {
|
||||||
|
Text("Episodes")
|
||||||
|
.font(.system(size: 18))
|
||||||
|
.fontWeight(.bold)
|
||||||
|
}
|
||||||
|
VStack(spacing: 8) {
|
||||||
|
if isRefetching {
|
||||||
|
ProgressView()
|
||||||
|
.padding()
|
||||||
|
} else {
|
||||||
|
Image(systemName: "exclamationmark.triangle")
|
||||||
|
.font(.largeTitle)
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
HStack(spacing: 2) {
|
||||||
|
Text("No episodes Found:")
|
||||||
|
.foregroundColor(.secondary)
|
||||||
|
Button(action: {
|
||||||
|
isRefetching = true
|
||||||
|
fetchDetails()
|
||||||
|
}) {
|
||||||
|
Text("Retry")
|
||||||
|
.foregroundColor(.accentColor)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
.padding()
|
||||||
|
.frame(maxWidth: .infinity)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.padding()
|
.padding()
|
||||||
|
|
@ -189,18 +220,18 @@ struct MediaInfoView: View {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
.onAppear {
|
.onAppear {
|
||||||
if !showedDrop {
|
if !hasFetched {
|
||||||
DropManager.shared.showDrop(title: "Fetching Data", subtitle: "Please wait while fetching", duration: 1.0, icon: UIImage(systemName: "arrow.triangle.2.circlepath"))
|
DropManager.shared.showDrop(title: "Fetching Data", subtitle: "Please wait while fetching", duration: 1.0, icon: UIImage(systemName: "arrow.triangle.2.circlepath"))
|
||||||
showedDrop = true
|
fetchDetails()
|
||||||
}
|
fetchItemID(byTitle: title) { result in
|
||||||
fetchDetails()
|
switch result {
|
||||||
fetchItemID(byTitle: title) { result in
|
case .success(let id):
|
||||||
switch result {
|
itemID = id
|
||||||
case .success(let id):
|
case .failure(let error):
|
||||||
itemID = id
|
Logger.shared.log("Failed to fetch Item ID: \(error)")
|
||||||
case .failure(let error):
|
}
|
||||||
Logger.shared.log("Failed to fetch Item ID: \(error)")
|
|
||||||
}
|
}
|
||||||
|
hasFetched = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -220,6 +251,7 @@ struct MediaInfoView: View {
|
||||||
}
|
}
|
||||||
self.episodeLinks = episodes
|
self.episodeLinks = episodes
|
||||||
self.isLoading = false
|
self.isLoading = false
|
||||||
|
self.isRefetching = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
|
@ -231,11 +263,13 @@ struct MediaInfoView: View {
|
||||||
}
|
}
|
||||||
self.episodeLinks = episodes
|
self.episodeLinks = episodes
|
||||||
self.isLoading = false
|
self.isLoading = false
|
||||||
|
self.isRefetching = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch {
|
} catch {
|
||||||
Logger.shared.log("Error loading module: \(error)", type: "Error")
|
Logger.shared.log("Error loading module: \(error)", type: "Error")
|
||||||
self.isLoading = false
|
self.isLoading = false
|
||||||
|
self.isRefetching = false
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -63,7 +63,7 @@ struct SearchView: View {
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
Text("No Results Found")
|
Text("No Results Found")
|
||||||
.font(.headline)
|
.font(.headline)
|
||||||
Text("Try different keywords/titles")
|
Text("Try different keywords")
|
||||||
.font(.caption)
|
.font(.caption)
|
||||||
.foregroundColor(.secondary)
|
.foregroundColor(.secondary)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue