feat(stations): скрывать украинские станции (ROKS, Kiss FM) для РФ
Radio ROKS и Kiss FM (TavR Media, хосты radioroks.ua / kissfm.ua) недоступны с российских IP без VPN. Теперь для пользователей из РФ они полностью скрыты — и сами станции (везде, где используется список), и их чипы-категории. Страна определяется по IP (api.country.is → ipapi.co; при VPN вернёт страну выходного узла, тогда станции доступны и НЕ скрываются), с фолбэком на страну SIM/сети/локали устройства, если IP-сервис недоступен (в РФ часто заблокирован). Код страны кэшируется (DataStore). Фильтр в GetStationsUseCase (combine со страной) + чипы в StationsViewModel. id 741 «Радио РОКС» (stream.roks.com) — российская, под правило не попадает. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -2,10 +2,12 @@ package com.radiola.ui.stations
|
||||
|
||||
import androidx.lifecycle.ViewModel
|
||||
import androidx.lifecycle.viewModelScope
|
||||
import com.radiola.domain.geo.GeoBlock
|
||||
import com.radiola.domain.model.Station
|
||||
import com.radiola.domain.model.Track
|
||||
import com.radiola.domain.repository.FavoritesRepository
|
||||
import com.radiola.domain.repository.NowPlayingRepository
|
||||
import com.radiola.domain.repository.RegionRepository
|
||||
import com.radiola.domain.repository.StationRepository
|
||||
import com.radiola.domain.usecase.GetStationsUseCase
|
||||
import com.radiola.domain.usecase.PlayStationUseCase
|
||||
@@ -27,6 +29,7 @@ class StationsViewModel @Inject constructor(
|
||||
private val favoritesRepository: FavoritesRepository,
|
||||
private val stationRepository: StationRepository,
|
||||
private val nowPlayingRepository: NowPlayingRepository,
|
||||
private val regionRepository: RegionRepository,
|
||||
private val playerController: PlayerController
|
||||
) : ViewModel() {
|
||||
|
||||
@@ -64,8 +67,20 @@ class StationsViewModel @Inject constructor(
|
||||
}
|
||||
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList())
|
||||
|
||||
val tags: StateFlow<List<String>> = stationRepository.getTags()
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList())
|
||||
// Чипы-жанры. Для пользователей из РФ убираем жанры украинских станций
|
||||
// (Radio ROKS, Kiss FM) — их чипы не показываем вовсе.
|
||||
val tags: StateFlow<List<String>> = combine(
|
||||
stationRepository.getTags(),
|
||||
stationRepository.getStations(),
|
||||
regionRepository.countryCode()
|
||||
) { tags, allStations, country ->
|
||||
if (GeoBlock.shouldHideUa(country)) {
|
||||
val uaGenres = allStations.filter { GeoBlock.isUaStation(it) }.map { it.genre }.toSet()
|
||||
tags.filterNot { it in uaGenres }
|
||||
} else {
|
||||
tags
|
||||
}
|
||||
}.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyList())
|
||||
|
||||
val favoriteIds: StateFlow<Set<Int>> = favoritesRepository.getFavorites()
|
||||
.map { list -> list.map { it.id }.toSet() }
|
||||
@@ -76,6 +91,8 @@ class StationsViewModel @Inject constructor(
|
||||
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyMap())
|
||||
|
||||
init {
|
||||
// Определяем страну пользователя по IP (для гео-фильтрации станций).
|
||||
viewModelScope.launch { regionRepository.refresh() }
|
||||
viewModelScope.launch {
|
||||
_isLoading.value = true
|
||||
refreshStationsUseCase()
|
||||
|
||||
Reference in New Issue
Block a user