fix: Flash in sidebar when publishing document (regression in 5fc68db5da)
This commit is contained in:
@@ -707,10 +707,25 @@ export default class DocumentsStore extends Store<Document> {
|
|||||||
params: Partial<Document>,
|
params: Partial<Document>,
|
||||||
options?: Record<string, string | boolean | number | undefined>
|
options?: Record<string, string | boolean | number | undefined>
|
||||||
): Promise<Document> {
|
): Promise<Document> {
|
||||||
const document = await super.update(params, options);
|
this.isSaving = true;
|
||||||
const collection = this.getCollectionForDocument(document);
|
|
||||||
void collection?.fetchDocuments({ force: true });
|
try {
|
||||||
|
const res = await client.post(`/${this.apiEndpoint}.update`, {
|
||||||
|
...params,
|
||||||
|
...options,
|
||||||
|
});
|
||||||
|
invariant(res?.data, "Data should be available");
|
||||||
|
|
||||||
|
const collection = this.getCollectionForDocument(res.data);
|
||||||
|
await collection?.fetchDocuments({ force: true });
|
||||||
|
|
||||||
|
const document = this.add(res.data);
|
||||||
|
this.addPolicies(res.policies);
|
||||||
|
|
||||||
return document;
|
return document;
|
||||||
|
} finally {
|
||||||
|
this.isSaving = false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@action
|
@action
|
||||||
|
|||||||
Reference in New Issue
Block a user