mirror of
https://github.com/outline/outline.git
synced 2026-11-20 21:23:06 +03:00
* Upgrade Mobx * fix: Enforce MobX action boundaries * fix: Wrap static observable updates in actions * Remove iteration tests
42 lines
872 B
TypeScript
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;
|