Skip to content

Commit

Permalink
refactor: replace type assertions and improve fallback handling
Browse files Browse the repository at this point in the history
- **poster-top-titles.tsx**: Removed unnecessary `as any` assertion for `picture` metadata URI.
- **use-is-verified.ts**: Switched from `||` to `??` for error fallback handling.
- **finance-quick-transfer.tsx**: Introduced explicit typing with `ProfilePicture_ImageSet_` and adjusted avatar logic for clarity.
- **publication-detail-main.tsx**: Improved `picture` metadata URI fallback, removing redundant `any` assertions.
- **publication-details-view.tsx**: Added a `customImage` prop for OG meta tags fallback.
- **profile-referrals-table-row.tsx**: Marked `Props` as readonly for better immutability.
- **publication-comment-item.tsx**: Removed `as any` assertion and refined fallback logic for comment avatars.
  • Loading branch information
cswni committed Jan 20, 2025
1 parent 716cc8f commit 8775a9f
Show file tree
Hide file tree
Showing 7 changed files with 20 additions and 9 deletions.
2 changes: 1 addition & 1 deletion src/components/poster/variants/poster-top-titles.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ const PosterTopTitles = ({ post }: { post: any }) => {
ratio={'1/1'}
style={{ width: '20px', height: '20px', borderRadius: '50%' }}
src={
(post?.by?.metadata?.picture as any)?.optimized?.uri ?? dicebear(post?.by?.id)
post?.by?.metadata?.picture?.optimized?.uri ?? dicebear(post?.by?.id)
}
/>
{post?.by?.metadata?.displayName ?? post?.by?.handle?.localName}
Expand Down
4 changes: 2 additions & 2 deletions src/components/publication-detail-main.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,7 @@ export default function PublicationDetailMain({
id: post.by.id,
displayName: post?.by?.metadata?.displayName,
avatar:
(post?.by?.metadata?.picture as any)?.optimized?.uri ?? dicebear(post?.by?.id),
post?.by?.metadata?.picture?.optimized?.uri ?? dicebear(post?.by?.id),
},
{
rawDescription: `${sessionData?.profile?.metadata?.displayName} liked ${post?.metadata?.title}`,
Expand Down Expand Up @@ -463,7 +463,7 @@ export default function PublicationDetailMain({
id: post?.by?.id,
displayName: post?.by?.metadata?.displayName,
avatar:
(post?.by?.metadata?.picture as any)?.optimized?.uri ?? dicebear(post?.by?.id),
post?.by?.metadata?.picture?.optimized?.uri ?? dicebear(post?.by?.id),
}}
/>
) : (
Expand Down
2 changes: 1 addition & 1 deletion src/hooks/use-is-verified.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,6 @@ export const useIsVerified = (account: Address): UseIsVerifiedHook => {
return {
isVerified,
loading,
error: error?.message || null,
error: error?.message ?? null,
};
};
13 changes: 12 additions & 1 deletion src/sections/finance/components/finance-quick-transfer.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,13 @@ export default function FinanceQuickTransfer({
const confirm = useBoolean();
const MAX_AMOUNT = balance;


interface ProfilePicture_ImageSet_ {
optimized: {
uri: string;
};
}

// This gets the current profile in the carousel
const getContactInfo: Profile | undefined = list?.find((_, index) => index === currentIndex);

Expand Down Expand Up @@ -344,7 +351,11 @@ export default function FinanceQuickTransfer({
placement="top"
>
<AvatarProfile
src={(profile?.metadata?.picture as any)?.optimized?.uri ?? profile?.id}
src={
profile?.metadata?.picture && 'optimized' in profile.metadata.picture
? (profile.metadata.picture as ProfilePicture_ImageSet_).optimized.uri
: profile?.id
}
alt={profile?.handle?.localName ?? ''}
sx={{
mx: 'auto',
Expand Down
2 changes: 1 addition & 1 deletion src/sections/publication/publication-comment-item.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ export default function PublicationCommentItem({ comment, hasReply, canReply }:
owner={{
id: comment?.by?.id,
displayName: comment?.by?.metadata?.displayName,
avatar: (comment?.by?.metadata?.picture as any)?.optimized?.uri ?? comment?.by?.id,
avatar: comment?.by?.metadata?.picture?.optimized?.uri ?? comment?.by?.id,
}}
/>
) : (
Expand Down
4 changes: 2 additions & 2 deletions src/sections/publication/view/publication-details-view.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -380,11 +380,11 @@ interface PublicationDetailsTagsProps {
publicationId: string
}

const PublicationDetailsTags: FC<PropsWithChildren<PublicationDetailsTagsProps>> = ({ title, publicationId, children }) => {
const PublicationDetailsTags: FC<PropsWithChildren<PublicationDetailsTagsProps>> = ({ title, publicationId, image: customImage, children }) => {
// OG META TAGS DATA
const metaTitle = `Watchit: ${title}`
const description = 'Check out this amazing publication on Watchit, where content meets Web3 & AI.'
const image = GLOBAL_CONSTANTS.LOGO_URL
const image = customImage ?? GLOBAL_CONSTANTS.LOGO_URL
const url = `${GLOBAL_CONSTANTS.BASE_URL}/publication/${publicationId}`

return <OgMetaTags
Expand Down
2 changes: 1 addition & 1 deletion src/sections/user/view/profile-referrals-table-row.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const capitalizeFirstLetter = (string: string) => {

// ----------------------------------------------------------------------

export default function ProfileReferralsTableRow({ row, selected }: Props) {
export default function ProfileReferralsTableRow({ row, selected }: Readonly<Props>) {
const { destination, status, created_at: date, id, receiver_id } = row;
const router = useRouter();

Expand Down

0 comments on commit 8775a9f

Please sign in to comment.