@@ -13,13 +13,15 @@ import com.surrus.galwaybus.db.MyDatabase
1313import kotlinx.coroutines.CoroutineScope
1414import kotlinx.coroutines.Dispatchers
1515import kotlinx.coroutines.MainScope
16+ import kotlinx.coroutines.flow.Flow
1617import kotlinx.coroutines.flow.combine
17- import kotlinx.datetime.Clock
18- import kotlinx.datetime.Instant
1918import org.koin.core.component.KoinComponent
2019import org.koin.core.component.get
2120import org.koin.core.component.inject
21+ import kotlin.time.Clock
2222import kotlin.time.Duration
23+ import kotlin.time.ExperimentalTime
24+ import kotlin.time.Instant
2325
2426
2527open class GalwayBusRepository : KoinComponent {
@@ -38,11 +40,11 @@ open class GalwayBusRepository : KoinComponent {
3840 }).asFlow().mapToList(Dispatchers .Default )
3941
4042 @NativeCoroutines
41- val favorites = appSettings.favorites
43+ val favorites: Flow < Set < String >> = appSettings.favorites
4244
4345 val favoriteBusStopList = busStops.combine(favorites) { busStops, favorites ->
4446 Logger .i { " favoriteBusStopList, favorites = $favorites , busStops size = ${busStops.size} " }
45- favorites.map { favorite -> busStops.firstOrNull { it.stopRef == favorite } }.filterNotNull()
47+ favorites.mapNotNull { favorite -> busStops.firstOrNull { it.stopRef == favorite } }
4648 }
4749
4850 suspend fun fetchAndStoreBusStops () {
@@ -84,6 +86,7 @@ open class GalwayBusRepository : KoinComponent {
8486 }
8587 }
8688
89+ @OptIn(ExperimentalTime ::class )
8790 @NativeCoroutines
8891 suspend fun fetchBusStopDepartures (stopRef : String ): Result <List <GalwayBusDeparture >> {
8992 try {
0 commit comments