diff --git src/bp-activity/bp-activity-filters.php src/bp-activity/bp-activity-filters.php
index c9e236b..c94dee7 100644
|
|
|
add_filter( 'bp_get_activity_css_class', 'bp_activity_timestamp_class', 9, 1 ); |
| 550 | 550 | * @return array $response |
| 551 | 551 | */ |
| 552 | 552 | function bp_activity_heartbeat_last_recorded( $response = array(), $data = array() ) { |
| | 553 | if ( ! empty( $data['bp_activity_timestamps'] ) ) { |
| | 554 | foreach ( (array) $data['bp_activity_timestamps'] as $activity_item ) { |
| | 555 | if ( ! empty( $activity_item['since'] ) ) { |
| | 556 | $response['bp_activity_refresh_items'][ $activity_item['activity_id'] ] = bp_core_time_since( (int) $activity_item['since'] ); |
| | 557 | } |
| | 558 | } |
| | 559 | } |
| | 560 | |
| 553 | 561 | if ( empty( $data['bp_activity_last_recorded'] ) ) { |
| 554 | 562 | return $response; |
| 555 | 563 | } |
diff --git src/bp-templates/bp-legacy/js/buddypress.js src/bp-templates/bp-legacy/js/buddypress.js
index 4c5e139..0afa10a 100644
|
|
|
jq(document).ready( function() { |
| 1760 | 1760 | // Set the last id to request after |
| 1761 | 1761 | var first_item_recorded = 0; |
| 1762 | 1762 | jq( document ).on( 'heartbeat-send.buddypress', function( e, data ) { |
| 1763 | | |
| | 1763 | var timestamps = []; |
| 1764 | 1764 | first_item_recorded = 0; |
| 1765 | 1765 | |
| 1766 | | // First row is default latest activity id |
| 1767 | | if ( jq( '#buddypress ul.activity-list li' ).first().prop( 'id' ) ) { |
| 1768 | | // getting the timestamp |
| 1769 | | timestamp = jq( '#buddypress ul.activity-list li' ).first().prop( 'class' ).match( /date-recorded-([0-9]+)/ ); |
| | 1766 | jq( '#buddypress ul.activity-list li' ).each( function( i ) { |
| | 1767 | var item = this, timestamp; |
| | 1768 | |
| | 1769 | timestamp = jq( item ).prop( 'class' ).match( /date-recorded-([0-9]+)/ ); |
| 1770 | 1770 | |
| 1771 | | if ( timestamp ) { |
| 1772 | | first_item_recorded = timestamp[1]; |
| | 1771 | if ( timestamp && null !== timestamp[1] ) { |
| | 1772 | // First row is default latest activity id |
| | 1773 | if ( 0 === i ) { |
| | 1774 | first_item_recorded = timestamp[1]; |
| | 1775 | } |
| | 1776 | |
| | 1777 | timestamps.push( { 'activity_id': jq( item ).prop( 'id' ), 'since': timestamp[1] } ); |
| 1773 | 1778 | } |
| | 1779 | } ); |
| | 1780 | |
| | 1781 | // Send the displayed activity timestamps |
| | 1782 | if ( 0 !== timestamps.length ) { |
| | 1783 | data.bp_activity_timestamps = timestamps; |
| 1774 | 1784 | } |
| 1775 | 1785 | |
| 1776 | 1786 | if ( 0 === activity_last_recorded || Number( first_item_recorded ) > activity_last_recorded ) { |
| … |
… |
jq(document).ready( function() { |
| 1789 | 1799 | // Increment newest_activities and activity_last_recorded if data has been returned |
| 1790 | 1800 | jq( document ).on( 'heartbeat-tick', function( e, data ) { |
| 1791 | 1801 | |
| | 1802 | // Refresh displayed activities time since |
| | 1803 | if ( data.bp_activity_refresh_items ) { |
| | 1804 | jq.each( data.bp_activity_refresh_items, function( activity_id, since ) { |
| | 1805 | jq( '#buddypress ul.activity-list li#' + activity_id + ' .activity-header .time-since' ).html( since ); |
| | 1806 | } ); |
| | 1807 | } |
| | 1808 | |
| 1792 | 1809 | // Only proceed if we have newest activities |
| 1793 | 1810 | if ( ! data.bp_activity_newest_activities ) { |
| 1794 | 1811 | return; |