@@ -10,9 +10,8 @@ import { NOTIFICATION_MESSAGES } from '../../constants';
1010import { updateModel , updateModels } from '../../generic/model-store' ;
1111import { messageTypes } from '../constants' ;
1212import {
13- getCourseUnitData ,
1413 editUnitDisplayName ,
15- getCourseSectionVerticalData ,
14+ getVerticalData ,
1615 createCourseXblock ,
1716 getCourseVerticalChildren ,
1817 handleCourseUnitVisibilityAndData ,
@@ -22,8 +21,6 @@ import {
2221 patchUnitItem ,
2322} from './api' ;
2423import {
25- updateLoadingCourseUnitStatus ,
26- fetchCourseItemSuccess ,
2724 updateSavingStatus ,
2825 fetchSequenceRequest ,
2926 fetchSequenceFailure ,
@@ -40,30 +37,13 @@ import {
4037} from './slice' ;
4138import { getNotificationMessage } from './utils' ;
4239
43- export function fetchCourseUnitQuery ( courseId ) {
44- return async ( dispatch ) => {
45- dispatch ( updateLoadingCourseUnitStatus ( { status : RequestStatus . IN_PROGRESS } ) ) ;
46-
47- try {
48- const courseUnit = await getCourseUnitData ( courseId ) ;
49-
50- dispatch ( fetchCourseItemSuccess ( courseUnit ) ) ;
51- dispatch ( updateLoadingCourseUnitStatus ( { status : RequestStatus . SUCCESSFUL } ) ) ;
52- return true ;
53- } catch ( error ) {
54- dispatch ( updateLoadingCourseUnitStatus ( { status : RequestStatus . FAILED } ) ) ;
55- return false ;
56- }
57- } ;
58- }
59-
6040export function fetchCourseSectionVerticalData ( courseId , sequenceId ) {
6141 return async ( dispatch ) => {
6242 dispatch ( updateLoadingCourseSectionVerticalDataStatus ( { status : RequestStatus . IN_PROGRESS } ) ) ;
6343 dispatch ( fetchSequenceRequest ( { sequenceId } ) ) ;
6444
6545 try {
66- const courseSectionVerticalData = await getCourseSectionVerticalData ( courseId ) ;
46+ const courseSectionVerticalData = await getVerticalData ( courseId ) ;
6747 dispatch ( fetchCourseSectionVerticalDataSuccess ( courseSectionVerticalData ) ) ;
6848 dispatch ( updateLoadingCourseSectionVerticalDataStatus ( { status : RequestStatus . SUCCESSFUL } ) ) ;
6949 dispatch ( updateModel ( {
@@ -94,8 +74,7 @@ export function editCourseItemQuery(itemId, displayName, sequenceId) {
9474 try {
9575 await editUnitDisplayName ( itemId , displayName ) . then ( async ( result ) => {
9676 if ( result ) {
97- const courseUnit = await getCourseUnitData ( itemId ) ;
98- const courseSectionVerticalData = await getCourseSectionVerticalData ( itemId ) ;
77+ const courseSectionVerticalData = await getVerticalData ( itemId ) ;
9978 dispatch ( fetchCourseSectionVerticalDataSuccess ( courseSectionVerticalData ) ) ;
10079 dispatch ( updateLoadingCourseSectionVerticalDataStatus ( { status : RequestStatus . SUCCESSFUL } ) ) ;
10180 dispatch ( updateModel ( {
@@ -107,7 +86,6 @@ export function editCourseItemQuery(itemId, displayName, sequenceId) {
10786 models : courseSectionVerticalData . units || [ ] ,
10887 } ) ) ;
10988 dispatch ( fetchSequenceSuccess ( { sequenceId } ) ) ;
110- dispatch ( fetchCourseItemSuccess ( courseUnit ) ) ;
11189 dispatch ( hideProcessingNotification ( ) ) ;
11290 dispatch ( updateSavingStatus ( { status : RequestStatus . SUCCESSFUL } ) ) ;
11391 }
@@ -146,8 +124,8 @@ export function editCourseUnitVisibilityAndData(
146124 if ( callback ) {
147125 callback ( ) ;
148126 }
149- const courseUnit = await getCourseUnitData ( blockId ) ;
150- dispatch ( fetchCourseItemSuccess ( courseUnit ) ) ;
127+ const courseSectionVerticalData = await getVerticalData ( blockId ) ;
128+ dispatch ( fetchCourseSectionVerticalDataSuccess ( courseSectionVerticalData ) ) ;
151129 const courseVerticalChildrenData = await getCourseVerticalChildren ( blockId ) ;
152130 dispatch ( updateCourseVerticalChildren ( courseVerticalChildrenData ) ) ;
153131 dispatch ( hideProcessingNotification ( ) ) ;
@@ -174,7 +152,7 @@ export function createNewCourseXBlock(body, callback, blockId, sendMessageToIfra
174152 if ( result ) {
175153 const formattedResult = camelCaseObject ( result ) ;
176154 if ( body . category === 'vertical' ) {
177- const courseSectionVerticalData = await getCourseSectionVerticalData ( formattedResult . locator ) ;
155+ const courseSectionVerticalData = await getVerticalData ( formattedResult . locator ) ;
178156 dispatch ( fetchCourseSectionVerticalDataSuccess ( courseSectionVerticalData ) ) ;
179157 }
180158 if ( body . stagedContent ) {
@@ -194,8 +172,8 @@ export function createNewCourseXBlock(body, callback, blockId, sendMessageToIfra
194172 sendMessageToIframe ( messageTypes . addXBlock , { data : result } ) ;
195173 }
196174 const currentBlockId = body . category === 'vertical' ? formattedResult . locator : blockId ;
197- const courseUnit = await getCourseUnitData ( currentBlockId ) ;
198- dispatch ( fetchCourseItemSuccess ( courseUnit ) ) ;
175+ const courseSectionVerticalData = await getVerticalData ( currentBlockId ) ;
176+ dispatch ( fetchCourseSectionVerticalDataSuccess ( courseSectionVerticalData ) ) ;
199177 }
200178 } ) ;
201179 } catch ( error ) {
@@ -240,8 +218,8 @@ export function deleteUnitItemQuery(itemId, xblockId, sendMessageToIframe) {
240218 try {
241219 await deleteUnitItem ( xblockId ) ;
242220 sendMessageToIframe ( messageTypes . completeXBlockDeleting , { locator : xblockId } ) ;
243- const courseUnit = await getCourseUnitData ( itemId ) ;
244- dispatch ( fetchCourseItemSuccess ( courseUnit ) ) ;
221+ const courseSectionVerticalData = await getVerticalData ( itemId ) ;
222+ dispatch ( fetchCourseSectionVerticalDataSuccess ( courseSectionVerticalData ) ) ;
245223 dispatch ( hideProcessingNotification ( ) ) ;
246224 dispatch ( updateSavingStatus ( { status : RequestStatus . SUCCESSFUL } ) ) ;
247225 } catch ( error ) {
@@ -259,8 +237,8 @@ export function duplicateUnitItemQuery(itemId, xblockId, callback) {
259237 try {
260238 const { courseKey, locator } = await duplicateUnitItem ( itemId , xblockId ) ;
261239 callback ( courseKey , locator ) ;
262- const courseUnit = await getCourseUnitData ( itemId ) ;
263- dispatch ( fetchCourseItemSuccess ( courseUnit ) ) ;
240+ const courseSectionVerticalData = await getVerticalData ( itemId ) ;
241+ dispatch ( fetchCourseSectionVerticalDataSuccess ( courseSectionVerticalData ) ) ;
264242 const courseVerticalChildrenData = await getCourseVerticalChildren ( itemId ) ;
265243 dispatch ( updateCourseVerticalChildren ( courseVerticalChildrenData ) ) ;
266244 dispatch ( hideProcessingNotification ( ) ) ;
@@ -316,8 +294,8 @@ export function patchUnitItemQuery({
316294 dispatch ( updateCourseOutlineInfoLoadingStatus ( { status : RequestStatus . IN_PROGRESS } ) ) ;
317295 callbackFn ( sourceLocator ) ;
318296 try {
319- const courseUnit = await getCourseUnitData ( currentParentLocator ) ;
320- dispatch ( fetchCourseItemSuccess ( courseUnit ) ) ;
297+ const courseSectionVerticalData = await getVerticalData ( currentParentLocator ) ;
298+ dispatch ( fetchCourseSectionVerticalDataSuccess ( courseSectionVerticalData ) ) ;
321299 } catch ( error ) {
322300 handleResponseErrors ( error , dispatch , updateSavingStatus ) ;
323301 }
@@ -335,8 +313,8 @@ export function updateCourseUnitSidebar(itemId) {
335313 dispatch ( showProcessingNotification ( NOTIFICATION_MESSAGES . saving ) ) ;
336314
337315 try {
338- const courseUnit = await getCourseUnitData ( itemId ) ;
339- dispatch ( fetchCourseItemSuccess ( courseUnit ) ) ;
316+ const courseSectionVerticalData = await getVerticalData ( itemId ) ;
317+ dispatch ( fetchCourseSectionVerticalDataSuccess ( courseSectionVerticalData ) ) ;
340318 dispatch ( hideProcessingNotification ( ) ) ;
341319 dispatch ( updateSavingStatus ( { status : RequestStatus . SUCCESSFUL } ) ) ;
342320 } catch ( error ) {
0 commit comments