-
Notifications
You must be signed in to change notification settings - Fork 15
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
add SuggestedUser card row in mobile feed #2417
Merged
Merged
Changes from 10 commits
Commits
Show all changes
12 commits
Select commit
Hold shift + click to select a range
a8b51b2
still not sure how to use this though...
Rohan-cp 6084274
better...
Rohan-cp d169738
matches designs
Rohan-cp 161b67f
better
Rohan-cp 1f58fcc
added fallback
Rohan-cp 984c397
cleaner
Rohan-cp 68c4b38
minor
Rohan-cp 6fe183d
closer
Rohan-cp bd37f28
cleanup
Rohan-cp 89a3863
finale
Rohan-cp 83720c8
better
Rohan-cp bbd9c01
comment
Robinnnnn File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
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
87 changes: 87 additions & 0 deletions
87
apps/mobile/src/components/Feed/Posts/FeedSuggestedProfileRow.tsx
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,87 @@ | ||
import { useMemo } from 'react'; | ||
import { View } from 'react-native'; | ||
import { graphql, useFragment } from 'react-relay'; | ||
import { removeNullValues } from 'shared/relay/removeNullValues'; | ||
|
||
import { TrendingUserCard } from '~/components/Trending/TrendingUserCard'; | ||
import { FeedSuggestedProfileRowFragment$key } from '~/generated/FeedSuggestedProfileRowFragment.graphql'; | ||
|
||
import { Typography } from '../../Typography'; | ||
|
||
const CARD_HEIGHT = 180; | ||
const CARD_WIDTH = 180; | ||
|
||
type FeedSuggestedProfileRowProps = { | ||
queryRef: FeedSuggestedProfileRowFragment$key; | ||
}; | ||
|
||
export function FeedSuggestedProfileRow({ queryRef }: FeedSuggestedProfileRowProps) { | ||
const query = useFragment( | ||
graphql` | ||
fragment FeedSuggestedProfileRowFragment on Query { | ||
viewer @required(action: THROW) { | ||
... on Viewer { | ||
suggestedUsers(first: 4) @required(action: THROW) { | ||
__typename | ||
edges { | ||
node { | ||
__typename | ||
... on GalleryUser { | ||
galleries { | ||
tokenPreviews { | ||
__typename | ||
} | ||
} | ||
...TrendingUserCardFragment | ||
} | ||
} | ||
} | ||
} | ||
} | ||
} | ||
...TrendingUserCardQueryFragment | ||
} | ||
`, | ||
queryRef | ||
); | ||
|
||
const suggestedUsers = useMemo(() => { | ||
const users = []; | ||
if (query.viewer?.suggestedUsers?.__typename === 'UsersConnection') { | ||
for (const edge of query.viewer?.suggestedUsers?.edges ?? []) { | ||
if (edge?.node) { | ||
users.push(edge.node); | ||
} | ||
} | ||
} | ||
if (users) { | ||
const usersWithTokenPreviews = users.filter((user) => { | ||
return user?.galleries?.find( | ||
(gallery) => removeNullValues(gallery?.tokenPreviews).length > 0 | ||
); | ||
}); | ||
return usersWithTokenPreviews?.slice(0, 2); | ||
} | ||
return users; | ||
}, [query.viewer?.suggestedUsers]); | ||
|
||
return ( | ||
<View className="pl-4 mt-2 mb-12 space-y-3"> | ||
<Typography | ||
className="text-sm text-offBlack dark:text-offBlack" | ||
font={{ family: 'ABCDiatype', weight: 'Bold' }} | ||
> | ||
Suggested creators and collectors | ||
</Typography> | ||
<View className="space-x-1 flex flex-row"> | ||
{suggestedUsers?.map((user, idx) => { | ||
return ( | ||
<View className="mb-1" style={{ width: CARD_WIDTH, height: CARD_HEIGHT }} key={idx}> | ||
<TrendingUserCard userRef={user} queryRef={query} /> | ||
</View> | ||
); | ||
})} | ||
</View> | ||
</View> | ||
); | ||
} |
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.
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.
insertedRow
astrue
? i assumepostCount === SUGGESTED_PROFILE_ROW_IDX
would only be true a single time anyway?overall i'm wondering if there could be a simpler way to do this without the loop, like:
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.
yo @Robinnnnn, you're right we don't need the
insertedRow
variable, removed that now.Regarding using the splice, I think we can't use the hardcoded value for the index because the items of the list are
feed-post-header
,feed-post-socialize-section
, etc (basically subsections of a single post in the feed for all the posts) so we want to add the row only when it is before afeed-post-header
Or it might end up after a post and before its mint button for example.