-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: show picture of current profile
- Loading branch information
Showing
6 changed files
with
98 additions
and
31 deletions.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { Avatar, AvatarProps } from '@mui/material' | ||
import { parseIpfs } from '../../helpers' | ||
import { MediaSet, NftImage } from '../../lens/schema/graphql' | ||
|
||
interface ProfileWithPictureInfo { | ||
picture?: MediaSet | Pick<NftImage, '__typename' | 'uri'> | null | ||
} | ||
|
||
const getProfilePictureUrl = (profile: ProfileWithPictureInfo) => { | ||
if (!profile.picture) return | ||
|
||
if (profile.picture?.__typename === 'MediaSet') { | ||
return parseIpfs(profile.picture.original.url) | ||
} | ||
|
||
if (profile.picture.__typename === 'NftImage') { | ||
return parseIpfs(profile.picture.uri) | ||
} | ||
} | ||
|
||
type ProfilePictureProps = AvatarProps & { | ||
profile: ProfileWithPictureInfo | ||
} | ||
|
||
export const ProfilePicture = (props: ProfilePictureProps) => { | ||
const { profile, ...avatarProps } = props | ||
const url = getProfilePictureUrl(profile) | ||
return <Avatar {...avatarProps} src={url} /> | ||
} |
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.