Sindbad~EG File Manager

Current Path : /home/frekansk/www/wp-content/plugins/learnpress/assets/src/apps/js/admin/editor/actions/
Upload File :
Current File : /home/frekansk/www/wp-content/plugins/learnpress/assets/src/apps/js/admin/editor/actions/course.js

const Course = {
	heartbeat: function( context ) {
		LP.Request( {
			type: 'heartbeat',
		} ).then(
			function( response ) {
				var result = response.body;
				context.commit( 'UPDATE_HEART_BEAT', !! result.success );
			},
			function( error ) {
				context.commit( 'UPDATE_HEART_BEAT', false );
			}
		);
	},

	draftCourse: function( context, payload ) {
		var auto_draft = context.getters.autoDraft;

		if ( auto_draft ) {
			LP.Request( {
				type: 'draft-course',
				course: JSON.stringify( payload ),
			} ).then( function( response ) {
				var result = response.body;

				if ( ! result.success ) {
					return;
				}

				context.commit( 'UPDATE_AUTO_DRAFT_STATUS', false );
			}
			);
		}
	},

	newRequest: function( context ) {
		context.commit( 'INCREASE_NUMBER_REQUEST' );
		context.commit( 'UPDATE_STATUS', 'loading' );

		window.onbeforeunload = function() {
			return '';
		};
	},

	requestCompleted: function( context, status ) {
		context.commit( 'DECREASE_NUMBER_REQUEST' );

		if ( context.getters.currentRequest === 0 ) {
			context.commit( 'UPDATE_STATUS', status );
			window.onbeforeunload = null;
		}
	},
};

export default Course;

Sindbad File Manager Version 1.0, Coded By Sindbad EG ~ The Terrorists