Skip to content

Commit

Permalink
[Release] Hotfix 2.24.6 => 2.24.7 (patch) (#11537)
Browse files Browse the repository at this point in the history
* chore: bump version to 2.24.7

* fix(Lens): update profile typings according to graphql schema (#11536)

closes #11535

* fix: typing (#11538)

---------

Co-authored-by: Wukong Sun <158803171+swkatmask@users.noreply.github.com>
  • Loading branch information
guanbinrui and swkatmask committed Apr 2, 2024
1 parent 58d57f1 commit 27d368e
Show file tree
Hide file tree
Showing 9 changed files with 30 additions and 30 deletions.
2 changes: 1 addition & 1 deletion package.json
Expand Up @@ -8,7 +8,7 @@
"yarn": ">=999.0.0",
"npm": ">=999.0.0"
},
"version": "2.24.6",
"version": "2.24.7",
"private": true,
"license": "AGPL-3.0-or-later",
"scripts": {
Expand Down
Expand Up @@ -16,6 +16,7 @@ import { Icons } from '@masknet/icons'
import { NetworkPluginID } from '@masknet/shared-base'
import { ProfilePopup } from './ProfilePopup.js'
import { useWeb3ProfileTrans } from '../../locales/i18n_generated.js'
import { getProfileAvatar } from '../../utils.js'

const useStyles = makeStyles()((theme) => ({
container: {
Expand Down Expand Up @@ -97,17 +98,12 @@ export const HandlerDescription = memo<HandlerDescriptionProps>(({ profiles, cur
)
}

const avatar = getProfileAvatar(currentProfile) || new URL('../assets/Lens.png', import.meta.url).href

return (
<Box className={classes.container}>
<Box className={classes.description}>
<WalletIcon
classes={{ mainIcon: classes.avatar }}
size={36}
mainIcon={
currentProfile.metadata?.picture?.optimized.uri ||
new URL('../assets/Lens.png', import.meta.url).href
}
/>
<WalletIcon classes={{ mainIcon: classes.avatar }} size={36} mainIcon={avatar} />
<Box>
<Typography className={classes.name}>
{currentProfile.metadata?.displayName ?? currentProfile.handle.localName}
Expand Down
Expand Up @@ -18,7 +18,7 @@ import { first } from 'lodash-es'
import { useCallback, useMemo, useState, type MouseEvent } from 'react'
import { useAsyncRetry } from 'react-use'
import { Web3ProfileTrans, useWeb3ProfileTrans } from '../../../locales/i18n_generated.js'
import { getLensterLink } from '../../../utils.js'
import { getLensterLink, getProfileAvatar } from '../../../utils.js'
import { useConfettiExplosion } from '../../hooks/ConfettiExplosion/index.js'
import { useFollow } from '../../hooks/Lens/useFollow.js'
import { useUnfollow } from '../../hooks/Lens/useUnfollow.js'
Expand Down Expand Up @@ -316,10 +316,7 @@ export function FollowLensDialog({ handle, onClose }: Props) {
return
}, [wallet?.owner, chainId, profile, feeTokenBalance, pluginID, providerType, isSelf, currentProfile])

const avatar = useMemo(() => {
if (!profile?.metadata?.picture?.optimized.uri) return
return profile?.metadata?.picture.optimized.uri
}, [profile?.metadata?.picture?.optimized.uri])
const avatar = useMemo(() => getProfileAvatar(profile), [profile])

const handleProfileChange = useCallback((profile: LensBaseAPI.Profile) => {
setCurrentProfile(profile)
Expand Down
Expand Up @@ -16,6 +16,7 @@ import { Icons } from '@masknet/icons'
import { NetworkPluginID } from '@masknet/shared-base'
import { ProfilePopup } from '../ProfilePopup.js'
import { useWeb3ProfileTrans } from '../../../locales/i18n_generated.js'
import { getProfileAvatar } from '../../../utils.js'

const useStyles = makeStyles()((theme) => ({
container: {
Expand Down Expand Up @@ -96,18 +97,12 @@ export const HandlerDescription = memo<HandlerDescriptionProps>(({ profiles, cur
</Box>
)
}
const avatar = getProfileAvatar(currentProfile) || new URL('../../assets/Lens.png', import.meta.url).href

return (
<Box className={classes.container}>
<Box className={classes.description}>
<WalletIcon
classes={{ mainIcon: classes.avatar }}
size={36}
mainIcon={
currentProfile.metadata?.picture?.optimized.uri ||
new URL('../../assets/Lens.png', import.meta.url).href
}
/>
<WalletIcon classes={{ mainIcon: classes.avatar }} size={36} mainIcon={avatar} />
<Box>
<Typography className={classes.name}>
{currentProfile.metadata?.displayName ?? currentProfile.handle.localName}
Expand Down
Expand Up @@ -20,6 +20,7 @@ import { NetworkPluginID } from '@masknet/shared-base'
import { useChainContext, useProviderDescriptor, useWeb3Utils } from '@masknet/web3-hooks-base'
import { useWeb3ProfileTrans } from '../../locales/i18n_generated.js'
import { isSameAddress } from '@masknet/web3-shared-base'
import { getProfileAvatar } from '../../utils.js'

const useStyles = makeStyles()((theme) => ({
paper: {
Expand Down Expand Up @@ -152,7 +153,8 @@ export const ProfilePopup = memo<ProfilePopupProps>(function ProfilePopup({
horizontal: 'right',
}}>
<List disablePadding className={classes.list}>
{profiles?.map((profile) => {
{profiles.map((profile) => {
const avatar = getProfileAvatar(profile)
return (
<ListItemButton
className={classes.item}
Expand All @@ -162,11 +164,11 @@ export const ProfilePopup = memo<ProfilePopupProps>(function ProfilePopup({
onChange(profile)
}}>
<ListItemIcon>
{profile.metadata?.picture?.optimized.uri ?
{avatar ?
<Image
className={classes.avatar}
size={36}
src={profile.metadata.picture.optimized.uri}
src={avatar}
fallback={<Icons.Lens size={36} className={classes.avatar} />}
/>
: <Icons.Lens size={36} className={classes.avatar} />}
Expand Down
Expand Up @@ -17,6 +17,7 @@ const useStyles = makeStyles()((theme) => ({
width: 568,
height: 484,
padding: theme.spacing(1, 2, 0),
scrollbarWidth: 'none',
'::-webkit-scrollbar': {
display: 'none',
},
Expand Down
8 changes: 8 additions & 0 deletions packages/plugins/Web3Profile/src/utils.ts
@@ -1,5 +1,13 @@
import type { LensBaseAPI } from '@masknet/web3-providers/types'
import urlcat from 'urlcat'

export function getLensterLink(handle: string) {
return urlcat('https://hey.xyz/u/:handle', { handle })
}

export function getProfileAvatar(profile: LensBaseAPI.Profile | undefined) {
const picture = profile?.metadata?.picture
if (!picture) return
if ('optimized' in picture) return picture.optimized?.uri || picture.raw.uri
return picture.image.optimized?.uri || picture.image.raw.uri
}
3 changes: 3 additions & 0 deletions packages/web3-providers/src/Lens/index.ts
Expand Up @@ -32,6 +32,9 @@ const LensProfileQuery = `
}
... on NftImage {
image {
optimized {
uri
}
raw {
uri
}
Expand Down
8 changes: 3 additions & 5 deletions packages/web3-providers/src/types/Lens.ts
Expand Up @@ -50,11 +50,9 @@ export namespace LensBaseAPI {
metadata?: {
bio: string
displayName: string
picture?: {
optimized: {
uri: string
}
}
picture?:
| { optimized: { uri: string } | null; raw: { uri: string } }
| { image: { optimized: { uri: string } | null; raw: { uri: string } } }
coverPicture?: {
optimized: {
uri: string
Expand Down

0 comments on commit 27d368e

Please sign in to comment.