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:
28
app/models/SearchQuery.ts
Normal file
28
app/models/SearchQuery.ts
Normal 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;
|
||||
Reference in New Issue
Block a user