Clean up error messages part 3
This commit is contained in:
parent
ddad27c800
commit
07cdac120a
@ -3885,10 +3885,7 @@ if ( ! wp_doing_ajax() ) {
|
||||
function fictioneer_ajax_get_auth() {
|
||||
// Enabled?
|
||||
if ( ! get_option( 'fictioneer_enable_ajax_authentication' ) ) {
|
||||
wp_send_json_error(
|
||||
array( 'error' => __( 'Not allowed.', 'fictioneer' ) ),
|
||||
403
|
||||
);
|
||||
wp_send_json_error( null, 403 );
|
||||
}
|
||||
|
||||
// Setup
|
||||
|
@ -121,9 +121,9 @@ function fictioneer_preprocess_comment( $commentdata ) {
|
||||
// Commenting disabled
|
||||
if ( fictioneer_is_commenting_disabled( $commentdata['comment_post_ID'] ) ) {
|
||||
if ( $is_ajax ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Commenting disabled.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Commenting disabled.', 'fictioneer' ) ) );
|
||||
} else {
|
||||
wp_die( __( 'Commenting disabled.', 'fictioneer' ) );
|
||||
wp_die( 'Commenting disabled.' );
|
||||
}
|
||||
}
|
||||
|
||||
@ -136,9 +136,9 @@ function fictioneer_preprocess_comment( $commentdata ) {
|
||||
) {
|
||||
if ( ! isset( $_POST['fictioneer_comment_validator'] ) || ! $_POST['fictioneer_comment_validator'] ) {
|
||||
if ( $is_ajax ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Comment did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Comment did not pass validation.' ) );
|
||||
} else {
|
||||
wp_die( __( 'Comment did not pass validation.', 'fictioneer' ) );
|
||||
wp_die( 'Comment did not pass validation.' );
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -146,7 +146,7 @@ function fictioneer_preprocess_comment( $commentdata ) {
|
||||
// Check fictioneer_admin_disable_commenting user flag
|
||||
if ( $current_user->fictioneer_admin_disable_commenting ) {
|
||||
if ( $is_ajax ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Commenting capability disabled.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Commenting capability disabled.', 'fictioneer' ) ) );
|
||||
} else {
|
||||
wp_die( __( 'Commenting capability disabled.', 'fictioneer' ) );
|
||||
}
|
||||
@ -163,7 +163,7 @@ function fictioneer_preprocess_comment( $commentdata ) {
|
||||
$error = sprintf( __( 'You cannot post more than %s links.', 'fictioneer' ), $max_links );
|
||||
|
||||
if ( $is_ajax ) {
|
||||
wp_send_json_error( array( 'error' => $error ) );
|
||||
wp_send_json_error( array( 'failure' => $error ) );
|
||||
} else {
|
||||
wp_die( $error );
|
||||
}
|
||||
@ -216,7 +216,7 @@ function fictioneer_validate_comment_form( $commentdata ) {
|
||||
// Abort if direct parent comment is deleted
|
||||
if ( $parent_id && $commentdata['comment_type'] === 'user_deleted' ) {
|
||||
if ( $is_ajax ) {
|
||||
wp_send_json_error( array( 'error' => __( 'You cannot reply to deleted comments.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'You cannot reply to deleted comments.', 'fictioneer' ) ) );
|
||||
} else {
|
||||
wp_die( __( 'You cannot reply to deleted comments.', 'fictioneer' ) );
|
||||
}
|
||||
@ -225,7 +225,7 @@ function fictioneer_validate_comment_form( $commentdata ) {
|
||||
// Abort if direct parent comment is marked as offensive
|
||||
if ( $parent_id && get_comment_meta( $parent_id, 'fictioneer_marked_offensive', true ) ) {
|
||||
if ( $is_ajax ) {
|
||||
wp_send_json_error( array( 'error' => __( 'You cannot reply to comments marked as offensive.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'You cannot reply to comments marked as offensive.', 'fictioneer' ) ) );
|
||||
} else {
|
||||
wp_die( __( 'You cannot reply to comments marked as offensive.', 'fictioneer' ) );
|
||||
}
|
||||
@ -235,7 +235,7 @@ function fictioneer_validate_comment_form( $commentdata ) {
|
||||
if ( $parent_id && ! get_option( 'fictioneer_disable_comment_callback' ) ) {
|
||||
if ( get_comment_meta( $parent_id, 'fictioneer_thread_closed', true ) ) {
|
||||
if ( $is_ajax ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Comment thread is closed.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Comment thread is closed.', 'fictioneer' ) ) );
|
||||
} else {
|
||||
wp_die( __( 'Comment thread is closed.', 'fictioneer' ) );
|
||||
}
|
||||
@ -251,7 +251,7 @@ function fictioneer_validate_comment_form( $commentdata ) {
|
||||
// Ancestor closed?
|
||||
if ( get_comment_meta( $ancestor->comment_ID, 'fictioneer_thread_closed', true ) ) {
|
||||
if ( $is_ajax ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Comment thread is closed.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Comment thread is closed.', 'fictioneer' ) ) );
|
||||
} else {
|
||||
wp_die( __( 'Comment thread is closed.', 'fictioneer' ) );
|
||||
}
|
||||
|
@ -515,44 +515,41 @@ if ( ! function_exists( 'fictioneer_comment_mod_menu' ) ) {
|
||||
function fictioneer_ajax_moderate_comment() {
|
||||
// Enabled?
|
||||
if ( ! get_option( 'fictioneer_enable_ajax_comment_moderation' ) ) {
|
||||
wp_send_json_error(
|
||||
array( 'error' => __( 'Not allowed.', 'fictioneer' ) ),
|
||||
403
|
||||
);
|
||||
wp_send_json_error( null, 403 );
|
||||
}
|
||||
|
||||
// Setup and validations
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
$comment_id = isset( $_POST['id'] ) ? fictioneer_validate_id( $_POST['id'] ) : false;
|
||||
|
||||
if ( empty( $_POST['operation'] ) || ! $comment_id ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Missing arguments.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Missing arguments.' ) );
|
||||
}
|
||||
|
||||
$operation = sanitize_text_field( $_POST['operation'] );
|
||||
|
||||
if ( ! in_array( $operation, ['spam', 'trash', 'approve', 'unapprove', 'close', 'open', 'sticky', 'unsticky'] ) ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Invalid operation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Invalid operation.' ) );
|
||||
}
|
||||
|
||||
$comment = get_comment( $comment_id );
|
||||
|
||||
if ( ! $comment ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Comment not found in database.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Comment not found in database.' ) );
|
||||
}
|
||||
|
||||
// Capabilities?
|
||||
if ( ! fictioneer_user_can_moderate( $comment ) ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Permission denied!', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Permission denied!', 'fictioneer' ) ) );
|
||||
}
|
||||
|
||||
if ( $operation === 'trash' && ! current_user_can( 'moderate_comments' ) ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Permission denied!', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Permission denied!', 'fictioneer' ) ) );
|
||||
}
|
||||
|
||||
// Process and update
|
||||
@ -602,7 +599,7 @@ function fictioneer_ajax_moderate_comment() {
|
||||
|
||||
wp_send_json_success( array( 'id' => $comment_id, 'operation' => $operation ) );
|
||||
} else {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Comment could not be updated.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Comment could not be updated.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -628,21 +625,18 @@ function fictioneer_ajax_report_comment() {
|
||||
get_option( 'fictioneer_disable_comment_callback' ) ||
|
||||
! get_option( 'fictioneer_enable_comment_reporting' )
|
||||
) {
|
||||
wp_send_json_error(
|
||||
array( 'error' => __( 'Not allowed.', 'fictioneer' ) ),
|
||||
403
|
||||
);
|
||||
wp_send_json_error( null, 403 );
|
||||
}
|
||||
|
||||
// Setup and validations
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( ['error' => __( 'Request did not pass validation.', 'fictioneer' )] );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
if ( empty( $_POST['id'] ) ) {
|
||||
wp_send_json_error( ['error' => __( 'Missing arguments.', 'fictioneer' )] );
|
||||
wp_send_json_error( array( 'error' => 'Missing arguments.' ) );
|
||||
}
|
||||
|
||||
$comment_id = fictioneer_validate_id( $_POST['id'] );
|
||||
@ -652,12 +646,12 @@ function fictioneer_ajax_report_comment() {
|
||||
$comment = get_comment( $comment_id );
|
||||
|
||||
if ( ! $comment ) {
|
||||
wp_send_json_error( ['error' => __( 'Comment not found.', 'fictioneer' )] );
|
||||
wp_send_json_error( array( 'error' => 'Comment not found.' ) );
|
||||
}
|
||||
|
||||
// Check if user is allowed to flag comments
|
||||
if ( get_the_author_meta( 'fictioneer_admin_disable_reporting', $user->ID ) ) {
|
||||
wp_send_json_error( ['error' => __( 'Reporting capability disabled.', 'fictioneer' )] );
|
||||
wp_send_json_error( array( 'failure' => __( 'Reporting capability disabled.', 'fictioneer' ) ) );
|
||||
}
|
||||
|
||||
// Get current reports (array of user IDs)
|
||||
@ -687,7 +681,7 @@ function fictioneer_ajax_report_comment() {
|
||||
$result = fictioneer_update_comment_meta( $comment_id, 'fictioneer_user_reports', $reports );
|
||||
|
||||
if ( ! $result ) {
|
||||
wp_send_json_error( ['error' => __( 'Database error. Report could not be saved.', 'fictioneer' )] );
|
||||
wp_send_json_error( array( 'error' => 'Report could not be saved.' ) );
|
||||
}
|
||||
|
||||
// Send back to moderation?
|
||||
|
@ -19,21 +19,18 @@
|
||||
function fictioneer_ajax_save_bookmarks() {
|
||||
// Enabled?
|
||||
if ( ! get_option( 'fictioneer_enable_bookmarks' ) ) {
|
||||
wp_send_json_error(
|
||||
array( 'error' => __( 'Not allowed.', 'fictioneer' ) ),
|
||||
403
|
||||
);
|
||||
wp_send_json_error( null, 403 );
|
||||
}
|
||||
|
||||
// Setup and validations
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
if ( empty( $_POST['bookmarks'] ) ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Missing arguments.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Missing arguments.' ) );
|
||||
}
|
||||
|
||||
// Valid?
|
||||
@ -44,7 +41,7 @@ function fictioneer_ajax_save_bookmarks() {
|
||||
$decoded = json_decode( wp_unslash( $bookmarks ), true );
|
||||
|
||||
if ( ! $decoded || ! isset( $decoded['data'] ) ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Invalid JSON.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Invalid JSON.' ) );
|
||||
}
|
||||
|
||||
// Update and response (uses wp_slash/wp_unslash internally)
|
||||
@ -57,12 +54,12 @@ function fictioneer_ajax_save_bookmarks() {
|
||||
if ( update_user_meta( $user->ID, 'fictioneer_bookmarks', $bookmarks ) ) {
|
||||
wp_send_json_success();
|
||||
} else {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Bookmarks could not be updated.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Bookmarks could not be updated.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
// Something went wrong if we end up here...
|
||||
wp_send_json_error( array( 'error' => __( 'Not a valid JSON string.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'An unknown error occurred.' ) );
|
||||
}
|
||||
|
||||
if ( get_option( 'fictioneer_enable_bookmarks' ) ) {
|
||||
|
@ -136,17 +136,17 @@ function fictioneer_ajax_set_checkmark() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
if ( empty( $_POST['story_id'] ) ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Missing arguments.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Missing arguments.' ) );
|
||||
}
|
||||
|
||||
$story_id = fictioneer_validate_id( $_POST['story_id'], 'fcn_story' );
|
||||
|
||||
if ( ! $story_id ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Invalid story ID.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Invalid story ID.' ) );
|
||||
}
|
||||
|
||||
$story_data = fictioneer_get_story_data( $story_id, false ); // Does not refresh comment count!
|
||||
@ -182,7 +182,7 @@ function fictioneer_ajax_set_checkmark() {
|
||||
if ( update_user_meta( $user->ID, 'fictioneer_user_checkmarks', $checkmarks ) ) {
|
||||
wp_send_json_success();
|
||||
} else {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Checkmarks could not be updated.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Checkmarks could not be updated.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -211,14 +211,14 @@ function fictioneer_ajax_clear_my_checkmarks() {
|
||||
$user = fictioneer_get_validated_ajax_user( 'nonce', 'fictioneer_clear_checkmarks' );
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Update user
|
||||
if ( delete_user_meta( $user->ID, 'fictioneer_user_checkmarks' ) ) {
|
||||
wp_send_json_success( array( 'success' => __( 'Data has been cleared.', 'fictioneer' ) ) );
|
||||
} else {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Checkmarks could not be updated.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Database error. Checkmarks could not be cleared.', 'fictioneer' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -241,7 +241,7 @@ function fictioneer_ajax_get_finished_checkmarks_list() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Setup
|
||||
|
@ -133,18 +133,18 @@ function fictioneer_ajax_toggle_follow() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
if ( empty( $_POST['story_id'] ) || empty( $_POST['set'] ) ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Missing arguments.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Missing arguments.' ) );
|
||||
}
|
||||
|
||||
// Valid story ID?
|
||||
$story_id = fictioneer_validate_id( $_POST['story_id'], 'fcn_story' );
|
||||
|
||||
if ( ! $story_id ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Invalid story ID.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Invalid story ID.' ) );
|
||||
}
|
||||
|
||||
// Set or unset?
|
||||
@ -174,7 +174,7 @@ function fictioneer_ajax_toggle_follow() {
|
||||
do_action( 'fictioneer_toggled_follow', $story_id, $set );
|
||||
wp_send_json_success();
|
||||
} else {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Follows could not be updated.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Follows could not be updated.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -203,7 +203,7 @@ function fictioneer_ajax_clear_my_follows() {
|
||||
$user = fictioneer_get_validated_ajax_user( 'nonce', 'fictioneer_clear_follows' );
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Update user
|
||||
@ -211,7 +211,7 @@ function fictioneer_ajax_clear_my_follows() {
|
||||
update_user_meta( $user->ID, 'fictioneer_user_follows_cache', false );
|
||||
wp_send_json_success( array( 'success' => __( 'Data has been cleared.', 'fictioneer' ) ) );
|
||||
} else {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Follows could not be cleared.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Database error. Follows could not be cleared.', 'fictioneer' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -244,13 +244,13 @@ function fictioneer_ajax_mark_follows_read() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
$user_follows = fictioneer_load_follows( $user );
|
||||
|
||||
if ( empty( $user_follows ) ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Follows are empty.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Follows are empty.', 'fictioneer' ) ) );
|
||||
}
|
||||
|
||||
// Update 'seen' timestamp to now; compatible with Date.now() in JavaScript
|
||||
@ -264,7 +264,7 @@ function fictioneer_ajax_mark_follows_read() {
|
||||
if ( $result ) {
|
||||
wp_send_json_success();
|
||||
} else {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Follows could not be updated.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Follows could not be updated.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -396,7 +396,7 @@ function fictioneer_ajax_get_follows_list() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Setup
|
||||
@ -420,7 +420,7 @@ function fictioneer_ajax_get_follows_list() {
|
||||
);
|
||||
|
||||
if ( ! $list_items ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Card list could not be queried.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Card list could not be queried.' ) );
|
||||
}
|
||||
|
||||
// Total number of pages
|
||||
|
@ -70,18 +70,18 @@ function fictioneer_ajax_toggle_reminder() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
if ( empty( $_POST['story_id'] ) || empty( $_POST['set'] ) ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Missing arguments.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Missing arguments.' ) );
|
||||
}
|
||||
|
||||
// Valid story ID?
|
||||
$story_id = fictioneer_validate_id( $_POST['story_id'], 'fcn_story' );
|
||||
|
||||
if ( ! $story_id ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Invalid story ID.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Invalid story ID.' ) );
|
||||
}
|
||||
|
||||
// Set or unset?
|
||||
@ -109,7 +109,7 @@ function fictioneer_ajax_toggle_reminder() {
|
||||
do_action( 'fictioneer_toggled_reminder', $story_id, $set );
|
||||
wp_send_json_success();
|
||||
} {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Reminders could not be updated.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Reminders could not be updated.' ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -138,14 +138,14 @@ function fictioneer_ajax_clear_my_reminders() {
|
||||
$user = fictioneer_get_validated_ajax_user( 'nonce', 'fictioneer_clear_reminders' );
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Update user
|
||||
if ( delete_user_meta( $user->ID, 'fictioneer_user_reminders' ) ) {
|
||||
wp_send_json_success( array( 'success' => __( 'Data has been cleared.', 'fictioneer' ) ) );
|
||||
} else {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Reminders could not be cleared.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Database error. Reminders could not be cleared.', 'fictioneer' ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,7 +168,7 @@ function fictioneer_ajax_get_reminders_list() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Setup
|
||||
|
@ -18,7 +18,7 @@ function fictioneer_ajax_get_user_data() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Setup
|
||||
@ -161,14 +161,14 @@ function fictioneer_ajax_clear_my_comment_subscriptions() {
|
||||
$user = fictioneer_get_validated_ajax_user( 'nonce', 'fictioneer_clear_comment_subscriptions' );
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Change validator
|
||||
if ( update_user_meta( $user->ID, 'fictioneer_comment_reply_validator', time() ) ) {
|
||||
wp_send_json_success( array( 'success' => __( 'Data has been cleared.', 'fictioneer' ) ) );
|
||||
} else {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Comment subscriptions could not be cleared.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Database error. Comment subscriptions could not be cleared.', 'fictioneer' ) ) );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_ajax_fictioneer_ajax_clear_my_comment_subscriptions', 'fictioneer_ajax_clear_my_comment_subscriptions' );
|
||||
@ -194,7 +194,7 @@ function fictioneer_ajax_clear_my_comments() {
|
||||
$user = fictioneer_get_validated_ajax_user( 'nonce', 'fictioneer_clear_comments' );
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
if (
|
||||
@ -202,20 +202,20 @@ function fictioneer_ajax_clear_my_comments() {
|
||||
fictioneer_is_author( $user->ID ) ||
|
||||
fictioneer_is_moderator( $user->ID )
|
||||
) {
|
||||
wp_send_json_error( array( 'error' => __( 'User role too high. Please ask an administrator.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'User role too high. Please ask an administrator.', 'fictioneer' ) ) );
|
||||
}
|
||||
|
||||
// Soft-delete comments
|
||||
$result = fictioneer_soft_delete_user_comments( $user->ID );
|
||||
|
||||
if ( ! $result ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. No comments found.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Database error. No comments found.' ) );
|
||||
}
|
||||
|
||||
if ( $result['failure'] && ! $result['complete'] ) {
|
||||
wp_send_json_error(
|
||||
array(
|
||||
'error' => sprintf(
|
||||
'failure' => sprintf(
|
||||
__( 'Partial database error. Only %1$s of %2$s comments could be cleared.', 'fictioneer' ),
|
||||
$result['updated_count'],
|
||||
$result['comment_count']
|
||||
@ -225,7 +225,7 @@ function fictioneer_ajax_clear_my_comments() {
|
||||
}
|
||||
|
||||
if ( $result['failure'] ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Comments could not be cleared.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Database error. Comments could not be cleared.', 'fictioneer' ) ) );
|
||||
}
|
||||
|
||||
// Report success
|
||||
@ -266,7 +266,7 @@ function fictioneer_ajax_unset_my_oauth() {
|
||||
! in_array( $channel, ['discord', 'twitch', 'patreon', 'google'] ) ||
|
||||
$sender_id !== $user->ID
|
||||
) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Delete connection
|
||||
@ -288,7 +288,7 @@ function fictioneer_ajax_unset_my_oauth() {
|
||||
);
|
||||
} else {
|
||||
// Failure response
|
||||
wp_send_json_error( array( 'error' => __( 'Database error. Please ask an administrator.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'failure' => __( 'Database error. Please ask an administrator.', 'fictioneer' ) ) );
|
||||
}
|
||||
}
|
||||
add_action( 'wp_ajax_fictioneer_ajax_unset_my_oauth', 'fictioneer_ajax_unset_my_oauth' );
|
||||
@ -311,7 +311,7 @@ function fictioneer_ajax_get_avatar() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Response
|
||||
|
2
js/bookmarks.min.js
vendored
2
js/bookmarks.min.js
vendored
File diff suppressed because one or more lines are too long
2
js/checkmarks.min.js
vendored
2
js/checkmarks.min.js
vendored
@ -1 +1 @@
|
||||
var fcn_checkmarks,fcn_userCheckmarksTimeout;function fcn_initializeCheckmarks(a){const c=a.detail.data.checkmarks;!1!==c&&(Array.isArray(c.data)&&0===c.data.length&&(c.data={}),fcn_checkmarks=c,fcn_updateCheckmarksView(),localStorage.removeItem("fcnBookshelfContent"),_$$("button.checkmark").forEach((a=>{a.addEventListener("click",(a=>{fcn_clickCheckmark(a.currentTarget)}))})))}function fcn_toggleCheckmark(a,c,t=null,e=null,s="toggle"){const n=fcn_getUserData();if(fcn_checkmarks&&n.checkmarks){if(localStorage.removeItem("fcnBookshelfContent"),"toggle"===s&&JSON.stringify(fcn_checkmarks.data[a])!==JSON.stringify(n.checkmarks.data[a]))return fcn_checkmarks=n.checkmarks,fcn_showNotification(fictioneer_tl.notification.checkmarksResynchronized),void fcn_updateCheckmarksView();if(fcn_checkmarks.data[a]||(fcn_checkmarks.data[a]=[]),n.checkmarks.data[a]||(n.checkmarks.data[a]=[]),t&&"progress"===c&&!fcn_checkmarks.data[a].includes(t)&&fcn_checkmarks.data[a].push(t),t&&"chapter"===c)if(!fcn_checkmarks.data[a].includes(t)&&"unset"!==s||"set"===s)fcn_checkmarks.data[a].push(t),e&&(e.classList.add("marked"),e.setAttribute("aria-checked",!0));else{fcn_removeItemOnce(fcn_checkmarks.data[a],t),e&&(e.classList.remove("marked"),e.setAttribute("aria-checked",!1)),fcn_removeItemOnce(fcn_checkmarks.data[a],a);const c=_$('button[data-type="story"]');c&&(c.classList.remove("marked"),c.setAttribute("aria-checked",!1))}if("story"===c){const c=(fcn_checkmarks.data[a].includes(a)||"unset"===s)&&"set"!==s;fcn_checkmarks.data[a]=[],c||(_$$("button.checkmark").forEach((c=>{fcn_checkmarks.data[a].push(parseInt(c.dataset.id))})),fcn_checkmarks.data[a].includes(a)||fcn_checkmarks.data[a].push(a))}fcn_checkmarks.data[a]=fcn_checkmarks.data[a].filter(((a,c,t)=>t.indexOf(a)==c)),n.checkmarks.data[a]=fcn_checkmarks.data[a],n.lastLoaded=0,fcn_setUserData(n),fcn_updateCheckmarksView(),clearTimeout(fcn_userCheckmarksTimeout),fcn_userCheckmarksTimeout=setTimeout((()=>{fcn_updateCheckmarks(a,fcn_checkmarks.data[a])}),fictioneer_ajax.post_debounce_rate)}}function fcn_clickCheckmark(a){fcn_toggleCheckmark(parseInt(a.dataset.storyId),a.dataset.type,parseInt(a.dataset.id),a)}function fcn_updateCheckmarks(a,c=null){c=c||fcn_getUserData().checkmarks.data[a],fcn_ajaxPost({action:"fictioneer_ajax_set_checkmark",fcn_fast_ajax:1,story_id:a,update:c.join(" ")}).then((a=>{a.data.error&&fcn_showNotification(a.data.error,3,"warning")})).catch((a=>{a.status&&a.statusText&&fcn_showNotification(`${a.status}: ${a.statusText}`,5,"warning")}))}function fcn_updateCheckmarksView(){const a=fcn_getUserData(),c=a.checkmarks;if(!c)return;const t=parseInt(fcn_inlineStorage.storyId);if(t){const e=c.data[t]&&c.data[t].includes(t);if(e){let e=!1;_$$("button.checkmark").forEach((a=>{const s=parseInt(a.dataset.id);c.data[t].includes(s)||(c.data[t].push(s),e=!0)})),e&&(a.checkmarks=c,fcn_setUserData(a),fcn_updateCheckmarks(t,c.data[t]))}_$$$("ribbon-read")?.classList.toggle("hidden",!e)}_$$("button.checkmark").forEach((a=>{const t=parseInt(a.dataset.storyId);if(c.data[t]){const e=c.data[t].includes(parseInt(a.dataset.id));a.classList.toggle("marked",e),a.setAttribute("aria-checked",e)}})),_$$(".card").forEach((a=>{const t=parseInt(a.dataset.storyId),e=c.data[t]&&(c.data[t].includes(parseInt(a.dataset.checkId))||c.data[t].includes(t));a.classList.toggle("has-checkmark",1==e)}))}document.addEventListener("fcnUserDataReady",(a=>{fcn_initializeCheckmarks(a)}));
|
||||
var fcn_checkmarks,fcn_userCheckmarksTimeout;function fcn_initializeCheckmarks(a){const e=a.detail.data.checkmarks;!1!==e&&(Array.isArray(e.data)&&0===e.data.length&&(e.data={}),fcn_checkmarks=e,fcn_updateCheckmarksView(),localStorage.removeItem("fcnBookshelfContent"),_$$("button.checkmark").forEach((a=>{a.addEventListener("click",(a=>{fcn_clickCheckmark(a.currentTarget)}))})))}function fcn_toggleCheckmark(a,e,t=null,c=null,s="toggle"){const r=fcn_getUserData();if(fcn_checkmarks&&r.checkmarks){if(localStorage.removeItem("fcnBookshelfContent"),"toggle"===s&&JSON.stringify(fcn_checkmarks.data[a])!==JSON.stringify(r.checkmarks.data[a]))return fcn_checkmarks=r.checkmarks,fcn_showNotification(fictioneer_tl.notification.checkmarksResynchronized),void fcn_updateCheckmarksView();if(fcn_checkmarks.data[a]||(fcn_checkmarks.data[a]=[]),r.checkmarks.data[a]||(r.checkmarks.data[a]=[]),t&&"progress"===e&&!fcn_checkmarks.data[a].includes(t)&&fcn_checkmarks.data[a].push(t),t&&"chapter"===e)if(!fcn_checkmarks.data[a].includes(t)&&"unset"!==s||"set"===s)fcn_checkmarks.data[a].push(t),c&&(c.classList.add("marked"),c.setAttribute("aria-checked",!0));else{fcn_removeItemOnce(fcn_checkmarks.data[a],t),c&&(c.classList.remove("marked"),c.setAttribute("aria-checked",!1)),fcn_removeItemOnce(fcn_checkmarks.data[a],a);const e=_$('button[data-type="story"]');e&&(e.classList.remove("marked"),e.setAttribute("aria-checked",!1))}if("story"===e){const e=(fcn_checkmarks.data[a].includes(a)||"unset"===s)&&"set"!==s;fcn_checkmarks.data[a]=[],e||(_$$("button.checkmark").forEach((e=>{fcn_checkmarks.data[a].push(parseInt(e.dataset.id))})),fcn_checkmarks.data[a].includes(a)||fcn_checkmarks.data[a].push(a))}fcn_checkmarks.data[a]=fcn_checkmarks.data[a].filter(((a,e,t)=>t.indexOf(a)==e)),r.checkmarks.data[a]=fcn_checkmarks.data[a],r.lastLoaded=0,fcn_setUserData(r),fcn_updateCheckmarksView(),clearTimeout(fcn_userCheckmarksTimeout),fcn_userCheckmarksTimeout=setTimeout((()=>{fcn_updateCheckmarks(a,fcn_checkmarks.data[a])}),fictioneer_ajax.post_debounce_rate)}}function fcn_clickCheckmark(a){fcn_toggleCheckmark(parseInt(a.dataset.storyId),a.dataset.type,parseInt(a.dataset.id),a)}function fcn_updateCheckmarks(a,e=null){e=e||fcn_getUserData().checkmarks.data[a],fcn_ajaxPost({action:"fictioneer_ajax_set_checkmark",fcn_fast_ajax:1,story_id:a,update:e.join(" ")}).then((a=>{a.success||(fcn_showNotification(a.data.failure??a.data.error??fictioneer_tl.notification.error,3,"warning"),(a.data.error||a.data.failure)&&console.error("Error:",a.data.error??a.data.failure))})).catch((a=>{a.status&&a.statusText&&fcn_showNotification(`${a.status}: ${a.statusText}`,5,"warning"),console.error(a)}))}function fcn_updateCheckmarksView(){const a=fcn_getUserData(),e=a.checkmarks;if(!e)return;const t=parseInt(fcn_inlineStorage.storyId);if(t){const c=e.data[t]&&e.data[t].includes(t);if(c){let c=!1;_$$("button.checkmark").forEach((a=>{const s=parseInt(a.dataset.id);e.data[t].includes(s)||(e.data[t].push(s),c=!0)})),c&&(a.checkmarks=e,fcn_setUserData(a),fcn_updateCheckmarks(t,e.data[t]))}_$$$("ribbon-read")?.classList.toggle("hidden",!c)}_$$("button.checkmark").forEach((a=>{const t=parseInt(a.dataset.storyId);if(e.data[t]){const c=e.data[t].includes(parseInt(a.dataset.id));a.classList.toggle("marked",c),a.setAttribute("aria-checked",c)}})),_$$(".card").forEach((a=>{const t=parseInt(a.dataset.storyId),c=e.data[t]&&(e.data[t].includes(parseInt(a.dataset.checkId))||e.data[t].includes(t));a.classList.toggle("has-checkmark",1==c)}))}document.addEventListener("fcnUserDataReady",(a=>{fcn_initializeCheckmarks(a)}));
|
2
js/comments.min.js
vendored
2
js/comments.min.js
vendored
File diff suppressed because one or more lines are too long
4
js/complete.min.js
vendored
4
js/complete.min.js
vendored
File diff suppressed because one or more lines are too long
2
js/follows.min.js
vendored
2
js/follows.min.js
vendored
@ -1 +1 @@
|
||||
const fcn_followsMenuItem=_$$$("follow-menu-button");var fcn_userFollowsTimeout,fcn_follows;function fcn_initializeFollows(o){const t=o.detail.data.follows;!1!==t&&(Array.isArray(t.data)&&0===t.data.length&&(t.data={}),fcn_follows=t,fcn_updateFollowsView(),localStorage.removeItem("fcnBookshelfContent"))}function fcn_toggleFollow(o){const t=fcn_getUserData();if(fcn_follows&&t.follows){if(localStorage.removeItem("fcnBookshelfContent"),JSON.stringify(fcn_follows.data[o])!==JSON.stringify(t.follows.data[o]))return fcn_follows=t.follows,fcn_showNotification(fictioneer_tl.notification.followsResynchronized),void fcn_updateFollowsView();fcn_follows.data[o]?delete fcn_follows.data[o]:fcn_follows.data[o]={story_id:parseInt(o),timestamp:Date.now()},t.follows.data[o]=fcn_follows.data[o],t.lastLoaded=0,fcn_setUserData(t),fcn_updateFollowsView(),clearTimeout(fcn_userFollowsTimeout),fcn_userFollowsTimeout=setTimeout((()=>{fcn_ajaxPost({action:"fictioneer_ajax_toggle_follow",fcn_fast_ajax:1,story_id:o,set:!!fcn_follows.data[o]}).then((o=>{o.data.error&&fcn_showNotification(o.data.error,5,"warning")})).catch((o=>{429===o.status?fcn_showNotification(fictioneer_tl.notification.slowDown,3,"warning"):o.status&&o.statusText&&fcn_showNotification(`${o.status}: ${o.statusText}`,5,"warning")}))}),fictioneer_ajax.post_debounce_rate)}}function fcn_updateFollowsView(){const o=fcn_getUserData();if(!fcn_follows||!o.follows)return;_$$(".button-follow-story").forEach((o=>{o.classList.toggle("_followed",!!fcn_follows?.data[o.dataset.storyId])})),_$$(".card").forEach((o=>{o.classList.toggle("has-follow",!!fcn_follows?.data[o.dataset.storyId])}));const t=parseInt(fcn_follows.new)>0;_$$(".mark-follows-read, .follows-alert-number, .mobile-menu-button").forEach((o=>{o.classList.toggle("_new",t),t>0&&(o.dataset.newCount=fcn_follows.new)}))}function fcn_setupFollowsHTML(){fcn_followsMenuItem.classList.contains("_loaded")||fcn_ajaxGet({action:"fictioneer_ajax_get_follows_notifications",fcn_fast_ajax:1}).then((o=>{if(o.data.html){const t=_$$$("follow-menu-scroll");t&&(t.innerHTML=o.data.html);const n=_$$$("mobile-menu-follows-list");n&&(n.innerHTML=o.data.html),!1===fcn_getUserData().loggedIn&&(fcn_prepareLogin(),fcn_fetchUserData())}})).catch((o=>{429===o.status?fcn_showNotification(fictioneer_tl.notification.slowDown,3,"warning"):o.status&&o.statusText&&fcn_showNotification(`${o.status}: ${o.statusText}`,5,"warning"),_$$$("follow-menu-scroll")?.remove(),_$$$("mobile-menu-follows-list")?.remove()})).then((()=>{fcn_followsMenuItem.classList.add("_loaded")}))}function fcn_markFollowsRead(){if(!fcn_followsMenuItem.classList.contains("_new")||!fcn_followsMenuItem.classList.contains("_loaded"))return;_$$(".mark-follows-read, .follows-alert-number, .follow-item, .mobile-menu-button").forEach((o=>{o.classList.remove("_new")}));const o=fcn_getUserData();o.new=0,o.lastLoaded=0,fcn_setUserData(o),fcn_ajaxPost({action:"fictioneer_ajax_mark_follows_read",fcn_fast_ajax:1}).catch((o=>{o.status&&o.statusText&&fcn_showNotification(`${o.status}: ${o.statusText}`,5,"warning")}))}document.addEventListener("fcnUserDataReady",(o=>{fcn_initializeFollows(o)})),fcn_followsMenuItem?.addEventListener("mouseover",(()=>{fcn_setupFollowsHTML()}),{once:!0}),fcn_followsMenuItem?.addEventListener("focus",(()=>{fcn_setupFollowsHTML()}),{once:!0}),_$('.mobile-menu__frame-button[data-frame-target="follows"]')?.addEventListener("click",(()=>{fcn_setupFollowsHTML()}),{once:!0}),_$$(".button-follow-story").forEach((o=>{o.addEventListener("click",(o=>{fcn_toggleFollow(o.currentTarget.dataset.storyId)}))})),_$$(".mark-follows-read").forEach((o=>{o.addEventListener("click",(()=>{fcn_markFollowsRead()}))}));
|
||||
const fcn_followsMenuItem=_$$$("follow-menu-button");var fcn_userFollowsTimeout,fcn_follows;function fcn_initializeFollows(o){const t=o.detail.data.follows;!1!==t&&(Array.isArray(t.data)&&0===t.data.length&&(t.data={}),fcn_follows=t,fcn_updateFollowsView(),localStorage.removeItem("fcnBookshelfContent"))}function fcn_toggleFollow(o){const t=fcn_getUserData();if(fcn_follows&&t.follows){if(localStorage.removeItem("fcnBookshelfContent"),JSON.stringify(fcn_follows.data[o])!==JSON.stringify(t.follows.data[o]))return fcn_follows=t.follows,fcn_showNotification(fictioneer_tl.notification.followsResynchronized),void fcn_updateFollowsView();fcn_follows.data[o]?delete fcn_follows.data[o]:fcn_follows.data[o]={story_id:parseInt(o),timestamp:Date.now()},t.follows.data[o]=fcn_follows.data[o],t.lastLoaded=0,fcn_setUserData(t),fcn_updateFollowsView(),clearTimeout(fcn_userFollowsTimeout),fcn_userFollowsTimeout=setTimeout((()=>{fcn_ajaxPost({action:"fictioneer_ajax_toggle_follow",fcn_fast_ajax:1,story_id:o,set:!!fcn_follows.data[o]}).then((o=>{o.success||(fcn_showNotification(o.data.failure??o.data.error??fictioneer_tl.notification.error,5,"warning"),(o.data.error||o.data.failure)&&console.error("Error:",o.data.error??o.data.failure))})).catch((o=>{429===o.status?fcn_showNotification(fictioneer_tl.notification.slowDown,3,"warning"):o.status&&o.statusText&&fcn_showNotification(`${o.status}: ${o.statusText}`,5,"warning"),console.error(o)}))}),fictioneer_ajax.post_debounce_rate)}}function fcn_updateFollowsView(){const o=fcn_getUserData();if(!fcn_follows||!o.follows)return;_$$(".button-follow-story").forEach((o=>{o.classList.toggle("_followed",!!fcn_follows?.data[o.dataset.storyId])})),_$$(".card").forEach((o=>{o.classList.toggle("has-follow",!!fcn_follows?.data[o.dataset.storyId])}));const t=parseInt(fcn_follows.new)>0;_$$(".mark-follows-read, .follows-alert-number, .mobile-menu-button").forEach((o=>{o.classList.toggle("_new",t),t>0&&(o.dataset.newCount=fcn_follows.new)}))}function fcn_setupFollowsHTML(){fcn_followsMenuItem.classList.contains("_loaded")||fcn_ajaxGet({action:"fictioneer_ajax_get_follows_notifications",fcn_fast_ajax:1}).then((o=>{if(o.data.html){const t=_$$$("follow-menu-scroll");t&&(t.innerHTML=o.data.html);const e=_$$$("mobile-menu-follows-list");e&&(e.innerHTML=o.data.html),!1===fcn_getUserData().loggedIn&&(fcn_prepareLogin(),fcn_fetchUserData())}})).catch((o=>{429===o.status?fcn_showNotification(fictioneer_tl.notification.slowDown,3,"warning"):o.status&&o.statusText&&fcn_showNotification(`${o.status}: ${o.statusText}`,5,"warning"),_$$$("follow-menu-scroll")?.remove(),_$$$("mobile-menu-follows-list")?.remove()})).then((()=>{fcn_followsMenuItem.classList.add("_loaded")}))}function fcn_markFollowsRead(){if(!fcn_followsMenuItem.classList.contains("_new")||!fcn_followsMenuItem.classList.contains("_loaded"))return;_$$(".mark-follows-read, .follows-alert-number, .follow-item, .mobile-menu-button").forEach((o=>{o.classList.remove("_new")}));const o=fcn_getUserData();o.new=0,o.lastLoaded=0,fcn_setUserData(o),fcn_ajaxPost({action:"fictioneer_ajax_mark_follows_read",fcn_fast_ajax:1}).catch((o=>{o.status&&o.statusText&&fcn_showNotification(`${o.status}: ${o.statusText}`,5,"warning")}))}document.addEventListener("fcnUserDataReady",(o=>{fcn_initializeFollows(o)})),fcn_followsMenuItem?.addEventListener("mouseover",(()=>{fcn_setupFollowsHTML()}),{once:!0}),fcn_followsMenuItem?.addEventListener("focus",(()=>{fcn_setupFollowsHTML()}),{once:!0}),_$('.mobile-menu__frame-button[data-frame-target="follows"]')?.addEventListener("click",(()=>{fcn_setupFollowsHTML()}),{once:!0}),_$$(".button-follow-story").forEach((o=>{o.addEventListener("click",(o=>{fcn_toggleFollow(o.currentTarget.dataset.storyId)}))})),_$$(".mark-follows-read").forEach((o=>{o.addEventListener("click",(()=>{fcn_markFollowsRead()}))}));
|
2
js/reminders.min.js
vendored
2
js/reminders.min.js
vendored
@ -1 +1 @@
|
||||
var fcn_userRemindersTimeout,fcn_reminders;function fcn_initializeReminders(e){const t=e.detail.data.reminders;!1!==t&&(Array.isArray(t.data)&&0===t.data.length&&(t.data={}),fcn_reminders=t,fcn_updateRemindersView(),localStorage.removeItem("fcnBookshelfContent"))}function fcn_toggleReminder(e){const t=fcn_getUserData();if(fcn_reminders&&t.reminders){if(localStorage.removeItem("fcnBookshelfContent"),JSON.stringify(fcn_reminders.data[e])!==JSON.stringify(t.reminders.data[e]))return fcn_reminders=t.reminders,fcn_showNotification(fictioneer_tl.notification.remindersResynchronized),void fcn_updateRemindersView();fcn_reminders.data[e]?delete fcn_reminders.data[e]:fcn_reminders.data[e]={story_id:parseInt(e),timestamp:Date.now()},t.reminders.data[e]=fcn_reminders.data[e],t.lastLoaded=0,fcn_setUserData(t),fcn_updateRemindersView(),clearTimeout(fcn_userRemindersTimeout),fcn_userRemindersTimeout=setTimeout((()=>{fcn_ajaxPost({action:"fictioneer_ajax_toggle_reminder",fcn_fast_ajax:1,story_id:e,set:!!fcn_reminders.data[e]}).then((e=>{e.data.error&&fcn_showNotification(e.data.error,5,"warning")})).catch((e=>{429===e.status?fcn_showNotification(fictioneer_tl.notification.slowDown,3,"warning"):e.status&&e.statusText&&fcn_showNotification(`${e.status}: ${e.statusText}`,5,"warning")}))}),fictioneer_ajax.post_debounce_rate)}}function fcn_updateRemindersView(){const e=fcn_getUserData();fcn_reminders&&e.reminders&&(_$$(".button-read-later").forEach((e=>{e.classList.toggle("_remembered",!!fcn_reminders.data[e.dataset.storyId])})),_$$(".card").forEach((e=>{e.classList.toggle("has-reminder",!!fcn_reminders.data[e.dataset.storyId])})))}document.addEventListener("fcnUserDataReady",(e=>{fcn_initializeReminders(e)})),_$$(".button-read-later").forEach((e=>{e.addEventListener("click",(e=>{fcn_toggleReminder(e.currentTarget.dataset.storyId)}))}));
|
||||
var fcn_userRemindersTimeout,fcn_reminders;function fcn_initializeReminders(e){const t=e.detail.data.reminders;!1!==t&&(Array.isArray(t.data)&&0===t.data.length&&(t.data={}),fcn_reminders=t,fcn_updateRemindersView(),localStorage.removeItem("fcnBookshelfContent"))}function fcn_toggleReminder(e){const t=fcn_getUserData();if(fcn_reminders&&t.reminders){if(localStorage.removeItem("fcnBookshelfContent"),JSON.stringify(fcn_reminders.data[e])!==JSON.stringify(t.reminders.data[e]))return fcn_reminders=t.reminders,fcn_showNotification(fictioneer_tl.notification.remindersResynchronized),void fcn_updateRemindersView();fcn_reminders.data[e]?delete fcn_reminders.data[e]:fcn_reminders.data[e]={story_id:parseInt(e),timestamp:Date.now()},t.reminders.data[e]=fcn_reminders.data[e],t.lastLoaded=0,fcn_setUserData(t),fcn_updateRemindersView(),clearTimeout(fcn_userRemindersTimeout),fcn_userRemindersTimeout=setTimeout((()=>{fcn_ajaxPost({action:"fictioneer_ajax_toggle_reminder",fcn_fast_ajax:1,story_id:e,set:!!fcn_reminders.data[e]}).then((e=>{e.success||(fcn_showNotification(e.data.failure??e.data.error??fictioneer_tl.notification.error,5,"warning"),(e.data.error||e.data.failure)&&console.error("Error:",e.data.error??e.data.failure))})).catch((e=>{429===e.status?fcn_showNotification(fictioneer_tl.notification.slowDown,3,"warning"):e.status&&e.statusText&&fcn_showNotification(`${e.status}: ${e.statusText}`,5,"warning"),console.error(e)}))}),fictioneer_ajax.post_debounce_rate)}}function fcn_updateRemindersView(){const e=fcn_getUserData();fcn_reminders&&e.reminders&&(_$$(".button-read-later").forEach((e=>{e.classList.toggle("_remembered",!!fcn_reminders.data[e.dataset.storyId])})),_$$(".card").forEach((e=>{e.classList.toggle("has-reminder",!!fcn_reminders.data[e.dataset.storyId])})))}document.addEventListener("fcnUserDataReady",(e=>{fcn_initializeReminders(e)})),_$$(".button-read-later").forEach((e=>{e.addEventListener("click",(e=>{fcn_toggleReminder(e.currentTarget.dataset.storyId)}))}));
|
2
js/user-profile.min.js
vendored
2
js/user-profile.min.js
vendored
@ -1 +1 @@
|
||||
function fcn_unsetOauth(t){const e=prompt(t.dataset.warning);if(!e||e.toLowerCase()!=t.dataset.confirm.toLowerCase())return;const a=_$$$(`oauth-${t.dataset.channel}`);a.classList.add("ajax-in-progress"),fcn_ajaxPost(payload={action:"fictioneer_ajax_unset_my_oauth",nonce:t.dataset.nonce,channel:t.dataset.channel,id:t.dataset.id}).then((t=>{t.success?(a.classList.remove("_connected"),a.classList.add("_disconnected"),a.querySelector("button").remove(),fcn_showNotification(a.dataset.unset)):(a.style.background="var(--notice-warning-background)",fcn_showNotification(t.data.error,5,"warning"))})).catch((t=>{t.status&&t.statusText&&(a.style.background="var(--notice-warning-background)",fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"))})).then((()=>{a.classList.remove("ajax-in-progress")}))}function fcn_deleteMyAccount(t){if(_$$$("button-delete-my-account").hasAttribute("disabled"))return;const e=prompt(t.dataset.warning);e&&e.toLowerCase()==t.dataset.confirm.toLowerCase()&&(_$$$("button-delete-my-account").setAttribute("disabled",!0),fcn_ajaxPost({action:"fictioneer_ajax_delete_my_account",nonce:t.dataset.nonce,id:t.dataset.id}).then((t=>{t.success?(localStorage.removeItem("fcnAuth"),localStorage.removeItem("fcnProfileAvatar"),location.reload()):(fcn_showNotification(t.data.error,5,"warning"),_$$$("button-delete-my-account").innerHTML=t.data.button)})).catch((t=>{t.status&&t.statusText&&(fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"),_$$$("button-delete-my-account").innerHTML=response.data.button)})))}_$$(".button-unset-oauth").forEach((t=>{t.addEventListener("click",(t=>{fcn_unsetOauth(t.currentTarget)}))})),_$$$("button-delete-my-account")?.addEventListener("click",(t=>{fcn_deleteMyAccount(t.currentTarget)}));const fcn_profileDataTranslations=_$$$("profile-data-translations")?.dataset;function fcn_dataDeletionPrompt(t){const e=prompt(t.dataset.warning);return!(!e||e.toLowerCase()!=t.dataset.confirm.toLowerCase())}function fcn_clearData(t,e){const a=t.closest(".card");localStorage.removeItem("fcnBookshelfContent"),a.classList.add("ajax-in-progress"),t.remove(),fcn_ajaxPost({action:e,fcn_fast_ajax:1,nonce:t.dataset.nonce}).then((t=>{t.success?a.querySelector(".card__content").innerHTML=t.data.success:fcn_showNotification(t.data.error,10,"warning")})).catch((t=>{t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,10,"warning")})).then((()=>{a.classList.remove("ajax-in-progress")}))}_$(".button-clear-comments")?.addEventListener("click",(t=>{fcn_dataDeletionPrompt(t.currentTarget)&&fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_comments")})),_$(".button-clear-comment-subscriptions")?.addEventListener("click",(t=>{fcn_dataDeletionPrompt(t.currentTarget)&&fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_comment_subscriptions")})),_$(".button-clear-checkmarks")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.checkmarks={data:{},updated:Date.now()},fcn_setUserData(e),fcn_updateCheckmarksView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_checkmarks",!0)})),_$(".button-clear-reminders")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.reminders={data:{}},fcn_setUserData(e),fcn_updateRemindersView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_reminders",!0)})),_$(".button-clear-follows")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.follows={data:{}},fcn_setUserData(e),fcn_updateFollowsView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_follows",!0)})),_$(".button-clear-bookmarks")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.bookmarks="{}",fcn_setUserData(e),fcn_bookmarks.data={},t.currentTarget.closest(".card").querySelector(".card__content").innerHTML=fcn_profileDataTranslations.clearedSuccess,fcn_setBookmarks(fcn_bookmarks)}));
|
||||
function fcn_unsetOauth(t){const e=prompt(t.dataset.warning);if(!e||e.toLowerCase()!=t.dataset.confirm.toLowerCase())return;const a=_$$$(`oauth-${t.dataset.channel}`);a.classList.add("ajax-in-progress"),fcn_ajaxPost(payload={action:"fictioneer_ajax_unset_my_oauth",nonce:t.dataset.nonce,channel:t.dataset.channel,id:t.dataset.id}).then((t=>{t.success?(a.classList.remove("_connected"),a.classList.add("_disconnected"),a.querySelector("button").remove(),fcn_showNotification(a.dataset.unset)):(a.style.background="var(--notice-warning-background)",fcn_showNotification(t.data.error,5,"warning"))})).catch((t=>{t.status&&t.statusText&&(a.style.background="var(--notice-warning-background)",fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"))})).then((()=>{a.classList.remove("ajax-in-progress")}))}function fcn_deleteMyAccount(t){if(_$$$("button-delete-my-account").hasAttribute("disabled"))return;const e=prompt(t.dataset.warning);e&&e.toLowerCase()==t.dataset.confirm.toLowerCase()&&(_$$$("button-delete-my-account").setAttribute("disabled",!0),fcn_ajaxPost({action:"fictioneer_ajax_delete_my_account",nonce:t.dataset.nonce,id:t.dataset.id}).then((t=>{t.success?(localStorage.removeItem("fcnAuth"),localStorage.removeItem("fcnProfileAvatar"),location.reload()):(fcn_showNotification(t.data.error,5,"warning"),_$$$("button-delete-my-account").innerHTML=t.data.button)})).catch((t=>{t.status&&t.statusText&&(fcn_showNotification(`${t.status}: ${t.statusText}`,5,"warning"),_$$$("button-delete-my-account").innerHTML=response.data.button)})))}_$$(".button-unset-oauth").forEach((t=>{t.addEventListener("click",(t=>{fcn_unsetOauth(t.currentTarget)}))})),_$$$("button-delete-my-account")?.addEventListener("click",(t=>{fcn_deleteMyAccount(t.currentTarget)}));const fcn_profileDataTranslations=_$$$("profile-data-translations")?.dataset;function fcn_dataDeletionPrompt(t){const e=prompt(t.dataset.warning);return!(!e||e.toLowerCase()!=t.dataset.confirm.toLowerCase())}function fcn_clearData(t,e){const a=t.closest(".card");localStorage.removeItem("fcnBookshelfContent"),a.classList.add("ajax-in-progress"),t.remove(),fcn_ajaxPost({action:e,fcn_fast_ajax:1,nonce:t.dataset.nonce}).then((t=>{t.success?a.querySelector(".card__content").innerHTML=t.data.success:(fcn_showNotification(t.data.failure??t.data.error??fictioneer_tl.notification.error,10,"warning"),(t.data.error||t.data.failure)&&console.error("Error:",t.data.error??t.data.failure))})).catch((t=>{t.status&&t.statusText&&fcn_showNotification(`${t.status}: ${t.statusText}`,10,"warning"),console.error(t)})).then((()=>{a.classList.remove("ajax-in-progress")}))}_$(".button-clear-comments")?.addEventListener("click",(t=>{fcn_dataDeletionPrompt(t.currentTarget)&&fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_comments")})),_$(".button-clear-comment-subscriptions")?.addEventListener("click",(t=>{fcn_dataDeletionPrompt(t.currentTarget)&&fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_comment_subscriptions")})),_$(".button-clear-checkmarks")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.checkmarks={data:{},updated:Date.now()},fcn_setUserData(e),fcn_updateCheckmarksView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_checkmarks",!0)})),_$(".button-clear-reminders")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.reminders={data:{}},fcn_setUserData(e),fcn_updateRemindersView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_reminders",!0)})),_$(".button-clear-follows")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.follows={data:{}},fcn_setUserData(e),fcn_updateFollowsView(),fcn_clearData(t.currentTarget,"fictioneer_ajax_clear_my_follows",!0)})),_$(".button-clear-bookmarks")?.addEventListener("click",(t=>{if(!fcn_dataDeletionPrompt(t.currentTarget))return;const e=fcn_getUserData();e.bookmarks="{}",fcn_setUserData(e),fcn_bookmarks.data={},t.currentTarget.closest(".card").querySelector(".card__content").innerHTML=fcn_profileDataTranslations.clearedSuccess,fcn_setBookmarks(fcn_bookmarks)}));
|
@ -464,7 +464,7 @@ function fictioneer_ajax_get_checkmarks() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Prepare Checkmarks
|
||||
@ -498,7 +498,7 @@ function fictioneer_ajax_get_reminders() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Prepare Reminders
|
||||
@ -531,7 +531,7 @@ function fictioneer_ajax_get_follows() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Prepare Follows
|
||||
@ -580,7 +580,7 @@ function fictioneer_ajax_get_fingerprint() {
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Response
|
||||
@ -604,17 +604,14 @@ add_action( 'wp_ajax_fictioneer_ajax_get_fingerprint', 'fictioneer_ajax_get_fing
|
||||
function fictioneer_ajax_get_bookmarks() {
|
||||
// Enabled?
|
||||
if ( ! get_option( 'fictioneer_enable_bookmarks' ) ) {
|
||||
wp_send_json_error(
|
||||
array( 'error' => __( 'Not allowed.', 'fictioneer' ) ),
|
||||
403
|
||||
);
|
||||
wp_send_json_error( null, 403 );
|
||||
}
|
||||
|
||||
// Setup and validations
|
||||
$user = fictioneer_get_validated_ajax_user();
|
||||
|
||||
if ( ! $user ) {
|
||||
wp_send_json_error( array( 'error' => __( 'Request did not pass validation.', 'fictioneer' ) ) );
|
||||
wp_send_json_error( array( 'error' => 'Request did not pass validation.' ) );
|
||||
}
|
||||
|
||||
// Look for saved bookmarks on user...
|
||||
|
@ -283,15 +283,25 @@ function fcn_saveUserBookmarks(bookmarks) {
|
||||
'bookmarks': JSON.stringify(bookmarks)
|
||||
})
|
||||
.then(response => {
|
||||
// Check for failure
|
||||
if (response.data.error) {
|
||||
fcn_showNotification(response.data.error, 3, 'warning');
|
||||
if (!response.success) {
|
||||
fcn_showNotification(
|
||||
response.data.failure ?? response.data.error ?? fictioneer_tl.notification.error,
|
||||
3,
|
||||
'warning'
|
||||
);
|
||||
|
||||
// Make sure the actual error (if any) is printed to the console too
|
||||
if (response.data.error || response.data.failure) {
|
||||
console.error('Error:', response.data.error ?? response.data.failure);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.status && error.statusText) {
|
||||
fcn_showNotification(`${error.status}: ${error.statusText}`, 3, 'warning');
|
||||
}
|
||||
|
||||
console.error(error);
|
||||
});
|
||||
}, fictioneer_ajax.post_debounce_rate); // Debounce synchronization
|
||||
}
|
||||
|
@ -228,14 +228,26 @@ function fcn_updateCheckmarks(storyId, checkmarks = null) {
|
||||
'update': checkmarks.join(' ')
|
||||
})
|
||||
.then(response => {
|
||||
if (response.data.error) {
|
||||
fcn_showNotification(response.data.error, 3, 'warning');
|
||||
// Check for failure
|
||||
if (!response.success) {
|
||||
fcn_showNotification(
|
||||
response.data.failure ?? response.data.error ?? fictioneer_tl.notification.error,
|
||||
3,
|
||||
'warning'
|
||||
);
|
||||
|
||||
// Make sure the actual error (if any) is printed to the console too
|
||||
if (response.data.error || response.data.failure) {
|
||||
console.error('Error:', response.data.error ?? response.data.failure);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.status && error.statusText) {
|
||||
fcn_showNotification(`${error.status}: ${error.statusText}`, 5, 'warning');
|
||||
}
|
||||
|
||||
console.error(error);
|
||||
});
|
||||
}
|
||||
|
||||
|
@ -209,17 +209,24 @@ function fcn_flagComment(source) {
|
||||
fcn_showNotification(response.data.resync);
|
||||
}
|
||||
} else {
|
||||
// Show error notice
|
||||
if (response.data?.error) {
|
||||
fcn_showNotification(response.data.error, 5, 'warning');
|
||||
fcn_showNotification(
|
||||
response.data.failure ?? response.data.error ?? fictioneer_tl.notification.error,
|
||||
5,
|
||||
'warning'
|
||||
);
|
||||
|
||||
// Make sure the actual error (if any) is printed to the console too
|
||||
if (response.data.error || response.data.failure) {
|
||||
console.error('Error:', response.data.error ?? response.data.failure);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
// Show server error
|
||||
if (error.status && error.statusText) {
|
||||
fcn_showNotification(`${error.status}: ${error.statusText}`, 5, 'warning');
|
||||
}
|
||||
|
||||
console.error(error);
|
||||
})
|
||||
.then(() => {
|
||||
// Regardless of success
|
||||
@ -872,7 +879,7 @@ function fcn_deleteMyComment(button) {
|
||||
);
|
||||
|
||||
// Make sure the actual error (if any) is printed to the console too
|
||||
if (response.data.failure || response.data.error) {
|
||||
if (response.data.error || response.data.failure) {
|
||||
console.error('Error:', response.data.error ?? response.data.failure);
|
||||
}
|
||||
}
|
||||
|
@ -108,8 +108,18 @@ function fcn_toggleFollow(storyId) {
|
||||
'set': fcn_follows.data[storyId] ? true : false // Must be boolean, not undefined!
|
||||
})
|
||||
.then(response => {
|
||||
if (response.data.error) {
|
||||
fcn_showNotification(response.data.error, 5, 'warning');
|
||||
// Check for failure
|
||||
if (!response.success) {
|
||||
fcn_showNotification(
|
||||
response.data.failure ?? response.data.error ?? fictioneer_tl.notification.error,
|
||||
5,
|
||||
'warning'
|
||||
);
|
||||
|
||||
// Make sure the actual error (if any) is printed to the console too
|
||||
if (response.data.error || response.data.failure) {
|
||||
console.error('Error:', response.data.error ?? response.data.failure);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
@ -118,6 +128,8 @@ function fcn_toggleFollow(storyId) {
|
||||
} else if (error.status && error.statusText) {
|
||||
fcn_showNotification(`${error.status}: ${error.statusText}`, 5, 'warning');
|
||||
}
|
||||
|
||||
console.error(error);
|
||||
});
|
||||
}, fictioneer_ajax.post_debounce_rate); // Debounce synchronization
|
||||
}
|
||||
|
@ -106,8 +106,18 @@ function fcn_toggleReminder(storyId) {
|
||||
'set': fcn_reminders.data[storyId] ? true : false // Must be boolean, not undefined!
|
||||
})
|
||||
.then(response => {
|
||||
if (response.data.error) {
|
||||
fcn_showNotification(response.data.error, 5, 'warning');
|
||||
// Check for failure
|
||||
if (!response.success) {
|
||||
fcn_showNotification(
|
||||
response.data.failure ?? response.data.error ?? fictioneer_tl.notification.error,
|
||||
5,
|
||||
'warning'
|
||||
);
|
||||
|
||||
// Make sure the actual error (if any) is printed to the console too
|
||||
if (response.data.error || response.data.failure) {
|
||||
console.error('Error:', response.data.error ?? response.data.failure);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
@ -116,6 +126,8 @@ function fcn_toggleReminder(storyId) {
|
||||
} else if (error.status && error.statusText) {
|
||||
fcn_showNotification(`${error.status}: ${error.statusText}`, 5, 'warning');
|
||||
}
|
||||
|
||||
console.error(error);
|
||||
});
|
||||
}, fictioneer_ajax.post_debounce_rate); // Debounce synchronization
|
||||
}
|
||||
|
@ -187,13 +187,24 @@ function fcn_clearData(button, action) {
|
||||
if (response.success) {
|
||||
card.querySelector('.card__content').innerHTML = response.data.success;
|
||||
} else {
|
||||
fcn_showNotification(response.data.error, 10, 'warning');
|
||||
fcn_showNotification(
|
||||
response.data.failure ?? response.data.error ?? fictioneer_tl.notification.error,
|
||||
10,
|
||||
'warning'
|
||||
);
|
||||
|
||||
// Make sure the actual error (if any) is printed to the console too
|
||||
if (response.data.error || response.data.failure) {
|
||||
console.error('Error:', response.data.error ?? response.data.failure);
|
||||
}
|
||||
}
|
||||
})
|
||||
.catch(error => {
|
||||
if (error.status && error.statusText) {
|
||||
fcn_showNotification(`${error.status}: ${error.statusText}`, 10, 'warning');
|
||||
}
|
||||
|
||||
console.error(error);
|
||||
})
|
||||
.then(() => {
|
||||
card.classList.remove('ajax-in-progress');
|
||||
|
Loading…
x
Reference in New Issue
Block a user