Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -1646,7 +1646,9 @@ fun SettingsScreen(
},
onRefresh = { viewModel.refreshIptv() },
onDelete = { viewModel.clearIptvConfig() },
onManageCategories = openIptvCategories
onManageCategories = openIptvCategories,
sortOrder = uiState.iptvSortOrder,
onSortOrderChange = { viewModel.setIptvSortOrder(it) }
)
"home_server" -> HomeServerSettings(
connections = uiState.homeServerConnections,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import com.arflix.tv.data.repository.HomeServerRepository
import com.arflix.tv.data.repository.PlexPinAuthSession
import com.arflix.tv.data.repository.IptvConfig
import com.arflix.tv.data.repository.IptvRepository
import com.arflix.tv.data.repository.normalizeIptvSortOrder
import com.arflix.tv.data.repository.IptvPlaylistEntry
import com.arflix.tv.data.repository.LauncherContinueWatchingRepository
import com.arflix.tv.data.repository.MediaRepository
Expand Down Expand Up @@ -1939,7 +1940,7 @@ class SettingsViewModel @Inject constructor(
viewModelScope.launch {
iptvRepository.observeConfig().collect { config ->
val current = _uiState.value
if (current.iptvM3uUrl != config.m3uUrl || current.iptvEpgUrl != config.epgUrl || current.iptvStalkerUrl != config.stalkerPortalUrl || current.iptvStalkerMac != config.stalkerMacAddress || current.iptvPlaylists != config.playlists) {
if (current.iptvM3uUrl != config.m3uUrl || current.iptvEpgUrl != config.epgUrl || current.iptvStalkerUrl != config.stalkerPortalUrl || current.iptvStalkerMac != config.stalkerMacAddress || current.iptvPlaylists != config.playlists || current.iptvSortOrder != config.sortOrder) {
_uiState.value = current.copy(
iptvM3uUrl = config.m3uUrl,
iptvEpgUrl = config.epgUrl,
Expand Down Expand Up @@ -2449,8 +2450,11 @@ class SettingsViewModel @Inject constructor(
}

fun setIptvSortOrder(mode: String) {
val normalized = normalizeIptvSortOrder(mode)
_uiState.value = _uiState.value.copy(iptvSortOrder = normalized)
viewModelScope.launch {
iptvRepository.saveSortOrder(mode)
iptvRepository.saveSortOrder(normalized)
syncLocalStateToCloud(silent = true)
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,19 @@ class IptvProviderOrderTest {
assertThat(normalizeIptvSortOrder(null)).isEqualTo("provider")
}

@Test
fun iptvSortOrderCyclesThroughExpectedSequence() {
fun nextSortOrder(current: String): String = when (normalizeIptvSortOrder(current)) {
"provider" -> "number"
"number" -> "name"
else -> "provider"
}

assertThat(nextSortOrder("provider")).isEqualTo("number")
assertThat(nextSortOrder("number")).isEqualTo("name")
assertThat(nextSortOrder("name")).isEqualTo("provider")
}

@Test
fun xtreamCategoryEndpointDefinesGroupOrder() {
val categorizedChannels = listOf(
Expand Down
Loading