Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Respost Issue #103

Closed
rlee1990 opened this issue Jun 22, 2021 · 14 comments
Closed

Respost Issue #103

rlee1990 opened this issue Jun 22, 2021 · 14 comments
Labels
question Further information is requested

Comments

@rlee1990
Copy link

I have a question. I am trying to do a repost/share as Facebook and Twitter do but when I use the code below I have issues. The activity is not copied to the target feed just the reaction does and not even the data that is added to the reaction.

streamClient!.reactions.add(
                                              'share', widget.post.id!,
                                              userId: streamClient
                                                  .currentUser!.userId,
                                              data: {
                                                'id': widget.post.id!,
                                              },
                                              targetFeeds: [
                                                feed.FeedId(
                                                    'user',
                                                    streamClient
                                                        .currentUser!.userId)
                                              ]);
@rlee1990 rlee1990 added the bug Something isn't working label Jun 22, 2021
@rlee1990
Copy link
Author

@sachaarbonel do you have any ideas on this?

@sachaarbonel
Copy link
Member

Can you expand on what you are trying to achieve? Add a count on the number of shares?
Also, what is your getEnrichedActivities query? Have you tried to add flags like flags: EnrichmentFlags().withOwnReactions()?

@rlee1990
Copy link
Author

The idea would be to achieve what Facebook and Twitter and others do for a retweet or repost. The support team sent me what I added above but when I add the reaction to the person that pressed the share buttons feed it really does not provide any useful information it doesn't even have the reaction data.

@sachaarbonel
Copy link
Member

sachaarbonel commented Jun 23, 2021

Oh I see, this currently being worked on as we speak but basically in a nutshell (trying to peel the layers for you):
to get the reaction counts:

count: reaction?.childrenCounts?[kind] ?? activity.reactionCounts?[kind],

to know if the user has already reacted:
ownReactions:
reaction?.ownChildren?[kind] ?? activity.ownReactions?[kind],

reactionsKind = widget.ownReactions?.filterByKind(widget.kind);
alreadyReacted = reactionsKind?.isNotEmpty != null;

based on that information we know if we should add or remove that reaction kind and wich icon we should display (repost, comment or heart for example)
alreadyReacted ? await removeReaction() : await addReaction();

for a repost reaction, "kind" being "repost"
you can then fetch your enriched activities like this for example (feedGroup here is the slug, for example user, etc)
.getEnrichedActivities(feedGroup: feedGroup),

@sachaarbonel sachaarbonel added question Further information is requested and removed bug Something isn't working labels Jun 23, 2021
@rlee1990
Copy link
Author

@sachaarbonel I think the issue is getting the activity as I already have the counts and added reactions but when I do this:

streamClient!.reactions.add(
                                              'share', widget.post.id!,
                                              userId: streamClient
                                                  .currentUser!.userId,
                                              data: {
                                                'id': widget.post.id!,
                                              },
                                              targetFeeds: [
                                                feed.FeedId(
                                                    'user',
                                                    streamClient
                                                        .currentUser!.userId)
                                              ]);

When trying to get the feed I have it set like this:

widget.streamClient!
        .flatFeed('user', widget.uid)
        .getEnrichedActivities(
            limit: 100,
            offset: 0,
            flags: EnrichmentFlags()
                .withReactionCounts()
                .withOwnReactions()
                .withRecentReactions()
                .withOwnChildren())

But the reaction is only there not the repost and the data that was added to the reaction is not there.

@sachaarbonel
Copy link
Member

What do you mean by the reaction is only there not the repost? As I understand the reaction is the repost.
Also, could you share some logs?

@rlee1990
Copy link
Author

@sachaarbonel This is all that shows in the user feed for the person that reposted an activity
Screen Shot 2021-06-23 at 10 33 15 AM

@rlee1990
Copy link
Author

Notice how on my reaction I even add data but its not there:

streamClient!.reactions.add(
                                              'share', widget.post.id!,
                                              userId: streamClient
                                                  .currentUser!.userId,
                                              data: {
                                                'id': widget.post.id!,
                                              },
                                              targetFeeds: [
                                                feed.FeedId(
                                                    'user',
                                                    streamClient
                                                        .currentUser!.userId)
                                              ]);

@sachaarbonel
Copy link
Member

sachaarbonel commented Jun 23, 2021

It works in my case, try to remove targetFeeds and let me know what you get
Capture d’écran 2021-06-23 à 10 37 51

@rlee1990
Copy link
Author

But then that defeats the point of a repost won't it. How will we get the activity?
Here is what I am trying to do.
User A adds a post to their user feed. The post shows on User B's timeline feed. User B clicks share or repost then the post from User B's timeline is added as an activity to User B's user feed and will show up on any feeds that follow User B's user feed.

@rlee1990
Copy link
Author

@sachaarbonel I hope that helps

@rlee1990
Copy link
Author

I think I see what is happening @sachaarbonel it looks like the post ID is added to the object field. I am trying to use that as a work around I will give that a go.

@sachaarbonel
Copy link
Member

Thanks for elaborating on this. I shared your issue with a member of the react team I'll get back to you when I have more input on this

@rlee1990
Copy link
Author

I got it to work it's odd but when I get the object for the reaction it then returns the whole post @sachaarbonel thanks for the help it got me to this. If the react team has a better approach I am all for it.

@rlee1990 rlee1990 closed this as completed Dec 4, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants