diff --git a/shared/src/commonMain/kotlin/com/jdamcd/tflarrivals/TflApi.kt b/shared/src/commonMain/kotlin/com/jdamcd/tflarrivals/TflApi.kt index 8e502bd..9bea198 100644 --- a/shared/src/commonMain/kotlin/com/jdamcd/tflarrivals/TflApi.kt +++ b/shared/src/commonMain/kotlin/com/jdamcd/tflarrivals/TflApi.kt @@ -33,26 +33,26 @@ internal class TflApi { } } - suspend fun fetchArrivals(station: String): List { - return client.get("$BASE_URL/StopPoint/$station/Arrivals") { - parameter("app_key", BuildKonfig.TFL_APP_KEY) - }.body() - } + suspend fun fetchArrivals(station: String): List = + client + .get("$BASE_URL/StopPoint/$station/Arrivals") { + parameter("app_key", BuildKonfig.TFL_APP_KEY) + }.body() - suspend fun searchStations(query: String): ApiSearchResult { - return client.get("$BASE_URL/StopPoint/Search") { - parameter("app_key", BuildKonfig.TFL_APP_KEY) - parameter("query", query) - parameter("modes", "dlr,elizabeth-line,overground,tube,tram") - parameter("tflOperatedNationalRailStationsOnly", true) - }.body() - } + suspend fun searchStations(query: String): ApiSearchResult = + client + .get("$BASE_URL/StopPoint/Search") { + parameter("app_key", BuildKonfig.TFL_APP_KEY) + parameter("query", query) + parameter("modes", "dlr,elizabeth-line,overground,tube,tram") + parameter("tflOperatedNationalRailStationsOnly", true) + }.body() - suspend fun stopDetails(id: String): ApiStopPoint { - return client.get("$BASE_URL/StopPoint/$id") { - parameter("app_key", BuildKonfig.TFL_APP_KEY) - }.body() - } + suspend fun stopDetails(id: String): ApiStopPoint = + client + .get("$BASE_URL/StopPoint/$id") { + parameter("app_key", BuildKonfig.TFL_APP_KEY) + }.body() } @Serializable diff --git a/shared/src/commonMain/kotlin/com/jdamcd/tflarrivals/TflArrivals.kt b/shared/src/commonMain/kotlin/com/jdamcd/tflarrivals/TflArrivals.kt index 7e8ab80..7107d74 100644 --- a/shared/src/commonMain/kotlin/com/jdamcd/tflarrivals/TflArrivals.kt +++ b/shared/src/commonMain/kotlin/com/jdamcd/tflarrivals/TflArrivals.kt @@ -37,10 +37,11 @@ internal class TflArrivals( } @Throws(CancellationException::class) - override suspend fun searchStops(query: String): List { - return api.searchStations(query).matches + override suspend fun searchStops(query: String): List = + api + .searchStations(query) + .matches .map { StopResult(it.id, it.name, it.id.startsWith("HUB")) } - } @Throws(CancellationException::class) override suspend fun stopDetails(id: String): StopDetails { @@ -61,12 +62,10 @@ internal class TflArrivals( .filter { settings.platformFilter.isEmpty() || it.platformName.contains(settings.platformFilter, ignoreCase = true) - } - .filter { arrival -> + }.filter { arrival -> settings.directionFilter == SettingsConfig.DIRECTION_FILTER_DEFAULT || arrival.direction.contains(settings.directionFilter) - } - .take(3) + }.take(3) .map { Arrival( // DLR arrivals all have the same ID, so use hash @@ -116,7 +115,9 @@ data class StopDetails( val children: List ) -class NoDataException(message: String) : Throwable(message = message) +class NoDataException( + message: String +) : Throwable(message = message) private fun formatTime(seconds: Int) = if (seconds < 60) {