From f12f952b376f470792ebaf0fd05bd9801418f285 Mon Sep 17 00:00:00 2001 From: Fedor Katurov Date: Tue, 28 Sep 2021 16:20:16 +0700 Subject: [PATCH] skipping tag update on empty tags --- src/components/tags/Tags/index.tsx | 8 +++++++- src/redux/node/sagas.ts | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/tags/Tags/index.tsx b/src/components/tags/Tags/index.tsx index 6b06db52..0f4acf4b 100644 --- a/src/components/tags/Tags/index.tsx +++ b/src/components/tags/Tags/index.tsx @@ -35,7 +35,13 @@ export const Tags: FC = ({ } const exist = tags.map(tag => tag.title); - onTagsChange(uniq([...exist, ...data, ...last]).filter(el => el) as string[]); + const uniqueTags = uniq([...exist, ...data, ...last]).filter(el => el) as string[]; + + if (uniqueTags.length === exist.length) { + return; + } + + onTagsChange(uniqueTags); }, [data] ); diff --git a/src/redux/node/sagas.ts b/src/redux/node/sagas.ts index 22510d40..8243d16d 100644 --- a/src/redux/node/sagas.ts +++ b/src/redux/node/sagas.ts @@ -252,6 +252,7 @@ function* onDeleteTag({ id, tagId }: ReturnType) { try { const { tags }: Unwrap = yield call(apiDeleteNodeTag, { id, tagId }); yield put(nodeSetTags(tags)); + yield call(nodeGetRelated, id); } catch {} }