fix: fetch only studio home data without courses
This commit is contained in:
committed by
Muhammad Farhan
parent
a26e3f9e92
commit
cc20dfd8ca
@@ -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