fix: Flash in sidebar when publishing document (regression in 5fc68db5da)

This commit is contained in:
Tom Moor
2023-12-27 22:05:37 -05:00
parent 60de93bc48
commit 7be71fda61

View File

@@ -707,10 +707,25 @@ export default class DocumentsStore extends Store<Document> {
params: Partial<Document>,
options?: Record<string, string | boolean | number | undefined>
): Promise<Document> {
const document = await super.update(params, options);
const collection = this.getCollectionForDocument(document);
void collection?.fetchDocuments({ force: true });
this.isSaving = 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;
} finally {
this.isSaving = false;
}
}
@action