StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
feat(home): expose hiddenChannelsLiveTv flow and hide/unhide actions
Celtiore4ddf3919a4c0
diff --git a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeViewModel.kt b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeViewModel.ktindex d10aec22..c5722615 100644--- a/app/src/main/java/com/streamvault/app/ui/screens/home/HomeViewModel.kt+++ b/app/src/main/java/com/streamvault/app/ui/screens/home/HomeViewModel.kt@@ -1473,6 +1473,14 @@ class HomeViewModel @Inject constructor(_uiState.update { it.copy(showDialog = false, selectedChannelForDialog = null) }}+ fun onShowHiddenChannelsDialog() {+ _uiState.update { it.copy(showHiddenChannelsDialog = true) }+ }++ fun onDismissHiddenChannelsDialog() {+ _uiState.update { it.copy(showHiddenChannelsDialog = false) }+ }+suspend fun verifyPin(pin: String): Boolean {return preferencesRepository.verifyParentalPin(pin)}@@ -1551,6 +1559,50 @@ class HomeViewModel @Inject constructor(}}+ /**+ * Surfaces the list of currently-hidden Live channels for the active provider,+ * sorted by name. Mirrors the M5 `hiddenLiveCategories` pattern but uses+ * `getChannelsByIds` to resolve channel metadata (name) from the hidden id+ * set, since HomeViewModel does not retain an "all channels" snapshot in+ * memory.+ */+ val hiddenChannelsLiveTv: StateFlow<List<Channel>> =+ _uiState+ .map { it.provider?.id }+ .distinctUntilChanged()+ .flatMapLatest { providerId ->+ if (providerId == null) flowOf(emptyList())+ else preferencesRepository.getHiddenChannelIds(providerId)+ .flatMapLatest { hiddenIds ->+ if (hiddenIds.isEmpty()) flowOf(emptyList())+ else channelRepository.getChannelsByIds(hiddenIds.toList())+ }+ .map { channels -> channels.sortedBy { it.name } }+ }+ .stateIn(viewModelScope, SharingStarted.WhileSubscribed(5_000L), emptyList())++ fun hideChannel(channel: Channel) {+ val providerId = _uiState.value.provider?.id ?: return+ viewModelScope.launch {+ preferencesRepository.setChannelHidden(providerId, channel.id, true)+ onDismissDialog()+ }+ }++ fun unhideChannel(channel: Channel) {+ val providerId = _uiState.value.provider?.id ?: return+ viewModelScope.launch {+ preferencesRepository.setChannelHidden(providerId, channel.id, false)+ }+ }++ fun unhideAllChannels() {+ val providerId = _uiState.value.provider?.id ?: return+ viewModelScope.launch {+ preferencesRepository.setHiddenChannelIds(providerId, emptySet())+ }+ }+fun setShowAllChannelsCategory(enabled: Boolean) {viewModelScope.launch { preferencesRepository.setShowAllChannelsCategory(enabled) }}@@ -1804,6 +1856,7 @@ data class HomeUiState(val showDialog: Boolean = false,val selectedChannelForDialog: Channel? = null,val dialogGroupMemberships: List<Long> = emptyList(),+ val showHiddenChannelsDialog: Boolean = false,val userMessage: String? = null,val showRenameGroupDialog: Boolean = false,val groupToRename: Category? = null,