From 4ce60d957d3004d78390d18068425aa2cc504cab Mon Sep 17 00:00:00 2001 From: cranci1 <100066266+cranci1@users.noreply.github.com> Date: Wed, 25 Jun 2025 10:37:09 +0200 Subject: [PATCH] fixed nil case + error --- Sora/MediaUtils/CustomPlayer/CustomPlayer.swift | 5 +++-- Sora/MediaUtils/NormalPlayer/VideoPlayer.swift | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Sora/MediaUtils/CustomPlayer/CustomPlayer.swift b/Sora/MediaUtils/CustomPlayer/CustomPlayer.swift index 9e1bc7d..d64eab4 100644 --- a/Sora/MediaUtils/CustomPlayer/CustomPlayer.swift +++ b/Sora/MediaUtils/CustomPlayer/CustomPlayer.swift @@ -1642,8 +1642,9 @@ class CustomMediaPlayerViewController: UIViewController, UIGestureRecognizerDele ContinueWatchingManager.shared.save(item: item) } - let remainingPercentage = (duration - currentTime) / duration - let threshold = (100.0 - (UserDefaults.standard.double(forKey: "remainingTimePercentage"))) / 100.0 ?? 0.1 + let remainingPercentage = (self.duration - self.currentTimeVal) / self.duration + let remainingTimePercentage = UserDefaults.standard.object(forKey: "remainingTimePercentage") != nil ? UserDefaults.standard.double(forKey: "remainingTimePercentage") : 90.0 + let threshold = (100.0 - remainingTimePercentage) / 100.0 if remainingPercentage < threshold { if self.aniListID != 0 && !self.aniListUpdatedSuccessfully && !self.aniListUpdateImpossible { diff --git a/Sora/MediaUtils/NormalPlayer/VideoPlayer.swift b/Sora/MediaUtils/NormalPlayer/VideoPlayer.swift index 599b8ca..6ffabd0 100644 --- a/Sora/MediaUtils/NormalPlayer/VideoPlayer.swift +++ b/Sora/MediaUtils/NormalPlayer/VideoPlayer.swift @@ -320,7 +320,8 @@ class VideoPlayerViewController: UIViewController { } let remainingPercentage = (duration - currentTime) / duration - let threshold = (100.0 - (UserDefaults.standard.double(forKey: "remainingTimePercentage"))) / 100.0 ?? 0.1 + let remainingTimePercentage = UserDefaults.standard.object(forKey: "remainingTimePercentage") != nil ? UserDefaults.standard.double(forKey: "remainingTimePercentage") : 90.0 + let threshold = (100.0 - remainingTimePercentage) / 100.0 if remainingPercentage < threshold { if self.aniListID != 0 && !self.aniListUpdateSent {