-
-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
@iPaulPro is attempting to deploy a commit to the Hey Team on Vercel. A member of the Team first needs to authorize it. |
apps/web/src/components/Publication/OpenAction/UnknownModule/Tip/index.tsx
Outdated
Show resolved
Hide resolved
- Removes unnecessary state for tip count and status
Boolean(tipData.publication.operations.actedOn.length); | ||
|
||
const countTips = | ||
(tipData?.publication?.__typename === 'Post' && |
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
const { data: tipData } = useUnknownOpenActionDataQuery({ | ||
variables: { | ||
module: VerifiedOpenActionModules.Tip, | ||
pubId: targetPublication.id | ||
} | ||
}); |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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)
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 | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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
sinceactedOn
is not currently used -- I can move this directly fromUnknownOpenActionData
toPublicationOperationFields
. - 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.
@bigint I see that tipping was entirely removed, is this PR no longer worth working on? |
What does this PR do?
This pull request focuses on better display of tipping and collect stats.
Related issues
Fixes #4778
Type of change
Explanation of the changes
actedOn
operation for tips/tippers
sub page for publicationsSide effects
seedAllowedTokens
script was updated to use Mumbai addresses where available when running ontestnet
.TipIcon
was created calledTipIconSolid
.ProfileLinkSource
was added when showing/tippers
calledtips
.UnknownOpenActionData
query was added to get the action count and operation status of the current user for unknown action modules (like tipping).