Skip to content

Commit

Permalink
Manually select outline block only when available
Browse files Browse the repository at this point in the history
  • Loading branch information
Imran92 committed Jan 1, 2024
1 parent ee75e87 commit a633f08
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions assets/js/admin/first-course-creation-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,17 +18,17 @@ export const getOutlineBlock = () =>
);

export const handleCourseOutlineBlockIncomplete = async () => {
let courseOutlineBlock = getOutlineBlock();
const courseOutlineBlock = getOutlineBlock();

// If the course outline block doesn't exist, create it and insert it.
if ( ! courseOutlineBlock ) {
const { insertBlock } = dispatch( 'core/block-editor' );

courseOutlineBlock = createBlock( 'sensei-lms/course-outline' );
await insertBlock( courseOutlineBlock );
// If the course outline block exists, just select it.
if ( courseOutlineBlock ) {
dispatch( 'core/editor' ).selectBlock( courseOutlineBlock.clientId );
return;
}

dispatch( 'core/editor' ).selectBlock( courseOutlineBlock.clientId );
const { insertBlock } = dispatch( 'core/block-editor' );

insertBlock( createBlock( 'sensei-lms/course-outline' ) );
};

// If the function isn't globally available, the link button doesn't find the reference.
Expand Down

0 comments on commit a633f08

Please sign in to comment.