Skip to content

Commit

Permalink
fix: update parentPage's childPages duplicate issue on page update
Browse files Browse the repository at this point in the history
  • Loading branch information
schettn committed Aug 5, 2024
1 parent 78852c2 commit e7218e8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions packages/jaen/src/redux/slices/page.ts
Original file line number Diff line number Diff line change
Expand Up @@ -125,12 +125,16 @@ const pagesSlice = createSlice({

// Add the page to the new parentPages' childPages
if (parentPageId) {
const childPages = state.nodes[parentPageId]?.childPages || [{id}]

if (!childPages.find(e => e.id === id)) {
childPages.push({id})
}

state.nodes[parentPageId] = {
modifiedAt,
...state.nodes[parentPageId],
childPages: state.nodes[parentPageId]?.childPages
? [...(state.nodes[parentPageId]?.childPages || []), {id}]
: [{id}]
childPages
}
}

Expand Down

0 comments on commit e7218e8

Please sign in to comment.