Skip to content

Commit

Permalink
set up check warning for other hubs
Browse files Browse the repository at this point in the history
  • Loading branch information
MrKevinOConnell committed Jun 28, 2024
1 parent bcbe2f7 commit d69518b
Showing 1 changed file with 48 additions and 42 deletions.
90 changes: 48 additions & 42 deletions src/app/[identifier]/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -46,45 +46,46 @@ export default function Page({ params }: ResponseProps) {
const [loading, setLoading] = useState(true);
const [showOtherHubs, setShowOtherHubs] = useState(false);

const fetchData = async () => {
setLoading(true);
const data = (await fetchCastAndFidData(hash, fid)) as any;
const checkWarning = (message: any) => {
if (!message) return [];
const expectedTypes = [
'USER_DATA_TYPE_PFP',
'USER_DATA_TYPE_DISPLAY',
'USER_DATA_TYPE_BIO',
'USER_DATA_TYPE_USERNAME',
];

const checkWarning = (message: any) => {
const expectedTypes = [
'USER_DATA_TYPE_PFP',
'USER_DATA_TYPE_DISPLAY',
'USER_DATA_TYPE_BIO',
'USER_DATA_TYPE_USERNAME',
];
if (message?.messages) {
const foundTypes = new Set();
message.messages.forEach((msg: any) => {
if (msg.data?.userDataBody?.type) {
foundTypes.add(msg.data.userDataBody.type);
}
});

if (message?.messages) {
const foundTypes = new Set();
message.messages.forEach((msg: any) => {
if (msg.data?.userDataBody?.type) {
foundTypes.add(msg.data.userDataBody.type);
}
});
return expectedTypes.filter((type) => !foundTypes.has(type));
}

return expectedTypes.filter((type) => !foundTypes.has(type));
}
const missingObjects = [];
const authorFid = message?.fid;
const expectedUsername = `!${authorFid}`;
const username = message?.username;
const pfp = message?.pfp?.url || message?.pfp_url;
const displayName = message?.display_name || message?.displayName;
const bio = message?.profile?.bio?.text;

const missingObjects = [];
const authorFid = message?.fid;
const expectedUsername = `!${authorFid}`;
const username = message?.username;
const pfp = message?.pfp?.url || message?.pfp_url;
const displayName = message?.display_name || message?.displayName;
const bio = message?.profile?.bio?.text;
if (!pfp) missingObjects.push('PFP');
if (!displayName) missingObjects.push('Display Name');
if (!bio) missingObjects.push('Bio');
if (!username || username === expectedUsername)
missingObjects.push('Username');

if (!pfp) missingObjects.push('PFP');
if (!displayName) missingObjects.push('Display Name');
if (!bio) missingObjects.push('Bio');
if (!username || username === expectedUsername)
missingObjects.push('Username');
return missingObjects;
};

return missingObjects;
};
const fetchData = async () => {
setLoading(true);
const data = (await fetchCastAndFidData(hash, fid)) as any;

const warpcastAuthorMissing = checkWarning(data.apiData.warpcast?.author);
const neynarAuthorMissing = checkWarning(
Expand Down Expand Up @@ -272,15 +273,20 @@ export default function Page({ params }: ResponseProps) {

{showOtherHubs && (
<div className="flex md:flex-row flex-col items-center my-5">
{hubs.slice(2).map((hub, index) => (
<div key={index}>
{renderHeader(
`${capitalizeNickname(hub.shortname)}`,
data?.hubData?.[index + 2],
[]
)}
</div>
))}
{hubs.slice(2).map((hub, index) => {
const hubData = data?.hubData?.[index + 2];
const authorData = hubData?.author?.fid || null;
const missingObjects = checkWarning(authorData);
return (
<div key={index}>
{renderHeader(
`${capitalizeNickname(hub.shortname)}`,
hubData,
missingObjects
)}
</div>
);
})}
</div>
)}
</div>
Expand Down

0 comments on commit d69518b

Please sign in to comment.