fix: fetch only studio home data without courses
This commit is contained in:
committed by
Muhammad Farhan
parent
a26e3f9e92
commit
cc20dfd8ca
@@ -11,7 +11,7 @@ import { fetchCourseDetail, fetchWaffleFlags } from './data/thunks';
|
||||
import { useModel } from './generic/model-store';
|
||||
import NotFoundAlert from './generic/NotFoundAlert';
|
||||
import PermissionDeniedAlert from './generic/PermissionDeniedAlert';
|
||||
import { fetchStudioHomeData } from './studio-home/data/thunks';
|
||||
import { fetchOnlyStudioHomeData } from './studio-home/data/thunks';
|
||||
import { getCourseAppsApiStatus } from './pages-and-resources/data/selectors';
|
||||
import { RequestStatus } from './data/constants';
|
||||
import Loading from './generic/Loading';
|
||||
@@ -25,7 +25,7 @@ const CourseAuthoringPage = ({ courseId, children }) => {
|
||||
}, [courseId]);
|
||||
|
||||
useEffect(() => {
|
||||
dispatch(fetchStudioHomeData());
|
||||
dispatch(fetchOnlyStudioHomeData());
|
||||
}, []);
|
||||
|
||||
const courseDetail = useModel('courseDetails', courseId);
|
||||
|
||||
@@ -16,10 +16,15 @@ import {
|
||||
fetchCourseDataSuccessV2,
|
||||
} from './slice';
|
||||
|
||||
function fetchStudioHomeData(search, hasHomeData, requestParams = {}, isPaginationEnabled = false) {
|
||||
function fetchStudioHomeData(
|
||||
search,
|
||||
hasHomeData,
|
||||
requestParams = {},
|
||||
isPaginationEnabled = false,
|
||||
shouldFetchCourses = true,
|
||||
) {
|
||||
return async (dispatch) => {
|
||||
dispatch(updateLoadingStatuses({ studioHomeLoadingStatus: RequestStatus.IN_PROGRESS }));
|
||||
dispatch(updateLoadingStatuses({ courseLoadingStatus: RequestStatus.IN_PROGRESS }));
|
||||
|
||||
if (!hasHomeData) {
|
||||
try {
|
||||
@@ -31,22 +36,30 @@ function fetchStudioHomeData(search, hasHomeData, requestParams = {}, isPaginati
|
||||
return;
|
||||
}
|
||||
}
|
||||
try {
|
||||
if (isPaginationEnabled) {
|
||||
const coursesData = await getStudioHomeCoursesV2(search || '', requestParams);
|
||||
dispatch(fetchCourseDataSuccessV2(coursesData));
|
||||
} else {
|
||||
const coursesData = await getStudioHomeCourses(search || '');
|
||||
dispatch(fetchCourseDataSuccess(coursesData));
|
||||
}
|
||||
if (shouldFetchCourses) {
|
||||
dispatch(updateLoadingStatuses({ courseLoadingStatus: RequestStatus.IN_PROGRESS }));
|
||||
try {
|
||||
if (isPaginationEnabled) {
|
||||
const coursesData = await getStudioHomeCoursesV2(search || '', requestParams);
|
||||
dispatch(fetchCourseDataSuccessV2(coursesData));
|
||||
} else {
|
||||
const coursesData = await getStudioHomeCourses(search || '');
|
||||
dispatch(fetchCourseDataSuccess(coursesData));
|
||||
}
|
||||
|
||||
dispatch(updateLoadingStatuses({ courseLoadingStatus: RequestStatus.SUCCESSFUL }));
|
||||
} catch (error) {
|
||||
dispatch(updateLoadingStatuses({ courseLoadingStatus: RequestStatus.FAILED }));
|
||||
dispatch(updateLoadingStatuses({ courseLoadingStatus: RequestStatus.SUCCESSFUL }));
|
||||
} catch (error) {
|
||||
dispatch(updateLoadingStatuses({ courseLoadingStatus: RequestStatus.FAILED }));
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
function fetchOnlyStudioHomeData() {
|
||||
// Wrapper function to fetch only studio home data (without fetching courses)
|
||||
return fetchStudioHomeData('', false, {}, false, false);
|
||||
}
|
||||
|
||||
function fetchLibraryData() {
|
||||
return async (dispatch) => {
|
||||
dispatch(updateLoadingStatuses({ libraryLoadingStatus: RequestStatus.IN_PROGRESS }));
|
||||
@@ -91,6 +104,7 @@ function requestCourseCreatorQuery() {
|
||||
|
||||
export {
|
||||
fetchStudioHomeData,
|
||||
fetchOnlyStudioHomeData,
|
||||
fetchLibraryData,
|
||||
requestCourseCreatorQuery,
|
||||
handleDeleteNotificationQuery,
|
||||
|
||||
Reference in New Issue
Block a user