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

feat: better tipping data display #4779

Closed
wants to merge 8 commits into from

Conversation

iPaulPro
Copy link
Collaborator

What does this PR do?

This pull request focuses on better display of tipping and collect stats.

Related issues

Fixes #4778

Type of change

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Enhancement (non-breaking small changes to existing functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

Explanation of the changes

  1. Filters open action counts to only reflect collects.
  2. Changes "Action" verb back to "Collect" where appropriate.
  3. Adds query to get action count and actedOn operation for tips
  4. Queries for tip action data for each publication
  5. Displays tip counts
  6. Shows solid tip icon when acted on
  7. Adds /tippers sub page for publications

Screen Shot 2024-03-26 at 1 06 18 AM

localhost_4783_posts_0xed-0x19 (2)

localhost_4783_posts_0xed-0x19 (1)

Side effects

  1. The seedAllowedTokens script was updated to use Mumbai addresses where available when running on testnet.
  2. A "solid" variant of the TipIcon was created called TipIconSolid.
  3. A new ProfileLinkSource was added when showing /tippers called tips.
  4. A new UnknownOpenActionData query was added to get the action count and operation status of the current user for unknown action modules (like tipping).

@iPaulPro iPaulPro requested a review from bigint as a code owner March 26, 2024 05:50
Copy link

vercel bot commented Mar 26, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
web ✅ Ready (Inspect) Visit Preview Mar 27, 2024 3:36am

Copy link

vercel bot commented Mar 26, 2024

@iPaulPro is attempting to deploy a commit to the Hey Team on Vercel.

A member of the Team first needs to authorize it.

@iPaulPro iPaulPro changed the title Better tipping data display feat: better tipping data display Mar 26, 2024
- Removes unnecessary state for tip count and status
Boolean(tipData.publication.operations.actedOn.length);

const countTips =
(tipData?.publication?.__typename === 'Post' &&
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wondering why only post? why not comments, mirrors and quotes?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In the case of a mirror we're looking at the target publication ID, so it's still be true here if the original post has tips. I don't think Mirror type has operations, actually. I forgot tipping was enabled for comments and quotes on Hey, though, so I've added those in 2a4305a

Comment on lines +36 to +41
const { data: tipData } = useUnknownOpenActionDataQuery({
variables: {
module: VerifiedOpenActionModules.Tip,
pubId: targetPublication.id
}
});
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, this is interesting, just found out that it gonna rate limit users. When someone opens a feed and keeps scrolling, it gonna makes 1 extra API call per post. This need to be fixed by somehow using GraphQL alias

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Going to switch this PR to a draft since the current approach is not feasible due to rate limiting and partial alias support in graphql-codegen. (more here)

Comment on lines +1 to +40
query UnknownOpenActionData($module: EvmAddress!, $pubId: PublicationId!) {
publication(request: { forId: $pubId }) {
... on Post {
stats {
countOpenActions(request: { anyOf: { address: $module } })
}
operations {
actedOn(request: { filter: { address: $module } }) {
... on UnknownOpenActionResult {
address
}
}
}
}
... on Comment {
stats {
countOpenActions(request: { anyOf: { address: $module } })
}
operations {
actedOn(request: { filter: { address: $module } }) {
... on UnknownOpenActionResult {
address
}
}
}
}
... on Quote {
stats {
countOpenActions(request: { anyOf: { address: $module } })
}
operations {
actedOn(request: { filter: { address: $module } }) {
... on UnknownOpenActionResult {
address
}
}
}
}
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should not make an extra graphql request for this, instead try using alias inside

PublicationOperationFields.graphql and PublicationStatsFields.graphql

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So the issue is that aliases aren't fully supported by graphql-codegen. See this issue. The query type is properly generated, but not the return type. In our case, PublicationStats doesn't have the aliased field (even though it's properly returned by the query).

graphql-typescript-response-factories adds support for aliases but only at the top level, not in fragments (see this issue).

Any ideas on the best way to go about this?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thoughts:

  • An alias isn't actually needed in PublicationOperationFields since actedOn is not currently used -- I can move this directly from UnknownOpenActionData to PublicationOperationFields.
  • The publication details page could afford to make the separate query for the count, and keep the "Tippers" page.
  • We could do some server-side caching of the tip counts, as a last resort.

If we're unable to show the tip count in the feed, the other parts of this PR are probably still worthwhile. If we cannot find a way to make codegen work with aliases in fragments, or a suitable workaround, caching the tip counts might be a viable option, though not particularly desirable.

@iPaulPro iPaulPro marked this pull request as draft March 27, 2024 18:29
@iPaulPro
Copy link
Collaborator Author

@bigint I see that tipping was entirely removed, is this PR no longer worth working on?

@iPaulPro iPaulPro closed this Apr 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Tips are counted as Collects
2 participants