Fixed formatting and also watched status method

This commit is contained in:
cranci1 2025-10-23 14:20:31 +02:00
parent 1c9b8339f5
commit f53cc505fc

View file

@ -24,7 +24,6 @@ struct EpisodeCell: View {
let tmdbID: Int?
let seasonNumber: Int?
//receives the set of filler episode numbers (from MediaInfoView)
let fillerEpisodes: Set<Int>?
let isMultiSelectMode: Bool
@ -43,7 +42,6 @@ struct EpisodeCell: View {
@State private var downloadAnimationScale: CGFloat = 1.0
@State private var activeDownloadTask: AVAssetDownloadTask?
@State private var retryAttempts: Int = 0
private var malIDFromParent: Int? { malID }
private let maxRetryAttempts: Int = 3
@ -55,7 +53,6 @@ struct EpisodeCell: View {
@AppStorage("selectedAppearance") private var selectedAppearance: Appearance = .system
@AppStorage("remainingTimePercentage") private var remainingTimePercentage: Double = 90.0
// Filler state (derived from passed-in fillerEpisodes)
@State private var isFiller: Bool = false
init(
@ -114,7 +111,6 @@ struct EpisodeCell: View {
episodeCellContent
.onAppear {
setupOnAppear()
// set filler state based on passed-in set (if available)
let epNum = episodeID + 1
if let set = fillerEpisodes {
self.isFiller = set.contains(epNum)
@ -183,7 +179,7 @@ private extension EpisodeCell {
}
.tint(.blue)
if progress >= (remainingTimePercentage / 100.0) {
if progress <= remainingTimePercentage {
Button(action: { markAsWatched() }) {
Label("Watched", systemImage: "checkmark.circle")
}
@ -285,7 +281,7 @@ private extension EpisodeCell {
var contextMenuContent: some View {
Group {
if progress >= (remainingTimePercentage / 100.0) {
if progress <= remainingTimePercentage {
Button(action: markAsWatched) {
Label("Mark Episode as Watched", systemImage: "checkmark.circle")
}
@ -312,7 +308,6 @@ private extension EpisodeCell {
}
private extension EpisodeCell {
func handleTap() {
if isMultiSelectMode {
onSelectionChanged?(!isSelected)
@ -323,9 +318,8 @@ private extension EpisodeCell {
}
}
private extension EpisodeCell {
func markAsWatched() {
let defaults = UserDefaults.standard
let totalTime = 1000.0
@ -351,7 +345,6 @@ private extension EpisodeCell {
}
}
func resetProgress() {
let userDefaults = UserDefaults.standard
userDefaults.set(0.0, forKey: "lastPlayedTime_\(episode)")
@ -811,7 +804,6 @@ private extension EpisodeCell {
}.resume()
}
func handleFetchFailure(error: Error) {
Logger.shared.log("Episode details fetch error: \(error.localizedDescription)", type: "Error")