Files
outline/app/models/SearchQuery.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

29 lines
561 B
TypeScript

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;