diff --git a/resources/components/picker/stop.html b/resources/components/picker/stop.html
index 49eea23..f40e869 100644
--- a/resources/components/picker/stop.html
+++ b/resources/components/picker/stop.html
@@ -3,10 +3,10 @@
-
+
- - {{ destination.name }}
+ - {{ destination.name }}
diff --git a/resources/ts/components/picker.ts b/resources/ts/components/picker.ts
index 6ca0faa..f74e41a 100644
--- a/resources/ts/components/picker.ts
+++ b/resources/ts/components/picker.ts
@@ -2,7 +2,7 @@ import Component from "vue-class-component";
import Vue from "vue";
import { Stop, StopGroup, StopGroups } from "../model";
import { Prop, Watch } from "vue-property-decorator";
-import { ensureArray, FetchingState, filter, map, time } from "../utils";
+import { FetchingState, filter, map, unique } from "../utils";
import { debounce } from "../decorators";
import urls from '../urls';
@@ -18,6 +18,10 @@ export class PickerStopComponent extends Vue {
get showMap() {
return this.inMap || this.map;
}
+
+ get destinations() {
+ return unique(this.stop.destinations, stop => stop.name);
+ }
}
@Component({
@@ -38,7 +42,7 @@ export class FinderComponent extends Vue {
get filtered(): StopGroups {
const groups = map(
this.found,
- (group: StopGroup, name: string) =>
+ (group: StopGroup) =>
group.filter(stop => !this.blacklist.some(blacklisted => blacklisted.id === stop.id))
) as StopGroups;
diff --git a/resources/ts/utils.ts b/resources/ts/utils.ts
index 2601a47..ecb4a18 100644
--- a/resources/ts/utils.ts
+++ b/resources/ts/utils.ts
@@ -75,3 +75,23 @@ export function time
(action: () => T, name?: string) {
return result;
}
+
+export const identity = a => a;
+
+export function unique(array: T[], criterion: (item: T) => U = identity) {
+ const result: T[] = [];
+ const known = new Set();
+
+ const entries = array.map(item => [ criterion(item), item ]) as [ U, T ][];
+
+ for (const [ key, item ] of entries) {
+ if (known.has(key)) {
+ continue;
+ }
+
+ known.add(key);
+ result.push(item);
+ }
+
+ return result;
+}