StreamVault is a TV-first free IPTV player for Android TV built with Kotlin, Jetpack Compose, Room, Hilt, and Media3.
Kotlin iptv-player
fix(live): show removal action for custom group members (#265)
bbans5e6da7148a4b
diff --git a/feature/live/src/main/java/com/streamvault/feature/live/home/HomeViewModel.kt b/feature/live/src/main/java/com/streamvault/feature/live/home/HomeViewModel.ktindex ff6fe920..ee78334b 100644--- a/feature/live/src/main/java/com/streamvault/feature/live/home/HomeViewModel.kt+++ b/feature/live/src/main/java/com/streamvault/feature/live/home/HomeViewModel.kt@@ -1663,7 +1663,7 @@ class HomeViewModel @Inject constructor(_uiState.update { it.copy(showDialog = true, selectedChannelForDialog = channel) }viewModelScope.launch {val memberships = favoriteRepository.getGroupMemberships(channel.providerId, channel.id, ContentType.LIVE)- _uiState.update { it.copy(dialogGroupMemberships = memberships) }+ _uiState.update { it.copy(dialogGroupMemberships = memberships.map { groupId -> -kotlin.math.abs(groupId) }) }}}diff --git a/feature/live/src/test/java/com/streamvault/feature/live/home/HomeViewModelTest.kt b/feature/live/src/test/java/com/streamvault/feature/live/home/HomeViewModelTest.ktindex a8055a54..9da8f40f 100644--- a/feature/live/src/test/java/com/streamvault/feature/live/home/HomeViewModelTest.kt+++ b/feature/live/src/test/java/com/streamvault/feature/live/home/HomeViewModelTest.kt@@ -174,6 +174,34 @@ class HomeViewModelTest {verify(combinedM3uRepository).setActiveLiveSource(ActiveLiveSource.ProviderSource(1L))}+ @Test+ fun `channel dialog exposes saved group memberships as virtual category ids`() = runTest {+ val channel = Channel(id = 42L, name = "Grouped channel", providerId = 7L)+ whenever(favoriteRepository.getGroupMemberships(7L, 42L, ContentType.LIVE))+ .thenReturn(listOf(1L, 23L))++ viewModel.onShowDialog(channel)+ runCurrent()++ assertThat(viewModel.uiState.value.dialogGroupMemberships)+ .containsExactly(-1L, -23L)+ assertThat(viewModel.uiState.value.showDialog).isTrue()+ }++ @Test+ fun `removing a channel from a custom group uses its saved group id`() = runTest {+ val channel = Channel(id = 42L, name = "Grouped channel", providerId = 7L)+ val group = Category(id = -23L, name = "My channels", type = ContentType.LIVE, isVirtual = true)+ whenever(favoriteRepository.removeFavorite(7L, 42L, ContentType.LIVE, 23L))+ .thenReturn(Result.Success(Unit))++ viewModel.removeFromGroup(channel, group)+ runCurrent()++ verify(favoriteRepository).removeFavorite(7L, 42L, ContentType.LIVE, 23L)+ verify(favoriteRepository, never()).removeFavorite(7L, 42L, ContentType.LIVE, null)+ }+@Testfun `initial state has empty categories and is loading`() = runTest {val state = viewModel.uiState.value