diff --git src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js src/bp-templates/bp-nouveau/js/buddypress-activity-post-form.js
index 9a50fb7bc..2b8ce57a8 100644
|
|
|
window.bp = window.bp || {}; |
| 708 | 708 | } |
| 709 | 709 | |
| 710 | 710 | bp.ajax.post( 'post_update', _.extend( data, this.model.attributes ) ).done( function( response ) { |
| 711 | | var scope = bp.Nouveau.getStorage( 'bp-activity', 'scope' ), |
| 712 | | prepended = false; |
| | 711 | var store = bp.Nouveau.getStorage( 'bp-activity' ), |
| | 712 | searchTerms = $( '[data-bp-search="activity"] input[type="search"]' ).val(), matches = {}, |
| | 713 | toPrepend = false; |
| | 714 | |
| | 715 | // Look for matches if the stream displays search results. |
| | 716 | if ( searchTerms ) { |
| | 717 | searchTerms = new RegExp( searchTerms, 'im' ); |
| | 718 | matches = response.activity.match( searchTerms ); |
| | 719 | } |
| 713 | 720 | |
| 714 | | if ( ! response.is_directory || |
| 715 | | ( 'all' === scope && ( 'user' === self.model.get( 'object' ) || false === response.is_private ) ) || |
| 716 | | ( self.model.get( 'object' ) + 's' === scope ) |
| 717 | | ) { |
| | 721 | /** |
| | 722 | * Before injecting the activity into the stream, we need to check the filter |
| | 723 | * and search terms are consistent with it when posting from a single item or |
| | 724 | * from the Activity directory. |
| | 725 | */ |
| | 726 | if ( ( ! searchTerms || matches ) ) { |
| | 727 | toPrepend = ! store.filter || 0 === parseInt( store.filter, 10 ) || 'activity_update' === store.filter; |
| | 728 | } |
| 718 | 729 | |
| 719 | | if ( ! $( '#activity-' + response.id ).length ) { |
| 720 | | bp.Nouveau.inject( '#activity-stream ul.activity-list', response.activity, 'prepend' ); |
| 721 | | prepended = true; |
| 722 | | } |
| | 730 | /** |
| | 731 | * In the Activity directory, we also need to check the active scope. |
| | 732 | * eg: An update posted in a private group should only show when the |
| | 733 | * "My Groups" tab is active. |
| | 734 | */ |
| | 735 | if ( toPrepend && response.is_directory ) { |
| | 736 | toPrepend = ( 'all' === store.scope && ( 'user' === self.model.get( 'object' ) || false === response.is_private ) ) |
| | 737 | || ( self.model.get( 'object' ) + 's' === store.scope ); |
| 723 | 738 | } |
| 724 | 739 | |
| 725 | 740 | // Reset the form |
| 726 | 741 | self.resetForm(); |
| 727 | 742 | |
| 728 | | // Stop here if the activity has been added to the stream |
| 729 | | if ( prepended ) { |
| 730 | | return; |
| 731 | | } |
| | 743 | // Display a successful feedback if the acticity is not consistent with the displayed stream. |
| | 744 | if ( ! toPrepend ) { |
| | 745 | self.views.add( new bp.Views.activityFeedback( { value: response.message, type: 'updated' } ) ); |
| 732 | 746 | |
| 733 | | /** |
| 734 | | * Do not add to the stream if the scope is not consistent with the activity |
| 735 | | */ |
| 736 | | self.views.add( new bp.Views.activityFeedback( { value: response.message, type: 'updated' } ) ); |
| | 747 | // Inject the activity into the stream only if it hasn't been done already (HeartBeat). |
| | 748 | } else if ( ! $( '#activity-' + response.id ).length ) { |
| | 749 | |
| | 750 | // It's the very first activity, let's make sure the container can welcome it! |
| | 751 | if ( ! $( '#activity-stream ul.activity-list').length ) { |
| | 752 | $( '#activity-stream' ).html( $( '<ul></ul>').addClass( 'activity-list item-list bp-list' ) ); |
| | 753 | } |
| | 754 | |
| | 755 | // Prepend the activity. |
| | 756 | bp.Nouveau.inject( '#activity-stream ul.activity-list', response.activity, 'prepend' ); |
| | 757 | } |
| 737 | 758 | } ).fail( function( response ) { |
| 738 | 759 | |
| 739 | 760 | self.model.set( 'errors', { type: 'error', value: response.message } ); |
diff --git src/bp-templates/bp-nouveau/js/buddypress-nouveau.js src/bp-templates/bp-nouveau/js/buddypress-nouveau.js
index 763c74d54..8d9930282 100644
|
|
|
window.bp = window.bp || {}; |
| 103 | 103 | store = {}; |
| 104 | 104 | } |
| 105 | 105 | |
| 106 | | if ( undefined !== property && store[property] ) { |
| 107 | | return store[property]; |
| | 106 | if ( undefined !== property ) { |
| | 107 | return store[property] || false; |
| 108 | 108 | } |
| 109 | 109 | |
| 110 | 110 | return store; |