diff --git a/src/common/component/Message/URLPreview.tsx b/src/common/component/Message/URLPreview.tsx index 8143b566..422df2df 100644 --- a/src/common/component/Message/URLPreview.tsx +++ b/src/common/component/Message/URLPreview.tsx @@ -1,9 +1,12 @@ import { useState, useEffect } from "react"; +import { useDispatch } from "react-redux"; import { useLazyGetOGInfoQuery } from "../../../app/services/message"; +import { upsertOG } from "../../../app/slices/footprint"; import { useAppSelector } from "../../../app/store"; export default function URLPreview({ url = "" }) { + const dispatch = useDispatch(); const [favicon, setFavicon] = useState(""); const [getInfo, { isLoading }] = useLazyGetOGInfoQuery(); const ogData = useAppSelector(store => store.footprint.og[url]); @@ -32,12 +35,9 @@ export default function URLPreview({ url = "" }) { // const handleFavError = () => { // setFavicon(""); // }; - // const handleOGImageError = () => { - // setData(prev => { - // if (!prev) return prev; - // return { ...prev, ogImage: "" }; - // }); - // }; + const handleOGImageError = () => { + dispatch(upsertOG({ key: url, value: { ...ogData, images: [] } })); + }; if (isLoading) return
; if (!url || !data || !data.title) return null; const { title, description, ogImage } = data; @@ -50,7 +50,7 @@ export default function URLPreview({ url = "" }) {

{title}

{description}

- og image + og image
) : ( diff --git a/src/types/resource.ts b/src/types/resource.ts index a108defb..d8ab86d4 100644 --- a/src/types/resource.ts +++ b/src/types/resource.ts @@ -44,9 +44,7 @@ export interface OG { width?: number; height?: number; alt?: string; - }[ - - ]; + }[]; audios: { type?: string; url: string;