diff --git a/src/components/hover-card/record.tsx b/src/components/hover-card/record.tsx index 52ac413..0fcab52 100644 --- a/src/components/hover-card/record.tsx +++ b/src/components/hover-card/record.tsx @@ -109,6 +109,7 @@ const RecordHoverCard = (props: RecordHoverCardProps) => { truncate newTab hideBlobs + preview /> diff --git a/src/components/json.tsx b/src/components/json.tsx index 464fdb6..c27b9e6 100644 --- a/src/components/json.tsx +++ b/src/components/json.tsx @@ -29,6 +29,7 @@ interface JSONContext { hideBlobs?: boolean; keyLinks?: boolean; path?: string; + preview?: boolean; } const JSONCtx = createContext(); @@ -161,7 +162,12 @@ const CollapsibleItem = (props: { }) => { const ctx = useJSONCtx(); const location = useLocation(); - const [show, setShow] = createSignal(true); + const isObject = () => props.value === Object(props.value); + const isEmpty = () => + Array.isArray(props.value) ? + (props.value as JSONType[]).length === 0 + : Object.keys(props.value as object).length === 0; + const [show, setShow] = createSignal(!(ctx.preview && isObject() && !isEmpty())); const isBlobContext = props.parentIsBlob ?? ctx.parentIsBlob; const labelStr = () => { @@ -181,11 +187,6 @@ const CollapsibleItem = (props: { } }); - const isObject = () => props.value === Object(props.value); - const isEmpty = () => - Array.isArray(props.value) ? - (props.value as JSONType[]).length === 0 - : Object.keys(props.value as object).length === 0; const summary = () => { if (Array.isArray(props.value)) { const len = (props.value as JSONType[]).length; @@ -245,10 +246,16 @@ const CollapsibleItem = (props: { @@ -269,12 +276,14 @@ const CollapsibleItem = (props: { - + + + @@ -464,6 +473,7 @@ export const JSONValue = (props: { newTab?: boolean; hideBlobs?: boolean; keyLinks?: boolean; + preview?: boolean; }) => { return ( diff --git a/src/views/car/explore.tsx b/src/views/car/explore.tsx index 6b2423c..d2cdb2e 100644 --- a/src/views/car/explore.tsx +++ b/src/views/car/explore.tsx @@ -853,7 +853,13 @@ const CollectionSubview = (props: { } > - + ); }} diff --git a/src/views/collection.tsx b/src/views/collection.tsx index 7f522dd..5309d93 100644 --- a/src/views/collection.tsx +++ b/src/views/collection.tsx @@ -57,6 +57,7 @@ const RecordLink = (props: { record: AtprotoRecord }) => { repo={props.record.record.uri.split("/")[2]} truncate hideBlobs + preview /> );