import { forwardRef, useEffect, useState } from "react"; export interface AsyncImageProps extends React.DetailedHTMLProps< React.ImgHTMLAttributes, HTMLImageElement > { onSettled?: (url: string) => void; } export const AsyncImage = forwardRef( ({ onSettled, ...props }, ref) => { const [source, setSource] = useState(null); useEffect(() => { if (props.src && props.src.startsWith("http")) { window.electron.getOrCacheImage(props.src).then((url) => { setSource(url); if (onSettled) onSettled(url); }); } }, [props.src, onSettled]); return ; } );