Skip to content

Commit

Permalink
Merge pull request #162 from us3r-network/B-profileBugs1017-shixuewen
Browse files Browse the repository at this point in the history
fix: profile bugs (10.17)
  • Loading branch information
sin-bufan authored Oct 18, 2023
2 parents 37ed5cd + ab22b64 commit f548c65
Show file tree
Hide file tree
Showing 4 changed files with 53 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ export default function HasU3ProfileInfoCard({
}
}

if (userData?.fid) {
if (userData?.fid && userData?.display) {
accounts.push({
platform: SocailPlatform.Farcaster,
avatar: userData.pfp,
Expand Down
43 changes: 43 additions & 0 deletions apps/u3/src/components/profile/profile-info/PlatformAccounts.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@ import styled, { StyledComponentPropsWithRef } from 'styled-components';
import { SocailPlatform } from '../../../api';
import LensIcon from '../../icons/LensIcon';
import FarcasterIcon from '../../icons/FarcasterIcon';
import { SocialButtonPrimary } from '../../social/button/SocialButton';
import { useLensCtx } from '../../../contexts/AppLensCtx';
import { useFarcasterCtx } from '../../../contexts/FarcasterCtx';

export type PlatformAccountsData = Array<{
platform: SocailPlatform;
Expand All @@ -11,13 +14,46 @@ export type PlatformAccountsData = Array<{
}>;
interface PlatformAccountsProps extends StyledComponentPropsWithRef<'div'> {
data: PlatformAccountsData;
isLoginUser?: boolean;
}
export default function PlatformAccounts({
data,
isLoginUser,
...wrapperProps
}: PlatformAccountsProps) {
const { isLogin: isLoginLens, setOpenLensLoginModal } = useLensCtx();
const { isConnected: isLoginFarcaster, openFarcasterQR } = useFarcasterCtx();
const findLensAccount = data?.find(
(item) => item.platform === SocailPlatform.Lens
);
const findFarcasterAccount = data?.find(
(item) => item.platform === SocailPlatform.Farcaster
);
return (
<Wrapper {...wrapperProps}>
{isLoginUser && !findLensAccount && (
<Row>
<Line />
<LensIcon width="40px" height="40px" />
<Center>
<LoginButton onClick={() => setOpenLensLoginModal(true)}>
{isLoginLens ? 'bind' : 'login'}
</LoginButton>
</Center>
</Row>
)}
{isLoginUser && !findFarcasterAccount && (
<Row>
<Line />
<FarcasterIcon width="40px" height="40px" />
<Center>
<LoginButton onClick={() => openFarcasterQR()}>
{isLoginFarcaster ? 'bind' : 'login'}
</LoginButton>
</Center>
</Row>
)}

{data.map((item) => (
<Row key={item.handle}>
<Line />
Expand Down Expand Up @@ -98,3 +134,10 @@ const Handle = styled.div`
font-weight: 400;
line-height: 24px;
`;

const LoginButton = styled(SocialButtonPrimary)`
width: 60px;
height: 24px;
font-size: 12px;
font-weight: 400;
`;
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { useCallback, useState } from 'react';
import { toast } from 'react-toastify';
import { Profile, useActiveProfile, useFollow } from '@lens-protocol/react-web';

import { useSession } from '@us3r-network/auth-with-rainbowkit';
import { ButtonPrimaryLineCss } from '../../common/button/ButtonBase';
import { InputBaseCss } from '../../common/input/InputBase';
import { TextareaBaseCss } from '../../common/input/TextareaBase';
Expand Down Expand Up @@ -43,6 +44,8 @@ export default function ProfileInfoBaseCard({
clickFollowers,
...wrapperProps
}: ProfileInfoBaseCardProps) {
const session = useSession();

const [isOpenEdit, setIsOpenEdit] = useState(false);
const canMesssage = useCanMessage(address);

Expand Down Expand Up @@ -107,7 +110,10 @@ export default function ProfileInfoBaseCard({
</BasicCenter>
</ProfileInfoBasicWrapper>

<PlatformAccounts data={platformAccounts} />
<PlatformAccounts
data={platformAccounts}
isLoginUser={isLoginUser}
/>

<UserInfo.Bio />

Expand All @@ -122,7 +128,7 @@ export default function ProfileInfoBaseCard({
</CountItem>
</CountsWrapper>

{(showFollowBtn || showMessageBtn) && (
{session?.id && (showFollowBtn || showMessageBtn) && (
<BtnsWrapper>
{showFollowBtn && (
<FollowBtn onClick={onFollow}>Follow</FollowBtn>
Expand Down
2 changes: 1 addition & 1 deletion apps/u3/src/container/Profile.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -334,7 +334,7 @@ function ProfileInfo({
return (
<ProfileInfoWrap {...props}>
<ProfileInfoCard
identity={identity}
identity={identity || did}
clickFollowing={clickFollowing}
clickFollowers={clickFollowers}
/>
Expand Down

0 comments on commit f548c65

Please sign in to comment.