From 5bbd0dc6f720b301b24f442c55155c357d55935e Mon Sep 17 00:00:00 2001 From: tapframe <85391825+tapframe@users.noreply.github.com> Date: Thu, 23 Apr 2026 01:44:15 +0530 Subject: [PATCH] feat: implement cache removal for active video in PlayerScreen --- .../kotlin/com/nuvio/app/features/player/PlayerScreen.kt | 8 ++++++++ .../app/features/streams/StreamLinkCacheRepository.kt | 4 ++++ 2 files changed, 12 insertions(+) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerScreen.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerScreen.kt index 81c52ea4..5376fc00 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerScreen.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/player/PlayerScreen.kt @@ -1488,6 +1488,14 @@ fun PlayerScreen( errorMessage = message if (message != null) { controlsVisible = !playerControlsLocked + val currentVideoId = activeVideoId + if (currentVideoId != null) { + val cacheKey = StreamLinkCacheRepository.contentKey( + contentType ?: parentMetaType, + currentVideoId, + ) + StreamLinkCacheRepository.remove(cacheKey) + } } }, ) diff --git a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamLinkCacheRepository.kt b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamLinkCacheRepository.kt index 07519fd7..0d497166 100644 --- a/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamLinkCacheRepository.kt +++ b/composeApp/src/commonMain/kotlin/com/nuvio/app/features/streams/StreamLinkCacheRepository.kt @@ -53,6 +53,10 @@ object StreamLinkCacheRepository { StreamLinkCacheStorage.saveEntry(hashedKey(contentKey), payload) } + fun remove(contentKey: String) { + StreamLinkCacheStorage.removeEntry(hashedKey(contentKey)) + } + fun getValid(contentKey: String, maxAgeMs: Long): CachedStreamLink? { if (maxAgeMs <= 0L) return null val raw = StreamLinkCacheStorage.loadEntry(hashedKey(contentKey)) ?: return null