import { convertFileSrc } from '@tauri-apps/api/core'; import classNames from 'classnames'; import { useState } from 'react'; import type { HttpResponse } from '@yaakapp/api'; interface Props { response: HttpResponse; className?: string; } export function ImageViewer({ response, className }: Props) { const bytes = response.contentLength ?? 0; const [show, setShow] = useState(bytes < 3 * 1000 * 1000); if (response.bodyPath === null) { return
Empty response body
; } const src = convertFileSrc(response.bodyPath); if (!show) { return ( <>
Response body is too large to preview.{' '}
); } return ( Response preview ); }