From ebea8d12d189ee7c3d9fbb094ca9528c761c42ec Mon Sep 17 00:00:00 2001 From: "kasia.oczkowska" Date: Wed, 3 Jul 2024 13:54:52 +0100 Subject: [PATCH] feat: use try-catch block for updating flow status --- .../web/src/components/EditorLayout/index.jsx | 30 ++++++++++--------- 1 file changed, 16 insertions(+), 14 deletions(-) diff --git a/packages/web/src/components/EditorLayout/index.jsx b/packages/web/src/components/EditorLayout/index.jsx index 75cf0cb1..37819435 100644 --- a/packages/web/src/components/EditorLayout/index.jsx +++ b/packages/web/src/components/EditorLayout/index.jsx @@ -59,23 +59,25 @@ export default function EditorLayout() { const onFlowStatusUpdate = React.useCallback( async (active) => { - await updateFlowStatus({ - variables: { - input: { - id: flowId, - active, + try { + await updateFlowStatus({ + variables: { + input: { + id: flowId, + active, + }, }, - }, - optimisticResponse: { - updateFlowStatus: { - __typename: 'Flow', - id: flowId, - active, + optimisticResponse: { + updateFlowStatus: { + __typename: 'Flow', + id: flowId, + active, + }, }, - }, - }); + }); - await queryClient.invalidateQueries({ queryKey: ['flows', flowId] }); + await queryClient.invalidateQueries({ queryKey: ['flows', flowId] }); + } catch (err) {} }, [flowId, queryClient], );