fix(shareModal/index.tsx): remove unused useRef variable tagListId to improve code readability and maintainability
fix(storeUtils.ts): update getTagsIds function to accept an array of tag objects instead of a ref object, and remove unnecessary console.log statements
This commit is contained in:
parent
003a3e0783
commit
95ef164f83
2 changed files with 6 additions and 9 deletions
|
|
@ -1,4 +1,4 @@
|
||||||
import { ReactNode, useContext, useEffect, useRef, useState } from "react";
|
import { ReactNode, useContext, useEffect, useState } from "react";
|
||||||
import EditFlowSettings from "../../components/EditFlowSettingsComponent";
|
import EditFlowSettings from "../../components/EditFlowSettingsComponent";
|
||||||
import IconComponent from "../../components/genericIconComponent";
|
import IconComponent from "../../components/genericIconComponent";
|
||||||
import { TagsSelector } from "../../components/tagsSelectorComponent";
|
import { TagsSelector } from "../../components/tagsSelectorComponent";
|
||||||
|
|
@ -43,7 +43,6 @@ export default function ShareModal({
|
||||||
const [sharePublic, setSharePublic] = useState(true);
|
const [sharePublic, setSharePublic] = useState(true);
|
||||||
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
const [selectedTags, setSelectedTags] = useState<string[]>([]);
|
||||||
const [unavaliableNames, setUnavaliableNames] = useState<string[]>([]);
|
const [unavaliableNames, setUnavaliableNames] = useState<string[]>([]);
|
||||||
const tagListId = useRef<{ id: string; name: string }[]>([]);
|
|
||||||
|
|
||||||
useEffect(() => {
|
useEffect(() => {
|
||||||
handleGetTags();
|
handleGetTags();
|
||||||
|
|
@ -91,11 +90,7 @@ export default function ShareModal({
|
||||||
last_tested_version: version,
|
last_tested_version: version,
|
||||||
is_component: is_component,
|
is_component: is_component,
|
||||||
});
|
});
|
||||||
saveFlowStore(
|
saveFlowStore(saveFlow, getTagsIds(selectedTags, tags), sharePublic).then(
|
||||||
saveFlow,
|
|
||||||
getTagsIds(selectedTags, tagListId),
|
|
||||||
sharePublic
|
|
||||||
).then(
|
|
||||||
() => {
|
() => {
|
||||||
if (is_component) {
|
if (is_component) {
|
||||||
addFlow(true, saveFlow);
|
addFlow(true, saveFlow);
|
||||||
|
|
|
||||||
|
|
@ -15,9 +15,11 @@ export default function cloneFLowWithParent(
|
||||||
|
|
||||||
export function getTagsIds(
|
export function getTagsIds(
|
||||||
tags: string[],
|
tags: string[],
|
||||||
tagListId: { current: { name: string; id: string }[] }
|
tagListId: { name: string; id: string }[]
|
||||||
) {
|
) {
|
||||||
|
console.log(tags);
|
||||||
|
console.log(tagListId);
|
||||||
return tags
|
return tags
|
||||||
.map((tag) => tagListId.current.find((tagObj) => tagObj.name === tag))!
|
.map((tag) => tagListId.find((tagObj) => tagObj.name === tag))!
|
||||||
.map((tag) => tag!.id);
|
.map((tag) => tag!.id);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue