Skip to content

Commit

Permalink
Remove logic from data class
Browse files Browse the repository at this point in the history
  • Loading branch information
jdamcd committed Dec 16, 2023
1 parent 1afecf0 commit 6ec633e
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
2 changes: 1 addition & 1 deletion macOS/Arrivals/SettingsView.swift
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ struct SettingsView: View {
}
.onChange(of: selectedResult) { result in
if let result {
if result.isHub() {
if result.isHub {
viewModel.disambiguate(stop: result)
selectedResult = nil
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ internal class TflArrivals(
@Throws(CancellationException::class)
override suspend fun searchStops(query: String): List<StopResult> {
return api.searchStations(query).matches
.map { StopResult(it.id, it.name) }
.map { StopResult(it.id, it.name, it.id.startsWith("HUB")) }
}

@Throws(CancellationException::class)
Expand All @@ -50,7 +50,7 @@ internal class TflArrivals(
stopPoint.commonName,
stopPoint.children
.filter { it.stopType == "NaptanMetroStation" || it.stopType == "NaptanRailStation" }
.map { StopResult(it.naptanId, it.commonName) }
.map { StopResult(it.naptanId, it.commonName, it.naptanId.startsWith("HUB")) }
)
}

Expand Down Expand Up @@ -106,10 +106,9 @@ data class Arrival(

data class StopResult(
val id: String,
val name: String
) {
fun isHub() = id.startsWith("HUB")
}
val name: String,
val isHub: Boolean
)

data class StopDetails(
val id: String,
Expand Down

0 comments on commit 6ec633e

Please sign in to comment.