From 63f1465d76a40d5e909a8b330e6e04e3c8b005f9 Mon Sep 17 00:00:00 2001 From: roboto84 <7658704+roboto84@users.noreply.github.com> Date: Thu, 23 Nov 2023 09:19:52 -0500 Subject: [PATCH] fix(search): bug with tags count on record update --- src/views/search/arcadia/components/ArcResult/ArcResult.tsx | 4 +--- .../components/ArcResultEdit/ArcResultEditConfirm.tsx | 4 ++-- src/views/search/components/AddRecord/AddRecord.tsx | 4 +--- 3 files changed, 4 insertions(+), 8 deletions(-) diff --git a/src/views/search/arcadia/components/ArcResult/ArcResult.tsx b/src/views/search/arcadia/components/ArcResult/ArcResult.tsx index a0c8da5..3eb311c 100644 --- a/src/views/search/arcadia/components/ArcResult/ArcResult.tsx +++ b/src/views/search/arcadia/components/ArcResult/ArcResult.tsx @@ -41,9 +41,7 @@ export function ArcResult(props: ArcResultProps) { { deep: true }, ); - if (state.tags.length !== camelCasedData.numberOfSubjects) { - dispatch({ type: SearchActionsEnum.LOAD_TAGS, value: camelCasedData.subjectsCounts }); - } + dispatch({ type: SearchActionsEnum.LOAD_TAGS, value: camelCasedData.subjectsCounts }); }); }; diff --git a/src/views/search/arcadia/components/ArcResult/components/ArcResultEdit/ArcResultEditConfirm.tsx b/src/views/search/arcadia/components/ArcResult/components/ArcResultEdit/ArcResultEditConfirm.tsx index 8dc689b..789bbd9 100644 --- a/src/views/search/arcadia/components/ArcResult/components/ArcResultEdit/ArcResultEditConfirm.tsx +++ b/src/views/search/arcadia/components/ArcResult/components/ArcResultEdit/ArcResultEditConfirm.tsx @@ -22,7 +22,6 @@ export function ArcResultEditConfirm(props: ArcResultEditConfirmProps) { if (!isFetching) { if (isError && error) { editResult.editingMessage = `An error has occurred editing: ${itemEditPackage.data}`; - onEditConfirmed(editResult); } else if (data) { const arcDeleteResult: ArcEditItemResults = camelcaseKeys( data, @@ -34,8 +33,9 @@ export function ArcResultEditConfirm(props: ArcResultEditConfirmProps) { } else { editResult.editingMessage = 'There was an issue with editing this record'; } - onEditConfirmed(editResult); } + // TODO: Rid ourselves of the dependence on JS call stack manipulation here + setTimeout(() => onEditConfirmed(editResult), 0); } return ( diff --git a/src/views/search/components/AddRecord/AddRecord.tsx b/src/views/search/components/AddRecord/AddRecord.tsx index 51a3486..362338d 100644 --- a/src/views/search/components/AddRecord/AddRecord.tsx +++ b/src/views/search/components/AddRecord/AddRecord.tsx @@ -53,9 +53,7 @@ export function AddRecord(props: AddRecordProps) { { deep: true }, ); - if (state.tags.length !== camelCasedData.numberOfSubjects) { - dispatch({ type: SearchActionsEnum.LOAD_TAGS, value: camelCasedData.subjectsCounts }); - } + dispatch({ type: SearchActionsEnum.LOAD_TAGS, value: camelCasedData.subjectsCounts }); }); };