feat: Show recent searches (#2868)

* stash

* root hookup

* recent searches UI

* feat: Add search query deletion

* simplify no results state

* lint
This commit is contained in:
Tom Moor
2021-12-19 11:08:28 -08:00
committed by GitHub
parent 81f3347ecf
commit 6fc1b5cc22
15 changed files with 267 additions and 100 deletions

28
app/models/SearchQuery.ts Normal file
View File

@@ -0,0 +1,28 @@
import { client } from "~/utils/ApiClient";
import BaseModel from "./BaseModel";
class SearchQuery extends BaseModel {
id: string;
query: string;
delete = async () => {
this.isSaving = true;
try {
await client.post(`/searches.delete`, {
query: this.query,
});
this.store.data.forEach((searchQuery: SearchQuery) => {
if (searchQuery.query === this.query) {
this.store.remove(searchQuery.id);
}
});
} finally {
this.isSaving = false;
}
};
}
export default SearchQuery;