diff --git a/framegear/components/Frame/Frame.tsx b/framegear/components/Frame/Frame.tsx
index a361f64a85..32653ec4ab 100644
--- a/framegear/components/Frame/Frame.tsx
+++ b/framegear/components/Frame/Frame.tsx
@@ -4,6 +4,7 @@ import { useAtom } from 'jotai';
import { ChangeEvent, PropsWithChildren, useCallback, useMemo, useState } from 'react';
import { ExternalLinkIcon, ResetIcon, RocketIcon } from '@radix-ui/react-icons';
import { useRedirectModal } from '@/components/RedirectModalContext/RedirectModalContext';
+import { FrameMetadataWithImageObject } from '@/utils/frameResultToFrameMetadata';
export function Frame() {
const [results] = useAtom(frameResultsAtom);
@@ -14,40 +15,14 @@ export function Frame() {
const latestFrame = results[results.length - 1];
- if (!latestFrame.isValid) {
- return ;
- }
-
- return ;
+ return ;
}
-function ValidFrame({ tags }: { tags: Record }) {
+function ValidFrame({ metadata }: { metadata: FrameMetadataWithImageObject }) {
const [inputText, setInputText] = useState('');
- const { image, imageAspectRatioClassname, input, buttons } = useMemo(() => {
- const image = tags['fc:frame:image'];
- const imageAspectRatioClassname =
- tags['fc:frame:image:aspect_ratio'] === '1:1' ? 'aspect-square' : 'aspect-[1.91/1]';
- const input = tags['fc:frame:input:text'];
- // TODO: when debugger is live we will also need to extract actions, etc.
- const buttons = [1, 2, 3, 4].map((index) => {
- const key = `fc:frame:button:${index}`;
- const actionKey = `${key}:action`;
- const targetKey = `${key}:target`;
- const value = tags[key];
- const action = tags[actionKey] || 'post';
- const target = tags[targetKey] || tags['fc:frame:post_url'];
-
- // If value exists, we can return the whole object (incl. default values).
- // If it doesn't, then the truth is there is no button.
- return value ? { key, value, action, target, index } : undefined;
- });
- return {
- image,
- imageAspectRatioClassname,
- input,
- buttons,
- };
- }, [tags]);
+ const { image, input, buttons } = metadata;
+ const imageAspectRatioClassname =
+ metadata.image.aspectRatio === '1:1' ? 'aspect-square' : 'aspect-[1.91/1]';
const handleInputChange = useCallback(
(e: ChangeEvent) => setInputText(e.target.value),
@@ -59,7 +34,7 @@ function ValidFrame({ tags }: { tags: Record }) {
{/* eslint-disable-next-line @next/next/no-img-element */}
@@ -67,15 +42,21 @@ function ValidFrame({ tags }: { tags: Record }) {
)}
- {buttons.map((button) =>
+ {buttons?.map((button, index) =>
button ? (
-
- {button.value}
+
+ {button.label}
) : null,
)}
@@ -89,6 +70,7 @@ function ErrorFrame() {
// TODO: implement -- decide how to handle
// - simply show an error?
// - best effort rendering of what they do have?
+ // - maybe just ValidFrame with a red border?
return ;
}
@@ -97,7 +79,9 @@ function PlaceholderFrame() {