Files
Tom Moor 57c110dbe5 chore: Upgrade MobX (#13554)
* Upgrade Mobx

* fix: Enforce MobX action boundaries

* fix: Wrap static observable updates in actions

* Remove iteration tests
2026-09-02 20:31:37 -04:00

42 lines
872 B
TypeScript

import { client } from "~/utils/ApiClient";
import Model from "./base/Model";
class SearchQuery extends Model {
static modelName = "Search";
constructor(fields: Record<string, unknown>, store: Model["store"]) {
super(fields, store);
this.initialize(fields);
}
/**
* The query string, automatically truncated to 255 characters.
*/
query: string;
/**
* Where the query originated.
*/
source: "api" | "app" | "slack" | "oauth";
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;