From c6e704c04d818428522303174b1590686e386dc3 Mon Sep 17 00:00:00 2001 From: cranci1 <100066266+cranci1@users.noreply.github.com> Date: Tue, 10 Jun 2025 15:32:15 +0200 Subject: [PATCH] revert poster --- Sora/Views/MediaInfoView/MediaInfoView.swift | 24 +++++++++++++++---- .../SettingsSubViews/SettingsViewData.swift | 10 ++++---- 2 files changed, 24 insertions(+), 10 deletions(-) diff --git a/Sora/Views/MediaInfoView/MediaInfoView.swift b/Sora/Views/MediaInfoView/MediaInfoView.swift index eb1170e..883788d 100644 --- a/Sora/Views/MediaInfoView/MediaInfoView.swift +++ b/Sora/Views/MediaInfoView/MediaInfoView.swift @@ -494,10 +494,21 @@ struct MediaInfoView: View { } } - Button(action: { - fetchTMDBPosterImageAndSet() - }) { - Label("Use TMDB Poster Image", systemImage: "photo") + if UserDefaults.standard.string(forKey: "originalPoster_\(href)") != nil { + Button(action: { + if let originalPoster = UserDefaults.standard.string(forKey: "originalPoster_\(href)") { + imageUrl = originalPoster + UserDefaults.standard.removeObject(forKey: "tmdbPosterURL_\(href)") + } + }) { + Label("Revert Module Poster", systemImage: "photo.badge.arrow.down") + } + } else { + Button(action: { + fetchTMDBPosterImageAndSet() + }) { + Label("Use TMDB Poster Image", systemImage: "photo") + } } Divider() @@ -841,6 +852,9 @@ struct MediaInfoView: View { imageUrl = "https://image.tmdb.org/t/p/w\(tmdbImageWidth)\(posterPath)" } DispatchQueue.main.async { + let currentPosterKey = "originalPoster_\(self.href)" + let currentPoster = self.imageUrl + UserDefaults.standard.set(currentPoster, forKey: currentPosterKey) self.imageUrl = imageUrl UserDefaults.standard.set(imageUrl, forKey: "tmdbPosterURL_\(self.href)") } @@ -1216,7 +1230,7 @@ struct MediaInfoView: View { guard self.activeFetchID == fetchID else { return } - self.playStream(url: streamUrl, fullURL: fullURL, subtitles: subtitles, headers: headers, fetchID: fetchID) + self.playStream(url: streamUrl, fullURL: href, subtitles: subtitles, headers: headers, fetchID: fetchID) }) streamIndex += 1 diff --git a/Sora/Views/SettingsView/SettingsSubViews/SettingsViewData.swift b/Sora/Views/SettingsView/SettingsSubViews/SettingsViewData.swift index f48c194..99bd701 100644 --- a/Sora/Views/SettingsView/SettingsSubViews/SettingsViewData.swift +++ b/Sora/Views/SettingsView/SettingsSubViews/SettingsViewData.swift @@ -137,7 +137,7 @@ fileprivate struct SettingsButtonRow: View { struct SettingsViewData: View { @State private var showAlert = false - @State private var cacheSizeText: String = "Calculating..." + @State private var cacheSizeText: String = "..." @State private var isCalculatingSize: Bool = false @State private var cacheSize: Int64 = 0 @State private var documentsSize: Int64 = 0 @@ -167,7 +167,7 @@ struct SettingsViewData: View { .frame(width: 24, height: 24) .foregroundStyle(.red) - Text("Clear All Caches") + Text("Remove All Caches") .foregroundStyle(.red) Spacer() @@ -199,7 +199,7 @@ struct SettingsViewData: View { SettingsButtonRow( icon: "doc.text", - title: "Remove All Files in Documents", + title: "Remove All Documents", subtitle: formatSize(documentsSize), action: { activeAlert = .removeDocs @@ -271,7 +271,7 @@ struct SettingsViewData: View { func calculateCacheSize() { isCalculatingSize = true - cacheSizeText = "Calculating..." + cacheSizeText = "..." DispatchQueue.global(qos: .background).async { if let cacheURL = FileManager.default.urls(for: .cachesDirectory, in: .userDomainMask).first { @@ -283,7 +283,7 @@ struct SettingsViewData: View { } } else { DispatchQueue.main.async { - self.cacheSizeText = "Unknown" + self.cacheSizeText = "N/A" self.isCalculatingSize = false } }