Skip to content
This repository has been archived by the owner on Aug 9, 2021. It is now read-only.

Commit

Permalink
- Don't break on retired stations, show the latest version of a retir…
Browse files Browse the repository at this point in the history
…ed station.
  • Loading branch information
hardiesoft committed Jul 21, 2021
1 parent f8eff57 commit cbbaedb
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/views/StationView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -217,9 +217,24 @@ export default {
api.groups.getStationsForGroup(this.groupName),
]);
this.group = group.result.groups[0];
this.station = stations.result.stations
.filter((station) => station.retiredAt === null)
.find((station) => station.name === this.stationName);
const station = stations.result.stations.filter(
(station) => station.name === this.stationName
);
if (station.length > 1) {
const nonRetired = station.find((item) => item.retiredAt === null);
if (nonRetired) {
this.station = nonRetired;
} else {
const sortedByLatestRetired = station.sort(
(a, b) =>
new Date(a.retiredAt).getTime() -
new Date(b.retiredAt).getTime()
);
this.station = sortedByLatestRetired.pop();
}
} else if (station.length === 1) {
this.station = station[0];
}
this.recordingsQueryFinal = {
tagMode: "any",
offset: 0,
Expand Down

0 comments on commit cbbaedb

Please sign in to comment.