* stash * root hookup * recent searches UI * feat: Add search query deletion * simplify no results state * lint
29 lines
561 B
TypeScript
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;
|