-
Notifications
You must be signed in to change notification settings - Fork 588
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
Profiles: several bug fixes #3190
Changes from 8 commits
b56edb0
4d808d1
54470a8
be6891b
0edfe13
2c36b19
26e5bd3
03e5a2f
a1d485f
d6bc117
aa841ce
69b4152
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -255,7 +255,7 @@ const UniqueTokenExpandedState = ({ | |
const isNFT = uniqueTokenType === UniqueTokenType.NFT; | ||
|
||
// Fetch the ENS profile if the unique token is an ENS name. | ||
const cleanENSName = isENS ? uniqueId.split(' ')?.[0] : uniqueId; | ||
const cleanENSName = isENS && uniqueId ? uniqueId?.split(' ')?.[0] : uniqueId; | ||
const ensProfile = useENSProfile(cleanENSName, { enabled: isENS }); | ||
const ensData = ensProfile.data; | ||
|
||
|
@@ -355,8 +355,8 @@ const UniqueTokenExpandedState = ({ | |
const isActionsEnabled = !external && !isReadOnlyWallet; | ||
const hasSendButton = isActionsEnabled && isSendable; | ||
|
||
const hasEditButton = | ||
isActionsEnabled && profilesEnabled && isENS && ensProfile.isOwner; | ||
const isENSActionsEnabled = isActionsEnabled && profilesEnabled && isENS; | ||
const hasEditButton = isENSActionsEnabled && ensProfile.isOwner; | ||
|
||
const familyLinkDisplay = useMemo( | ||
() => | ||
|
@@ -529,7 +529,7 @@ const UniqueTokenExpandedState = ({ | |
registrationDate={ | ||
ensData?.registration.registrationDate | ||
} | ||
showEditButton={hasEditButton} | ||
showEditButton={isENSActionsEnabled} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not sure about the naming of this prop, doesn't this modify the ENS duration (not edit the ENS)? maybe There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. done! |
||
/> | ||
)} | ||
</Bleed> | ||
|
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -56,28 +56,32 @@ export default function useENSRecordDisplayProperties({ | |||||
() => Object.keys(imageKeyMap).includes(recordKey), | ||||||
[recordKey] | ||||||
); | ||||||
const isUrlValue = useMemo( | ||||||
|
||||||
const isUrlRecord = useMemo( | ||||||
() => | ||||||
recordValue.match(/^http/) || | ||||||
[ENS_RECORDS.url, ENS_RECORDS.website].includes(recordKey as ENS_RECORDS), | ||||||
[recordKey, recordValue] | ||||||
[recordKey] | ||||||
); | ||||||
const isUrlValue = useMemo(() => recordValue.match(/^http/), [recordValue]); | ||||||
|
||||||
const url = useMemo(() => { | ||||||
if (isUrlValue) { | ||||||
if (isUrlValue || isUrlRecord) { | ||||||
return recordValue.match(/^http/) | ||||||
? recordValue | ||||||
: `https://${recordValue}`; | ||||||
} | ||||||
if (links[recordKey]) { | ||||||
return `${links[recordKey]}${recordValue.replace('@', '')}`; | ||||||
} | ||||||
}, [isUrlValue, recordKey, recordValue]); | ||||||
}, [isUrlRecord, isUrlValue, recordKey, recordValue]); | ||||||
|
||||||
const displayUrl = useMemo( | ||||||
() => (url ? new URL(url).hostname.replace(/^www\./, '') : undefined), | ||||||
[url] | ||||||
); | ||||||
const { displayUrl, displayUrlUsername } = useMemo(() => { | ||||||
const urlObj = url ? new URL(url) : { hostname: '', pathname: '' }; | ||||||
return { | ||||||
displayUrl: urlObj?.hostname?.replace(/^www\./, ''), | ||||||
displayUrlUsername: urlObj?.pathname?.replace('/', ''), | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hm is not the hostname, for example https://twitter.com/estebanmino_ will return estebanmino_ There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. oh whoops my bad |
||||||
}; | ||||||
}, [url]); | ||||||
|
||||||
const label = useMemo(() => { | ||||||
// @ts-expect-error | ||||||
|
@@ -92,17 +96,28 @@ export default function useENSRecordDisplayProperties({ | |||||
}, [recordKey, type]); | ||||||
|
||||||
const value = useMemo(() => { | ||||||
if (isUrlValue && displayUrl) { | ||||||
if (isUrlRecord && displayUrl) { | ||||||
return ` ${displayUrl}`; | ||||||
} | ||||||
if (isUrlValue && displayUrlUsername) { | ||||||
return displayUrlUsername; | ||||||
} | ||||||
if (recordKey === ENS_RECORDS.email) { | ||||||
return ` ${recordValue}`; | ||||||
} | ||||||
if (type === 'address') { | ||||||
return formatAddressForDisplay(recordValue, 4, 4) || ''; | ||||||
} | ||||||
return recordValue; | ||||||
}, [displayUrl, isUrlValue, recordKey, recordValue, type]); | ||||||
}, [ | ||||||
displayUrl, | ||||||
displayUrlUsername, | ||||||
isUrlRecord, | ||||||
isUrlValue, | ||||||
recordKey, | ||||||
recordValue, | ||||||
type, | ||||||
]); | ||||||
|
||||||
const icon = useMemo(() => icons[recordKey], [recordKey]); | ||||||
|
||||||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -81,12 +81,13 @@ export default function ENSAssignRecordsSheet() { | |
}); | ||
|
||
const [avatarUrl, setAvatarUrl] = useState(initialAvatarUrl); | ||
|
||
const [accentColor, setAccentColor] = useRecoilState(accentColorAtom); | ||
|
||
const { result: dominantColor } = usePersistentDominantColorFromImage( | ||
avatarUrl || '' | ||
avatarUrl | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. added again, is a js file so it didn't say anything |
||
); | ||
const [prevDominantColor, setPrevDominantColor] = useState(dominantColor); | ||
|
||
useEffect(() => { | ||
setAccentColor(dominantColor || prevDominantColor || colors.purple); | ||
if (dominantColor) { | ||
|
@@ -185,7 +186,7 @@ export default function ENSAssignRecordsSheet() { | |
} | ||
|
||
export function ENSAssignRecordsBottomActions({ visible: defaultVisible }) { | ||
const { navigate } = useNavigation(); | ||
const { navigate, goBack } = useNavigation(); | ||
const keyboardHeight = useKeyboardHeight(); | ||
const [accentColor] = useRecoilState(accentColorAtom); | ||
|
||
|
@@ -295,16 +296,25 @@ export function ENSAssignRecordsBottomActions({ visible: defaultVisible }) { | |
{lang.t('profiles.create.skip')} | ||
</TintButton> | ||
) : ( | ||
<Box style={{ opacity: disabled ? 0.5 : 1 }}> | ||
<SheetActionButton | ||
color={accentColor} | ||
disabled={disabled} | ||
label={lang.t('profiles.create.review')} | ||
onPress={handlePressContinue} | ||
size="big" | ||
testID="ens-assign-records-review" | ||
weight="heavy" | ||
/> | ||
<Box> | ||
{!disabled ? ( | ||
<SheetActionButton | ||
color={accentColor} | ||
label={lang.t('profiles.create.review')} | ||
onPress={handlePressContinue} | ||
size="big" | ||
testID="ens-assign-records-review" | ||
weight="heavy" | ||
/> | ||
) : ( | ||
<TintButton | ||
color="secondary60" | ||
onPress={goBack} | ||
testID="ens-assign-records-cancel" | ||
> | ||
{lang.t(`profiles.create.cancel`)} | ||
</TintButton> | ||
)} | ||
</Box> | ||
)} | ||
</SheetActionButtonRow> | ||
|
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.
maybe leave this as
hasEditButton
, and the below line could behasENSExtendDurationButton
or somethingThere 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.
done!