Skip to content

Commit

Permalink
reverts all changes to the navigation blocks hook
Browse files Browse the repository at this point in the history
  • Loading branch information
draganescu committed May 29, 2020
1 parent 5880467 commit e4849f5
Showing 1 changed file with 5 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,8 @@ export default function useNavigationBlocks( menuId ) {
[ menuId ]
);

const { saveMenuItem, deleteMenuItem } = useDispatch( 'core' );
const { saveMenuItem } = useDispatch( 'core' );
const { createSuccessNotice } = useDispatch( 'core/notices' );

const [ blocks, setBlocks ] = useState( [] );

const menuItemsRef = useRef( {} );
Expand Down Expand Up @@ -123,31 +122,15 @@ export default function useNavigationBlocks( menuId ) {

saveNestedBlocks( innerBlocks, parentItemId );

const getCurrentMenuItemBlocks = (
currentBlocks,
currentBlockList
) => {
currentBlocks.forEach( ( block ) => {
currentBlockList.push( block.clientId );
getCurrentMenuItemBlocks( block.innerBlocks, currentBlockList );
} );
return currentBlockList;
};

let currentBlockClientIds = [];
currentBlockClientIds = getCurrentMenuItemBlocks(
innerBlocks,
currentBlockClientIds
);

const deletedClientIds = difference(
Object.keys( menuItemsRef.current ),
currentBlockClientIds
innerBlocks.map( ( block ) => block.clientId )
);

// Disable reason, this code will eventually be implemented.
// eslint-disable-next-line no-unused-vars
for ( const deletedClientId of deletedClientIds ) {
const menuItem = menuItemsRef.current[ deletedClientId ];
deleteMenuItem( menuItem.id );
// TODO - delete menu items.
}

createSuccessNotice( __( 'Navigation saved.' ), {
Expand Down

0 comments on commit e4849f5

Please sign in to comment.