analogwp / analogwp-templates

Style Kits for Elementor adds a number of intuitive styling controls in the Elementor editor that allow you to apply styles globally or per page.
https://analogwp.com
27 stars 7 forks source link

Wrong key verified in array #388

Closed gvgvgvijayan closed 4 years ago

gvgvgvijayan commented 4 years ago

Replace in-array condition value to published instead of popularityIndex when sorting by published time.

https://github.com/analogwp/analogwp-templates/blob/develop/client/App.js#L347

Snippet where issue present:

    if ( 'latest' === value ) {
        const sorted = sortData.sort( ( a, b ) => {
            if ( 'popularityIndex' in a ) {
                if ( parseInt( getTime( a.published ) ) < parseInt( getTime( b.published ) ) ) {
                    return 1;
                }
                if ( parseInt( getTime( a.published ) ) > parseInt( getTime( b.published ) ) ) {
                    return -1;
                }
            }
            return 0;
        } );

        this.setState( { [ library ]: sorted } );
    }