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
Closed
Changes from all commits
Commits
Show all changes
8 commits
Select commit
Hold shift + click to select a range
6363ae9
chore: uses testnet addresses when seeding allowed tokens
iPaulPro fd53efe
fix: tip icon svg error
iPaulPro 3a782f3
fix: filters countOpenActions stats by collects only
iPaulPro b0c97ed
fix: filters collectors list by collect actions only
iPaulPro a9e8362
feat: shows tip counts, stats, and tippers
iPaulPro 29bd91d
fix: changes from review
iPaulPro 2a4305a
fix: shows tip data for comments and quotes
iPaulPro b969531
Merge branch 'main' into feat/tipping-data
bigint File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,111 @@ | ||
import type { Profile, WhoActedOnPublicationRequest } from '@hey/lens'; | ||
import type { FC } from 'react'; | ||
|
||
import ProfileListShimmer from '@components/Shared/Shimmer/ProfileListShimmer'; | ||
import UserProfile from '@components/Shared/UserProfile'; | ||
import { ArrowLeftIcon } from '@heroicons/react/24/outline'; | ||
import { ProfileLinkSource } from '@hey/data/tracking'; | ||
import { VerifiedOpenActionModules } from '@hey/data/verified-openaction-modules'; | ||
import { TipIcon } from '@hey/icons'; | ||
import { LimitType, useWhoActedOnPublicationQuery } from '@hey/lens'; | ||
import { Card, EmptyState, ErrorMessage } from '@hey/ui'; | ||
import Link from 'next/link'; | ||
import { Virtuoso } from 'react-virtuoso'; | ||
import { useProfileStore } from 'src/store/persisted/useProfileStore'; | ||
|
||
interface TippersProps { | ||
publicationId: string; | ||
} | ||
|
||
const Tippers: FC<TippersProps> = ({ publicationId }) => { | ||
const { currentProfile } = useProfileStore(); | ||
|
||
// Variables | ||
const request: WhoActedOnPublicationRequest = { | ||
limit: LimitType.TwentyFive, | ||
on: publicationId, | ||
where: { | ||
anyOf: [{ address: VerifiedOpenActionModules.Tip }] | ||
} | ||
}; | ||
|
||
const { data, error, fetchMore, loading } = useWhoActedOnPublicationQuery({ | ||
skip: !publicationId, | ||
variables: { request } | ||
}); | ||
|
||
const profiles = data?.whoActedOnPublication?.items; | ||
const pageInfo = data?.whoActedOnPublication?.pageInfo; | ||
const hasMore = pageInfo?.next; | ||
|
||
const onEndReached = async () => { | ||
if (!hasMore) { | ||
return; | ||
} | ||
|
||
await fetchMore({ | ||
variables: { request: { ...request, cursor: pageInfo?.next } } | ||
}); | ||
}; | ||
|
||
if (loading) { | ||
return <ProfileListShimmer />; | ||
} | ||
|
||
if (profiles?.length === 0) { | ||
return ( | ||
<div className="p-5"> | ||
<EmptyState | ||
hideCard | ||
icon={<TipIcon className="size-8" />} | ||
message="No tippers." | ||
/> | ||
</div> | ||
); | ||
} | ||
|
||
if (error) { | ||
return ( | ||
<ErrorMessage | ||
className="m-5" | ||
error={error} | ||
title="Failed to load tippers" | ||
/> | ||
); | ||
} | ||
|
||
return ( | ||
<Card> | ||
<div className="flex items-center space-x-3 p-5"> | ||
<Link href={`/posts/${publicationId}`}> | ||
<ArrowLeftIcon className="size-5" /> | ||
</Link> | ||
<b className="text-lg">Tipped by</b> | ||
</div> | ||
<div className="divider" /> | ||
<Virtuoso | ||
className="virtual-divider-list-window" | ||
computeItemKey={(index, profile) => `${profile.id}-${index}`} | ||
data={profiles} | ||
endReached={onEndReached} | ||
itemContent={(_, profile) => { | ||
return ( | ||
<div className="p-5"> | ||
<UserProfile | ||
hideFollowButton={currentProfile?.id === profile.id} | ||
hideUnfollowButton={currentProfile?.id === profile.id} | ||
profile={profile as Profile} | ||
showBio | ||
showUserPreview={false} | ||
source={ProfileLinkSource.Tips} | ||
/> | ||
</div> | ||
); | ||
}} | ||
useWindowScroll | ||
/> | ||
</Card> | ||
); | ||
}; | ||
|
||
export default Tippers; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
import ViewPublication from '@components/Publication'; | ||
|
||
export default ViewPublication; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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)