mirror of
https://github.com/cranci1/Sora.git
synced 2026-05-07 10:40:26 +00:00
dwo (#132)
* bug fixes (#127) * yeah @realdoomsboygaming fault * fixes * freaky ahh update --------- Co-authored-by: Seiike <122684677+Seeike@users.noreply.github.com>
This commit is contained in:
parent
92061e868a
commit
0d042cc3e6
4 changed files with 41 additions and 16 deletions
|
|
@ -14,6 +14,10 @@ struct ContentView: View {
|
|||
.tabItem {
|
||||
Label("Library", systemImage: "books.vertical")
|
||||
}
|
||||
DownloadView()
|
||||
.tabItem {
|
||||
Label("Downloads", systemImage: "arrow.down.app.fill")
|
||||
}
|
||||
SearchView()
|
||||
.tabItem {
|
||||
Label("Search", systemImage: "magnifyingglass")
|
||||
|
|
|
|||
|
|
@ -24,24 +24,42 @@ class ContinueWatchingManager {
|
|||
remove(item: item)
|
||||
return
|
||||
}
|
||||
|
||||
|
||||
var items = fetchItems()
|
||||
if let index = items.firstIndex(where: { $0.streamUrl == item.streamUrl && $0.episodeNumber == item.episodeNumber }) {
|
||||
items[index] = item
|
||||
} else {
|
||||
items.append(item)
|
||||
|
||||
items.removeAll { existing in
|
||||
existing.fullUrl == item.fullUrl &&
|
||||
existing.episodeNumber == item.episodeNumber &&
|
||||
existing.module.metadata.sourceName == item.module.metadata.sourceName
|
||||
}
|
||||
|
||||
items.append(item)
|
||||
|
||||
if let data = try? JSONEncoder().encode(items) {
|
||||
UserDefaults.standard.set(data, forKey: storageKey)
|
||||
}
|
||||
}
|
||||
|
||||
func fetchItems() -> [ContinueWatchingItem] {
|
||||
if let data = UserDefaults.standard.data(forKey: storageKey),
|
||||
let items = try? JSONDecoder().decode([ContinueWatchingItem].self, from: data) {
|
||||
return items
|
||||
guard
|
||||
let data = UserDefaults.standard.data(forKey: storageKey),
|
||||
let raw = try? JSONDecoder().decode([ContinueWatchingItem].self, from: data)
|
||||
else {
|
||||
return []
|
||||
}
|
||||
return []
|
||||
|
||||
var seen = Set<String>()
|
||||
let unique = raw.reversed().filter { item in
|
||||
let key = "\(item.fullUrl)|\(item.module.metadata.sourceName)|\(item.episodeNumber)"
|
||||
if seen.contains(key) {
|
||||
return false
|
||||
} else {
|
||||
seen.insert(key)
|
||||
return true
|
||||
}
|
||||
}.reversed()
|
||||
|
||||
return Array(unique)
|
||||
}
|
||||
|
||||
func remove(item: ContinueWatchingItem) {
|
||||
|
|
|
|||
|
|
@ -110,6 +110,7 @@ struct EpisodeCell: View {
|
|||
Spacer()
|
||||
CircularProgressBar(progress: currentProgress)
|
||||
.frame(width: 40, height: 40)
|
||||
.padding(.trailing, 8)
|
||||
}
|
||||
.contentShape(Rectangle())
|
||||
.background(isMultiSelectMode && isSelected ? Color.accentColor.opacity(0.1) : Color.clear)
|
||||
|
|
@ -120,8 +121,11 @@ struct EpisodeCell: View {
|
|||
.onAppear {
|
||||
updateProgress()
|
||||
updateDownloadStatus()
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||
fetchEpisodeDetails()
|
||||
|
||||
if let type = module.metadata.type?.lowercased(), type == "anime" {
|
||||
DispatchQueue.main.asyncAfter(deadline: .now() + 0.1) {
|
||||
fetchAnimeEpisodeDetails()
|
||||
}
|
||||
}
|
||||
|
||||
if let totalEpisodes = totalEpisodes, episodeID + 1 < totalEpisodes {
|
||||
|
|
@ -168,11 +172,7 @@ struct EpisodeCell: View {
|
|||
private var episodeThumbnail: some View {
|
||||
ZStack {
|
||||
if let url = URL(string: episodeImageUrl.isEmpty ? defaultBannerImage : episodeImageUrl) {
|
||||
KFImage.optimizedEpisodeThumbnail(url: url)
|
||||
.setProcessor(DownsamplingImageProcessor(size: CGSize(width: 100, height: 56)))
|
||||
.memoryCacheExpiration(.seconds(600))
|
||||
.cacheOriginalImage()
|
||||
.fade(duration: 0.1)
|
||||
KFImage(url)
|
||||
.onFailure { error in
|
||||
Logger.shared.log("Failed to load episode image: \(error)", type: "Error")
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,6 +18,9 @@ struct SettingsView: View {
|
|||
NavigationLink(destination: SettingsViewPlayer()) {
|
||||
Text("Media Player")
|
||||
}
|
||||
NavigationLink(destination: SettingsViewDownloads().environmentObject(JSController.shared)) {
|
||||
Text("Downloads")
|
||||
}
|
||||
NavigationLink(destination: SettingsViewModule()) {
|
||||
Text("Modules")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue