fix(favorites): не терять избранное после перезапуска приложения
refreshStations пересоздавал каталог с isFavorite=false, а insertAll (OnConflictStrategy.REPLACE) затирал строки — отметки «избранное» пропадали при каждом старте. Перед вставкой считываем текущие id избранного (getFavoriteIdsOnce) и проставляем их новым записям. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -72,8 +72,10 @@ class StationRepositoryImpl @Inject constructor(
|
||||
}
|
||||
}
|
||||
|
||||
// 4. Save to DB
|
||||
android.util.Log.d("StationRepo", "Saving ${merged.size} merged stations to DB")
|
||||
// 4. Save to DB. Сохраняем текущие отметки «избранное», иначе REPLACE
|
||||
// в insertAll затрёт их при каждом пересоздании каталога (на старте).
|
||||
val favoriteIds = db.stationDao().getFavoriteIdsOnce().toSet()
|
||||
android.util.Log.d("StationRepo", "Saving ${merged.size} merged stations to DB (избранных сохранено: ${favoriteIds.size})")
|
||||
val entities = merged.mapIndexed { index, station ->
|
||||
StationEntity(
|
||||
id = station.id,
|
||||
@@ -85,7 +87,7 @@ class StationRepositoryImpl @Inject constructor(
|
||||
tags = station.tags.joinToString(","),
|
||||
sortOrder = index,
|
||||
source = station.source,
|
||||
isFavorite = false,
|
||||
isFavorite = station.id in favoriteIds,
|
||||
qualities = encodeQualities(station.qualities)
|
||||
)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user