From ed9cf4cee33c2571040f7447c5972d0bcbe45590 Mon Sep 17 00:00:00 2001 From: Tom Moor Date: Fri, 7 Jul 2023 08:34:50 -0400 Subject: [PATCH] fix: No visible error message when maximm pinned documents is reached --- app/actions/definitions/documents.tsx | 28 +++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/app/actions/definitions/documents.tsx b/app/actions/definitions/documents.tsx index fe1037e80..86ad7381a 100644 --- a/app/actions/definitions/documents.tsx +++ b/app/actions/definitions/documents.tsx @@ -404,13 +404,19 @@ export const pinDocumentToCollection = createAction({ return; } - const document = stores.documents.get(activeDocumentId); - await document?.pin(document.collectionId); + try { + const document = stores.documents.get(activeDocumentId); + await document?.pin(document.collectionId); - const collection = stores.collections.get(activeCollectionId); + const collection = stores.collections.get(activeCollectionId); - if (!collection || !location.pathname.startsWith(collection?.url)) { - stores.toasts.showToast(t("Pinned to collection")); + if (!collection || !location.pathname.startsWith(collection?.url)) { + stores.toasts.showToast(t("Pinned to collection")); + } + } catch (err) { + stores.toasts.showToast(err.message, { + type: "error", + }); } }, }); @@ -443,10 +449,16 @@ export const pinDocumentToHome = createAction({ } const document = stores.documents.get(activeDocumentId); - await document?.pin(); + try { + await document?.pin(); - if (location.pathname !== homePath()) { - stores.toasts.showToast(t("Pinned to team home")); + if (location.pathname !== homePath()) { + stores.toasts.showToast(t("Pinned to team home")); + } + } catch (err) { + stores.toasts.showToast(err.message, { + type: "error", + }); } }, });