fix(now-playing): матч текущего трека по id станции, а не по имени

Станции с одинаковым именем в разных сетях (напр. «Deep» у Record и DFM)
показывали один и тот же трек — матч был по lowercase-имени. Каталожный id
(== station.id) уникален и совпадает со stationId в /now-playing, поэтому
матчим по id. Убран весь by-name путь (репозиторий, плеер, карточки).

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
nk
2026-06-03 15:54:24 +03:00
parent eeceb754ea
commit 1ef60b6053
8 changed files with 15 additions and 44 deletions

View File

@@ -94,7 +94,7 @@ fun FavoritesScreen(
isFavorite = favoriteIds.contains(station.id),
onClick = { onStationClick(station) },
onFavoriteClick = { viewModel.toggleFavorite(station) },
nowTrack = nowPlaying[station.name.trim().lowercase()],
nowTrack = nowPlaying[station.id],
modifier = Modifier.animateItemPlacement()
)
}

View File

@@ -34,8 +34,8 @@ class FavoritesViewModel @Inject constructor(
.map { list -> list.map { it.id }.toSet() }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptySet())
// Текущие треки по lowercase-имени станции — для обложек на карточках.
val nowPlaying: StateFlow<Map<String, Track>> = nowPlayingRepository.getAllNowPlayingByName()
// Текущие треки по id станции (каталожный == station.id) — без коллизий по имени.
val nowPlaying: StateFlow<Map<Int, Track>> = nowPlayingRepository.getAllNowPlaying()
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyMap())
init {

View File

@@ -98,7 +98,7 @@ class PlayerViewModel @Inject constructor(
}
// Collect now playing for this station (API has priority: covers + accurate metadata)
launch {
getNowPlayingUseCase(station.id, station.name)
getNowPlayingUseCase(station.id)
.distinctUntilChanged()
.collect { track ->
if (track != null) {

View File

@@ -118,7 +118,7 @@ fun StationsScreen(
isFavorite = favoriteIds.contains(station.id),
onClick = { onStationClick(station) },
onFavoriteClick = { viewModel.toggleFavorite(station) },
nowTrack = nowPlaying[station.name.trim().lowercase()],
nowTrack = nowPlaying[station.id],
modifier = Modifier.animateItemPlacement()
)
}

View File

@@ -65,8 +65,8 @@ class StationsViewModel @Inject constructor(
.map { list -> list.map { it.id }.toSet() }
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptySet())
// Текущие треки по lowercase-имени станции — для обложек на карточках.
val nowPlaying: StateFlow<Map<String, Track>> = nowPlayingRepository.getAllNowPlayingByName()
// Текущие треки по id станции (каталожный == station.id) — без коллизий по имени.
val nowPlaying: StateFlow<Map<Int, Track>> = nowPlayingRepository.getAllNowPlaying()
.stateIn(viewModelScope, SharingStarted.WhileSubscribed(5000), emptyMap())
init {