Skip to content

Commit 0aa819c

Browse files
committed
feat: fixed everything up
1 parent 21e87b3 commit 0aa819c

File tree

5 files changed

+262
-210
lines changed

5 files changed

+262
-210
lines changed

platforms/blabsy/src/components/layout/user-home-layout.tsx

Lines changed: 96 additions & 87 deletions
Original file line numberDiff line numberDiff line change
@@ -19,102 +19,111 @@ import { UserShare } from '@components/user/user-share';
1919
import type { LayoutProps } from './common-layout';
2020

2121
export function UserHomeLayout({ children }: LayoutProps): JSX.Element {
22-
const { user, isAdmin } = useAuth();
23-
const { user: userData, loading } = useUser();
24-
const { push } = useRouter();
22+
const { user, isAdmin } = useAuth();
23+
const { user: userData, loading } = useUser();
24+
const { push } = useRouter();
2525

26-
const {
27-
query: { id }
28-
} = useRouter();
26+
const {
27+
query: { id }
28+
} = useRouter();
2929

30-
const coverData = userData?.coverPhotoURL
31-
? { src: userData.coverPhotoURL, alt: userData.name }
32-
: null;
30+
const coverData = userData?.coverPhotoURL
31+
? { src: userData.coverPhotoURL, alt: userData.name }
32+
: null;
3333

34-
const profileData = userData
35-
? { src: userData.photoURL, alt: userData.name }
36-
: null;
34+
const profileData = userData
35+
? { src: userData.photoURL, alt: userData.name }
36+
: null;
3737

38-
const { id: userId } = user ?? {};
38+
const { id: userId } = user ?? {};
3939

40-
const isOwner = userData?.id === userId;
40+
const isOwner = userData?.id === userId;
4141

42-
const handleMessage = async (): Promise<void> => {
43-
if (!user || !userData) return;
44-
45-
try {
46-
const chatId = await getOrCreateDirectChat(user.id, userData.id);
47-
await push(`/chat?chatId=${chatId}`);
48-
} catch (error) {
49-
console.error('Error creating chat:', error);
50-
}
51-
};
42+
const handleMessage = async (): Promise<void> => {
43+
if (!user || !userData) return;
5244

53-
return (
54-
<>
55-
{userData && (
56-
<SEO
57-
title={`${`${userData.name} (@${userData.username})`} / Twitter`}
58-
/>
59-
)}
60-
<motion.section {...variants} exit={undefined}>
61-
{loading ? (
62-
<Loading className='mt-5' />
63-
) : !userData ? (
64-
<>
65-
<UserHomeCover />
66-
<div className='flex flex-col gap-8'>
67-
<div className='relative flex flex-col gap-3 px-4 py-3'>
68-
<UserHomeAvatar />
69-
<p className='text-xl font-bold'>@{id}</p>
70-
</div>
71-
<div className='p-8 text-center'>
72-
<p className='text-3xl font-bold'>This account doesn't exist</p>
73-
<p className='text-light-secondary dark:text-dark-secondary'>
74-
Try searching for another.
75-
</p>
76-
</div>
77-
</div>
78-
</>
79-
) : (
80-
<>
81-
<UserHomeCover coverData={coverData} />
82-
<div className='relative flex flex-col gap-3 px-4 py-3'>
83-
<div className='flex justify-between'>
84-
<UserHomeAvatar profileData={profileData} />
85-
{isOwner ? (
86-
<UserEditProfile />
45+
try {
46+
const chatId = await getOrCreateDirectChat(user.id, userData.id);
47+
await push(`/chat?chatId=${chatId}`);
48+
} catch (error) {
49+
console.error('Error creating chat:', error);
50+
}
51+
};
52+
53+
return (
54+
<>
55+
{userData && (
56+
<SEO
57+
title={`${`${userData.name} (@${userData.username})`} / Twitter`}
58+
/>
59+
)}
60+
<motion.section {...variants} exit={undefined}>
61+
{loading ? (
62+
<Loading className='mt-5' />
63+
) : !userData ? (
64+
<>
65+
<UserHomeCover />
66+
<div className='flex flex-col gap-8'>
67+
<div className='relative flex flex-col gap-3 px-4 py-3'>
68+
<UserHomeAvatar />
69+
<p className='text-xl font-bold'>@{id}</p>
70+
</div>
71+
<div className='p-8 text-center'>
72+
<p className='text-3xl font-bold'>
73+
This account doesn't exist
74+
</p>
75+
<p className='text-light-secondary dark:text-dark-secondary'>
76+
Try searching for another.
77+
</p>
78+
</div>
79+
</div>
80+
</>
8781
) : (
88-
<div className='flex gap-2 self-start'>
89-
<UserShare username={userData.username} />
90-
<Button
91-
className='dark-bg-tab group relative border border-light-line-reply p-2
92-
hover:bg-light-primary/10 active:bg-light-primary/20 dark:border-light-secondary
82+
<>
83+
<UserHomeCover coverData={coverData} />
84+
<div className='relative flex flex-col gap-3 px-4 py-3'>
85+
<div className='flex justify-between'>
86+
<UserHomeAvatar profileData={profileData} />
87+
{isOwner ? (
88+
<UserEditProfile />
89+
) : (
90+
<div className='flex gap-2 self-start'>
91+
<UserShare
92+
username={userData.username}
93+
/>
94+
<Button
95+
className='dark-bg-tab group relative border border-light-line-reply p-2
96+
hover:bg-light-primary/10 active:bg-light-primary/20 dark:border-light-secondary
9397
dark:hover:bg-dark-primary/10 dark:active:bg-dark-primary/20'
94-
onClick={handleMessage}
95-
>
96-
<HeroIcon className='h-5 w-5' iconName='EnvelopeIcon' />
97-
<ToolTip tip='Message' />
98-
</Button>
99-
<FollowButton
100-
userTargetId={userData.id}
101-
userTargetUsername={userData.username}
102-
/>
103-
{isAdmin && <UserEditProfile hide />}
104-
</div>
98+
onClick={handleMessage}
99+
>
100+
<HeroIcon
101+
className='h-5 w-5'
102+
iconName='EnvelopeIcon'
103+
/>
104+
<ToolTip tip='Message' />
105+
</Button>
106+
<FollowButton
107+
userTargetId={userData.id}
108+
userTargetUsername={
109+
userData.username
110+
}
111+
/>
112+
{isAdmin && <UserEditProfile hide />}
113+
</div>
114+
)}
115+
</div>
116+
<UserDetails {...userData} />
117+
</div>
118+
</>
105119
)}
106-
</div>
107-
<UserDetails {...userData} />
108-
</div>
109-
</>
110-
)}
111-
</motion.section>
112-
{userData && (
113-
<>
114-
<UserNav />
115-
{children}
120+
</motion.section>
121+
{userData && (
122+
<>
123+
<UserNav />
124+
{children}
125+
</>
126+
)}
116127
</>
117-
)}
118-
</>
119-
);
128+
);
120129
}

platforms/blabsy/src/components/tweet/tweet.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -201,7 +201,7 @@ export function Tweet(tweet: TweetProps): JSX.Element {
201201
</p>
202202
)}
203203
<div className='mt-1 flex flex-col gap-2'>
204-
{images && (
204+
{images && images.length > 0 && (
205205
<ImagePreview
206206
tweet
207207
imagesPreview={images}
@@ -215,7 +215,7 @@ export function Tweet(tweet: TweetProps): JSX.Element {
215215
isOwner={isOwner}
216216
tweetId={tweetId}
217217
userLikes={userLikes}
218-
userReplies={userReplies}
218+
userReplies={0}
219219
userRetweets={userRetweets}
220220
openModal={
221221
!parent ? openModal : undefined

0 commit comments

Comments
 (0)