imath / bp-reshare

BuddyPress component to reshare activities
33 stars 16 forks source link

All the activities in the stream of the user profil get shown as reshared #26

Open TheVrai opened 6 years ago

TheVrai commented 6 years ago

In v.2.1, for WP 4.9.4, BP 2.9.4 : all the activities in the stream of the user profil get shown as reshared, if you choose to modify the activity avatar to be full and not thumb. It is due to the line #390 of the script.js which look whether the src of the activity avatar is different to mark it as reshared. I'm trying to patch it, probably by parsing the classes of the avatars (which the id number in it) and then will do a pull request. Thx for all the great job !

ShastinaSandman commented 5 years ago

Wondering if there was an update on this... same thing happened to me as well. :-/

TheVrai commented 5 years ago

Hi, I've done a patch of the script which is working till now. It's from the line #391, to #401, replace it with : ` if ( bpReshare.displayedUser ) { var activityAvatar = $( selector ).find( '.activity-avatar' ), / Change by TheVrai : avatar id parsed in the class instead of the img src / displayedUserAvatarId = $( bpReshare.displayedUser.avatar ).prop( 'class' ).split( 'avatar' )[1];

            if ( displayedUserAvatarId !== activityAvatar.find( 'img' ).prop( 'class' ).split( 'avatar' )[1] && ! $( selector ).find( '.activity-reshared-by' ).length ) {
                /*
                **Change by TheVrai : to avoid marking up friendship created activities
                **
                */
                if($( selector ).prop('class').indexOf('friendship_created')!==-1 ){
                    var secondaryActityAvatarId = $( selector ).find('.activity-header img').prop('class').split('avatar')[1];
                    if(displayedUserAvatarId == secondaryActityAvatarId ){
                        return;
                    }
                }
                $( activityAvatar ).before(
                $( '<div></div>' ).addClass( 'activity-reshared-by' )
                              .html( bpReshare.displayedUser.resharedText.replace( '%s', bpReshare.displayedUser.avatar ) )
                );                      
            }
        }`

I'm doing a pull request soon.

ShastinaSandman commented 5 years ago

Sadly that did not work for me :( any other ideas?

imath commented 5 years ago

I'm not sure to understand the issue. If I rephrase it like this:

All the activities posted by the user are shown into the Reshared Activities subnav of the user's profile activities

is it what's happening. Because I've just found a bug about it when the option to order the stream by number of reshares in on.

ShastinaSandman commented 5 years ago

Hello imath,

I will activate the plugin today on my staging site, update the code and see if the issue is still there and let you know. Thanks so much for all your continuous hard work. 🤗

ShastinaSandman commented 5 years ago

It works!! Thank you so much :) so thankful

imath commented 5 years ago

Thanks a lot for your feedback 👌