Skip to content

Commit

Permalink
= 4.2.5.9 =
Browse files Browse the repository at this point in the history
~ Send idItemViewing to API.
  • Loading branch information
tungnxt89 committed Jan 5, 2024
1 parent d3fea4b commit 7c4c3f4
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
17 changes: 17 additions & 0 deletions assets/src/apps/js/frontend/single-curriculum/skeleton.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,22 @@ import scrollToItemCurrent from './scrolltoitem';
import { searchCourseContent } from './components/search';

export default function courseCurriculumSkeleton( courseID = '' ) {
let idItemViewing = 0;
const elItemViewing = document.querySelector( '.viewing-course-item' );
if ( elItemViewing ) {
const regex = new RegExp( '^viewing-course-item-([0-9].*)' );
const classList = elItemViewing.classList;

classList.forEach( function( className ) {
const compare = regex.exec( className );

if ( compare ) {
idItemViewing = compare[ 1 ];
return false;
}
} );
}

let isLoadingItems = false;
let isLoadingSections = false;
const Sekeleton = () => {
Expand All @@ -31,6 +47,7 @@ export default function courseCurriculumSkeleton( courseID = '' ) {
courseId: courseID || lpGlobalSettings.post_id || '',
page,
sectionID: sectionID || '',
idItemViewing,
} );
let paramsFetch = {};
if ( 0 !== parseInt( lpData.user_id ) ) {
Expand Down
21 changes: 11 additions & 10 deletions inc/rest-api/v1/frontend/class-lp-rest-lazy-load-controller.php
Original file line number Diff line number Diff line change
Expand Up @@ -168,13 +168,14 @@ public function user_progress( WP_REST_Request $request ): LP_REST_Response {
* @version 1.0.2
*/
public function course_curriculum( WP_REST_Request $request ): LP_REST_Response {
$response = new LP_REST_Response();
$params = $request->get_params();
$total_rows = 0;
$course_id = absint( $params['courseId'] ?? 0 );
$per_page = LP_Settings::get_option( 'section_per_page', -1 );
$page = absint( $params['page'] ?? 1 );
$section_id = wp_unslash( $params['sectionID'] ?? false );
$response = new LP_REST_Response();
$params = $request->get_params();
$total_rows = 0;
$course_id = absint( $params['courseId'] ?? 0 );
$per_page = LP_Settings::get_option( 'section_per_page', - 1 );
$page = absint( $params['page'] ?? 1 );
$section_id = wp_unslash( $params['sectionID'] ?? false );
$item_viewing = absint( $params['idItemViewing'] ?? 0 );

try {
ob_start();
Expand Down Expand Up @@ -243,17 +244,17 @@ public function course_curriculum( WP_REST_Request $request ): LP_REST_Response
*
* @param WP_REST_Request $request
*
* @author nhamdv
* @return WP_REST_Response|WP_Error
* @since 4.1.5
* @version 1.0.2
* @return WP_REST_Response|WP_Error
* @author nhamdv
*/
public function course_curriculum_items( WP_REST_Request $request ) {
$params = $request->get_params();

$section_id = absint( $params['sectionId'] ?? 0 );
$course_id = absint( $params['courseId'] ?? 0 );
$per_page = LP_Settings::get_option( 'course_item_per_page', -1 );
$per_page = LP_Settings::get_option( 'course_item_per_page', - 1 );
$page = absint( $params['page'] ?? 1 );

$response = new LP_REST_Response();
Expand Down

0 comments on commit 7c4c3f4

Please sign in to comment.