feat: implement cache removal for active video in PlayerScreen

This commit is contained in:
tapframe 2026-04-23 01:44:15 +05:30
parent 19edc6de61
commit 5bbd0dc6f7
2 changed files with 12 additions and 0 deletions

View file

@ -1488,6 +1488,14 @@ fun PlayerScreen(
errorMessage = message errorMessage = message
if (message != null) { if (message != null) {
controlsVisible = !playerControlsLocked controlsVisible = !playerControlsLocked
val currentVideoId = activeVideoId
if (currentVideoId != null) {
val cacheKey = StreamLinkCacheRepository.contentKey(
contentType ?: parentMetaType,
currentVideoId,
)
StreamLinkCacheRepository.remove(cacheKey)
}
} }
}, },
) )

View file

@ -53,6 +53,10 @@ object StreamLinkCacheRepository {
StreamLinkCacheStorage.saveEntry(hashedKey(contentKey), payload) StreamLinkCacheStorage.saveEntry(hashedKey(contentKey), payload)
} }
fun remove(contentKey: String) {
StreamLinkCacheStorage.removeEntry(hashedKey(contentKey))
}
fun getValid(contentKey: String, maxAgeMs: Long): CachedStreamLink? { fun getValid(contentKey: String, maxAgeMs: Long): CachedStreamLink? {
if (maxAgeMs <= 0L) return null if (maxAgeMs <= 0L) return null
val raw = StreamLinkCacheStorage.loadEntry(hashedKey(contentKey)) ?: return null val raw = StreamLinkCacheStorage.loadEntry(hashedKey(contentKey)) ?: return null