0

I am using Get Stream Io react native in my project https://github.com/GetStream/react-native-activity-feed

I see there is a functionality in the library of following a particular user, whereas the opposite is not available i.e. how to unfollow a user.

Please point me in the right direction on how to achieve this in react native

1 Answers1

0

Our library doesn't include the logic for following/unfollowing. It has a button that allows you to set it up yourself though. Which is the FollowButton you're talking about. You could do something like this:

<FollowButton
  followed={async () => {
    // check if you're following the user
    const following = await your_timeline_feed.following({filter: ['user:user_42'] })
    if (following) {
      return true;
    }
    return false;
  }} // renders the button as "following"

  clicked={async () => {
    // your logic for following/unfollowing
    await your_timeline_feed.follow('user', 'user_42');
  }}
/>

Read more here:

Jaap Bakker
  • 165
  • 8
  • Thanks for your response, I am seeing a method `follow( targetFeedGroup: string, targetUserId: string | StreamUser, options?: FollowRequestOptions, ): Promise; ` in class `StreamFeed` which can be taken from `StreamClient` using this method `feed( feedGroup: string, userId?: string, ): StreamFeed;` No unfollow method in StreamFeed class. Do I need to explicitly hit an endpoint to achieve this unfollowing a user activity? or I am missing something here – Asim Khatri May 08 '20 at 09:03
  • https://github.com/GetStream/react-native-activity-feed/blob/master/custom-definitions/getstream.js at line 216. Only follow method is available and no unfollow – Asim Khatri May 08 '20 at 09:32
  • Those are custom definitions. We also use these, there should be an unfollow method on the feed. https://github.com/GetStream/stream-js/blob/23b86825c0e16e47acd5ede7700f7e67544e7502/types/getstream/index.d.ts#L169 – Jaap Bakker May 13 '20 at 08:28