From 7be71fda614eabd6c1e99c58ca07813fd9075132 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Wed, 27 Dec 2023 22:05:37 -0500 Subject: [PATCH] fix: Flash in sidebar when publishing document (regression in 5fc68db5da7eff9147353c7ae6ede90695c4f904) --- app/stores/DocumentsStore.ts | 23 +++++++++++++++++++---- 1 file changed, 19 insertions(+), 4 deletions(-) diff --git a/app/stores/DocumentsStore.ts b/app/stores/DocumentsStore.ts index fc01384f3..b3ac39f74 100644 --- a/app/stores/DocumentsStore.ts +++ b/app/stores/DocumentsStore.ts @@ -707,10 +707,25 @@ export default class DocumentsStore extends Store { params: Partial, options?: Record ): Promise { - const document = await super.update(params, options); - const collection = this.getCollectionForDocument(document); - void collection?.fetchDocuments({ force: true }); - return document; + 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