Facetwp add post_id to AJAX refresh

<?php
/** adds the post_id to a variable passed during refresh **/
add_action( 'wp_footer', function() {
    if ( is_singular() ) : ?>
        <script>
        (function($) {
            $(document).on('facetwp-refresh', function() {
                FWP_HTTP.post_id = <?php echo get_the_ID(); ?>;
            });
        })(jQuery);
        </script>
    <?php endif;
}, 100 );

/** access post_id in query args of facetwp listing template settings
 ** if using a visual query you'll first need to convert that to Dev mode
 ** advanced query args **/
add_filter( 'facetwp_query_args', function( $query_args, $class ) {
    if ( 'my_template_name' == $class->ajax_params['template'] ) {
        $post_id = isset( $class->http_params['post_id'] ) ? $class->http_params['post_id'] : get_the_id();
        // OR if that doesn't work as expected, use: $post_id = isset( FWP()->facet->http_params[ 'post_id' ] ) ? FWP()->facet->http_params[ 'post_id' ] : get_the_id();
    }
    return $query_args;
}, 10, 2 );