Reputation: 3
I am building a social networking application using ReactJs frontend, Adonisjs backend and Getstream-io. The features include:
My problem: I want to add functionality for bookmarking posts. I can't think of a way to do this. Is there a way to push a certain activity to a user's "bookmark" feed?.
I thought about just saving the post to my own database but then I realized that this won't work because it won't show with latest reactions when I display them in the bookmarks page. If anyone has done something like this before then your help is greatly appreciated, thanks.
Upvotes: 0
Views: 46
Reputation: 321
I'm assuming that "bookmarking" a post is not a problem for you. The underlying question is how to structure so that you can show the bookmarked activities for a user?
Regarding how to "bookmark" a post, same as the recommendation from @Robot-43, you can add it as a reaction to the post.
Regarding how to structure so that you can have a page that lists all the bookmarked posts, here is my suggestion:
You can get all reactions of a userId
and filter it by kind
https://getstream.io/activity-feeds/docs/dotnet-csharp/reactions_introduction/#retrieving-reactions
You can read reactions and filter them based on their user_id or activity_id values. Further filtering can be done with the kind parameter (e.g. retrieve all likes by one user, retrieve all comments for one activity, etc.).
Request an API to get all the reactions filtering by the user's ID, and the "bookmark" reaction kind, now you get a list of activityIds with that reaction.
Next make a request to the batch activity get
API, and send the list of activityIds in the request.
https://getstream.io/activity-feeds/docs/dotnet-csharp/add_many_activities/#batch-get-activities-by-id
You can also find the batch enriched activity get
in the source code probably, even if it's not documented in the website (if enriched activities is what you are using)
And then, you'll have your page :)
in batch activities get
, you can send 100 activityIds at a time.
Upvotes: 0
Reputation: 49
Simply create a feed and call it, say, bookmark.
If a user bookmark a post on, say another feed called "timeline", then you would add reaction on that post of kind called, say, "bookmark", and at the same time you would use "targetFeeds" to put it there.
Example: const bookmark = await client.reactions.add( 'bookmark', {id: '6d47e970-d317-11eb-8080-800109d57843'}, {}, { targetFeeds: ["bookmark:zoro"] } );
Then that feed will have these bookmarks.
You can check "own reaction" to see if activity on main feed (e.g timeline), which you did make the bookmark from, is already bookmarked or not and show banner to user or icon. And of course you have now the bookmark feed which can list all the bookmarks.
All likes/comments would be visible on all feeds, as this is fan out.
Upvotes: 0