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: tips data maybe null #557

Merged
merged 1 commit into from
Feb 21, 2024
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
27 changes: 19 additions & 8 deletions apps/u3/src/components/social/farcaster/FCastTipDetail.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ export default function FCastTipDetail({ cast }: { cast: FarCast }) {
const [loading, setLoading] = useState(false);
const [tipDetails, setTipDetails] = useState<
{
fromFid: number;
amount: number;
createdAt: number;
txHash: string;
Expand Down Expand Up @@ -88,6 +89,7 @@ function TipDetailsModal({
open: boolean;
setOpen: (open: boolean) => void;
details: {
fromFid: number;
amount: number;
txHash: string;
createdAt: number;
Expand All @@ -103,8 +105,8 @@ function TipDetailsModal({
closeModal={() => {
setOpen(false);
}}
contentTop="40%"
className="w-full md:w-[600px]"
contentTop="50%"
className="w-full md:w-[600px] max-h-full overflow-y-auto"
>
{(loading && (
<div className="flex justify-center items-center min-h-36">
Expand Down Expand Up @@ -146,21 +148,30 @@ function TipDetailsModal({
</TableHeader>
<TableBody className="border-none mb-5">
{details.map((detail, index) => {
const avatar = detail.userDatas.find((item) => item.type === 1);
const name = detail.userDatas.find((item) => item.type === 2);
const handle = detail.userDatas.find((item) => item.type === 6);
const avatar = (detail.userDatas &&
detail.userDatas.find((item) => item.type === 1)) || {
value: '',
};
const name = (detail.userDatas &&
detail.userDatas.find((item) => item.type === 2)) || {
value: detail.fromFid,
};
const handle = (detail.userDatas &&
detail.userDatas.find((item) => item.type === 6)) || {
value: detail.fromFid,
};
return (
<TableRow key={detail.createdAt} className="border-none">
<TableCell className="font-medium flex gap-3">
<img
src={avatar.value}
src={avatar?.value}
alt=""
className="w-12 h-12 object-cover rounded-full"
/>
<div>
<div className="text-lg">{name.value}</div>
<div className="text-lg">{name?.value}</div>
<div className="text-sm text-[#718096]">
@{handle.value}
@{handle?.value}
</div>
</div>
</TableCell>
Expand Down
8 changes: 1 addition & 7 deletions apps/u3/src/components/social/farcaster/FCastTips.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -101,13 +101,7 @@ export default function FCastTips({
// notify
cast.tipsTotalAmount =
(cast.tipsTotalAmount || 0) + Number(allowanceValue);
await notifyTipApi({
fromFid: currFid,
amount: Number(allowanceValue),
txHash: '',
type: 'Allowance',
castHash: Buffer.from(cast.hash.data).toString('hex'),
});

setReplyTipAmount(allowanceValue);
setReplyTipTimes(Number(getReplyTipTimes()) - 1);
setReplyTipAmountTotal(
Expand Down