Skip to:
Content

BuddyPress.org

Changeset 7116


Ignore:
Timestamp:
05/28/2013 02:42:15 AM (13 years ago)
Author:
boonebgorges
Message:

Exclude dynamically added activity items when clicking Load More in directory

This prevents duplicate items appearing after Load More due to the numeric
offset caused by AJAX-inserted activity items.

Fixes #4897

Props imath

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/bp-templates/bp-legacy/buddypress-functions.php

    r7095 r7116  
    417417        if ( ! empty( $_POST['page'] ) && '-1' != $_POST['page'] )
    418418                $qs[] = 'page=' . absint( $_POST['page'] );
     419
     420        // exludes activity just posted and avoids duplicate ids
     421        if ( ! empty( $_POST['exclude_just_posted'] ) ) {
     422                $just_posted = wp_parse_id_list( $_POST['exclude_just_posted'] );
     423                $qs[] = 'exclude=' . implode( ',', $just_posted );
     424        }
    419425
    420426        $object_search_text = bp_get_search_default_text( $object );
  • trunk/bp-templates/bp-legacy/js/buddypress.js

    r7114 r7116  
    117117
    118118                                jq("#activity-stream").prepend(response);
    119                                 jq("#activity-stream li:first").addClass('new-update');
     119                                jq("#activity-stream li:first").addClass('new-update just-posted');
    120120
    121121                                if ( 0 != jq("#latest-update").length ) {
    … …  
    319319                        var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
    320320
     321                        var just_posted = [];
     322                       
     323                        jq('.activity-list li.just-posted').each( function(){
     324                                just_posted.push( jq(this).attr('id').replace( 'activity-','' ) );
     325                        });
     326
    321327                        jq.post( ajaxurl, {
    322328                                action: 'activity_get_older_updates',
    323329                                'cookie': bp_get_cookies(),
    324                                 'page': oldest_page
     330                                'page': oldest_page,
     331                                'exclude_just_posted': just_posted.join(',')
    325332                        },
    326333                        function(response)
  • trunk/bp-themes/bp-default/_inc/ajax.php

    r7095 r7116  
    126126        if ( ! empty( $_POST['page'] ) && '-1' != $_POST['page'] )
    127127                $qs[] = 'page=' . absint( $_POST['page'] );
     128
     129        // exludes activity just posted and avoids duplicate ids
     130        if ( ! empty( $_POST['exclude_just_posted'] ) ) {
     131                $just_posted = wp_parse_id_list( $_POST['exclude_just_posted'] );
     132                $qs[] = 'exclude=' . implode( ',', $just_posted );
     133        }
    128134
    129135        $object_search_text = bp_get_search_default_text( $object );
  • trunk/bp-themes/bp-default/_inc/global.js

    r7114 r7116  
    117117
    118118                                jq("ul#activity-stream").prepend(response);
    119                                 jq("ul#activity-stream li:first").addClass('new-update');
     119                                jq("ul#activity-stream li:first").addClass('new-update just-posted');
    120120
    121121                                if ( 0 != jq("#latest-update").length ) {
    … …  
    316316                        var oldest_page = ( jq.cookie('bp-activity-oldestpage') * 1 ) + 1;
    317317
     318                        var just_posted = [];
     319                       
     320                        jq('.activity-list li.just-posted').each( function(){
     321                                just_posted.push( jq(this).attr('id').replace( 'activity-','' ) );
     322                        });
     323
    318324                        jq.post( ajaxurl, {
    319325                                action: 'activity_get_older_updates',
    320326                                'cookie': bp_get_cookies(),
    321                                 'page': oldest_page
     327                                'page': oldest_page,
     328                                'exclude_just_posted': just_posted.join(',')
    322329                        },
    323330                        function(response)
Note: See TracChangeset for help on using the changeset viewer.