Skip to content
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

fix: profile bugs (10.17) #162

Merged
merged 1 commit into from
Oct 18, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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