Skip to content

Commit

Permalink
[stu-343-edit-sequence-name-descriotion] chore: using Immer + remove …
Browse files Browse the repository at this point in the history
…useless spread operation
  • Loading branch information
LatentDream committed Apr 15, 2024
1 parent 0b5e84a commit ff39d3e
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -273,18 +273,17 @@ export function SequenceTable() {
toast.error("Sequence name must be unique");
return;
}
setSequences(
[...sequences].map((seq, idx) => {
if (idx === renameForIdx.current) {
return {
...seq,
project: { ...seq.project, name: newName },
testSequenceUnsaved: true,
};
}
return seq;
}),
);
if (newName === "") {
toast.error("Sequence name cannot be empty");
return;
}
setSequences(produce(sequences, (draft) => {
const seq = draft[renameForIdx.current];
seq.project.name = newName;
seq.testSequenceUnsaved = true;
}))
setIsRenameDescModalOpen(false);

setIsRenameNameModalOpen(false);
};
const [isRenameNameModalOpen, setIsRenameNameModalOpen] = useState(false);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ export async function saveSequence(
}
// Set the sequence as saved
stateManager.setSequences(
[...stateManager.sequences].map((seq) => {
stateManager.sequences.map((seq) => {
if (seq.project.name === sequence.name) {
return { ...seq, testSequenceUnsaved: false };
}
Expand Down Expand Up @@ -121,7 +121,7 @@ export async function saveSequences(
return err(res.error);
}
stateManager.setSequences(
[...stateManager.sequences].map((seq) => ({
stateManager.sequences.map((seq) => ({
...seq,
testSequenceUnsaved: false,
})),
Expand Down

0 comments on commit ff39d3e

Please sign in to comment.