Files
outline/app/stores/SearchesStore.ts
Tom Moor 6fc1b5cc22 feat: Show recent searches (#2868)
* stash

* root hookup

* recent searches UI

* feat: Add search query deletion

* simplify no results state

* lint
2021-12-19 11:08:28 -08:00

21 lines
536 B
TypeScript

import { uniqBy } from "lodash";
import { computed } from "mobx";
import SearchQuery from "~/models/SearchQuery";
import BaseStore, { RPCAction } from "./BaseStore";
import RootStore from "./RootStore";
export default class SearchesStore extends BaseStore<SearchQuery> {
actions = [RPCAction.List, RPCAction.Delete];
apiEndpoint = "searches";
constructor(rootStore: RootStore) {
super(rootStore, SearchQuery);
}
@computed
get recent(): SearchQuery[] {
return uniqBy(this.orderedData, "query").slice(0, 8);
}
}