StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
fix(provider): clear active live source when a provider is deleted to prevent loading issues
David Nashashc5027617b790
diff --git a/data/src/main/java/com/streamvault/data/repository/CombinedM3uRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/CombinedM3uRepositoryImpl.ktindex 4ac0b778..c0bda590 100644--- a/data/src/main/java/com/streamvault/data/repository/CombinedM3uRepositoryImpl.kt+++ b/data/src/main/java/com/streamvault/data/repository/CombinedM3uRepositoryImpl.kt@@ -206,7 +206,17 @@ class CombinedM3uRepositoryImpl @Inject constructor(}override fun getActiveLiveSource(): Flow<ActiveLiveSource?> =- preferencesRepository.activeLiveSource+ combine(+ preferencesRepository.activeLiveSource,+ providerRepository.getProviders()+ ) { activeSource, providers ->+ when (activeSource) {+ is ActiveLiveSource.ProviderSource -> activeSource.takeIf { source ->+ providers.any { provider -> provider.id == source.providerId }+ }+ else -> activeSource+ }+ }override suspend fun setActiveLiveSource(source: ActiveLiveSource?): Result<Unit> = try {preferencesRepository.setActiveLiveSource(source)diff --git a/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt b/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.ktindex c9937d41..be91263d 100644--- a/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt+++ b/data/src/main/java/com/streamvault/data/repository/ProviderRepositoryImpl.kt@@ -371,6 +371,17 @@ class ProviderRepositoryImpl @Inject constructor(completedWeight += PROVIDER_ROW_STEP_WEIGHTpendingCleanupActions = providerDeletionCleanupDao.countByProvider(id)}+ try {+ if (preferencesRepository.activeLiveSource.first() == ActiveLiveSource.ProviderSource(id)) {+ preferencesRepository.setActiveLiveSource(null)+ }+ } catch (cancelled: CancellationException) {+ throw cancelled+ } catch (_: Exception) {+ // The provider is already deleted. Keep deletion successful; the live-source+ // repository also filters out references to missing providers.+ logger.warning("Could not clear the saved live source for deleted provider $id")+ }stalkerApiService.invalidateSessionScopes(id)reportProgress("Provider library removed.")reportProgress("Finalizing provider cleanup...")diff --git a/docs/CHANGELOG.md b/docs/CHANGELOG.mdindex 49d23328..a9fe6547 100644--- a/docs/CHANGELOG.md+++ b/docs/CHANGELOG.md@@ -13,6 +13,7 @@ All notable product changes are recorded in this document.- Reduced peak memory during large M3U syncs by using staged database keys for duplicate detection and paged series reconciliation; Xtream and Stalker sync paths are unchanged.### Fixed+- Fixed Live TV remaining stuck loading after deleting a provider and adding another by clearing and validating the saved active source.- Fixed missing episodes from providers that return nested episode arrays or season-keyed episode maps, which were previously skipped and left series with no episodes.- Fixed episodes disappearing when an episode's optional metadata block arrived in an unexpected shape: the episode is now kept and only the metadata is skipped.- Fixed series pages that stayed empty after a failed details request: a failure with no cached episodes now shows a localized error, and a series with no episodes shows a localized empty state.