Skip to content

Commit

Permalink
Merge pull request #37 from EyeSeeTea/fix/migrations
Browse files Browse the repository at this point in the history
Fix deleted sections on migrations executed
  • Loading branch information
adrianq authored Jul 3, 2024
2 parents 2ade2d5 + 66e93fc commit 99ab1bc
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions src/migrations/tasks/02.remove-duplicated-nodes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,11 @@ class RemoveDuplicatedNodesMigration {
const fixedTrees = landingTrees.map(tree =>
tree.reduce<PersistedLandingPage>((acc, node) => {
const inParentTree =
node.parent === "none" || node.type === "root" || acc.some(parent => parent.id === node.parent);
const alreadyExist = acc.some(n => n.id === node.id);
node.parent === "none" ||
node.type === "root" ||
tree.some(maybeParent => maybeParent.id === node.parent); // To avoid nodes out of place

const alreadyExist = acc.some(n => n.id === node.id); // To avoid duplicated nodes
if (inParentTree && !alreadyExist) {
return [...acc, node];
} else {
Expand Down

0 comments on commit 99ab1bc

Please sign in to comment.