Skip to content

Commit

Permalink
change name of hasOutlineBlock function
Browse files Browse the repository at this point in the history
  • Loading branch information
Imran92 committed Jan 1, 2024
1 parent f749ad7 commit 3d82cd5
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 7 deletions.
10 changes: 5 additions & 5 deletions assets/js/admin/first-course-creation-notice.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,14 +11,14 @@ import { find as findObject } from 'lodash';
*/
import { getFirstBlockByName } from '../../blocks/course-outline/data';

export const hasOutlineBlock = () =>
export const getOutlineBlock = () =>
getFirstBlockByName(
'sensei-lms/course-outline',
select( 'core/block-editor' ).getBlocks()
);

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

// If the course outline block doesn't exist, create it and insert it.
if ( ! courseOutlineBlock ) {
Expand Down Expand Up @@ -142,8 +142,8 @@ export const handleFirstCourseCreationHelperNotice = () => {
if (
noticeCreated &&
! noticeRemoved &&
hasOutlineBlock() &&
hasLessonInOutline( [ hasOutlineBlock() ] )
getOutlineBlock() &&
hasLessonInOutline( [ getOutlineBlock() ] )
) {
noticeRemoved = true;
noticeCreated = false;
Expand All @@ -156,7 +156,7 @@ export const handleFirstCourseCreationHelperNotice = () => {
! noticeCreated &&
! isFirstCourseNoticeDismissed &&
! (
hasOutlineBlock() && hasLessonInOutline( [ hasOutlineBlock() ] )
getOutlineBlock() && hasLessonInOutline( [ getOutlineBlock() ] )
)
) {
noticeCreated = true;
Expand Down
4 changes: 2 additions & 2 deletions assets/js/admin/first-course-creation-notice.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { dispatch, select, subscribe } from '@wordpress/data';
* Internal dependencies
*/
import {
hasOutlineBlock,
getOutlineBlock,
handleCourseOutlineBlockIncomplete,
handleFirstCourseCreationHelperNotice,
hasLessonInOutline,
Expand Down Expand Up @@ -81,7 +81,7 @@ describe( 'handleCourseOutlineBlockIncomplete', () => {
.handleCourseOutlineBlockIncomplete
);
getFirstBlockByName.mockClear();
hasOutlineBlock.mockClear();
getOutlineBlock.mockClear();
createBlock.mockClear();
} );
it( 'should create and insert a block when no course outline block exists', () => {
Expand Down

0 comments on commit 3d82cd5

Please sign in to comment.