Skip to content

Commit

Permalink
Check for undefined Value When Deleting Pages (#1902)
Browse files Browse the repository at this point in the history
* Check if node is defined before reading ID property

* Revert "Check if node is defined before reading ID property"

This reverts commit c24cf3f.

* Pass node to deleteNode when deleting a SitePage node

* Fix import
  • Loading branch information
deniaz authored and KyleAMathews committed Aug 24, 2017
1 parent ef6b391 commit 71c3596
Showing 1 changed file with 4 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ const _ = require(`lodash`)

const { emitter } = require(`../../redux`)
const { boundActionCreators } = require(`../../redux/actions`)
const { getNode } = require(`../../redux`)

function transformPackageJson(json) {
const transformDeps = deps =>
Expand Down Expand Up @@ -149,5 +150,7 @@ exports.onCreatePage = ({ page, boundActionCreators }) => {

// Listen for DELETE_PAGE and delete page nodes.
emitter.on(`DELETE_PAGE`, action => {
boundActionCreators.deleteNode(createPageId(action.payload.path))
const nodeId = createPageId(action.payload.path)
const node = getNode(nodeId)
boundActionCreators.deleteNode(nodeId, node)
})

0 comments on commit 71c3596

Please sign in to comment.