diff --git a/src/app/components/url-preview/UrlPreviewCard.tsx b/src/app/components/url-preview/UrlPreviewCard.tsx
index 6ac2b0e5..590d06e5 100644
--- a/src/app/components/url-preview/UrlPreviewCard.tsx
+++ b/src/app/components/url-preview/UrlPreviewCard.tsx
@@ -13,7 +13,6 @@ import * as css from './UrlPreviewCard.css';
import { UrlPreview, UrlPreviewContent, UrlPreviewDescription, UrlPreviewImg } from './UrlPreview';
const linkStyles = { color: color.Success.Main };
-const TARGET_HEIGHT = 300;
export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: string | null }>(
({ url, ts, mediaType, ...props }, ref) => {
@@ -22,11 +21,6 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: s
const isDirect = !!mediaType;
- const [mediaDim, setMediaDim] = useState<{ w: number; h: number } | null>(null);
- const calculatedWidth = mediaDim
- ? Math.ceil((TARGET_HEIGHT * mediaDim.w) / mediaDim.h)
- : undefined;
-
const [previewStatus, loadPreview] = useAsyncCallback(
useCallback(() => {
if (isDirect) return Promise.resolve(null);
@@ -100,6 +94,34 @@ export const UrlPreviewCard = as<'div', { url: string; ts: number; mediaType?: s
);
};
+ let previewContent;
+ if (previewStatus.status === AsyncStatus.Success) {
+ previewContent = previewStatus.data ? (
+ renderContent(previewStatus.data)
+ ) : (
+
+
+ {decodeURIComponent(url)}
+
+
+ );
+ } else {
+ previewContent = (
+
+
+
+ );
+ }
+
return (
- {previewStatus.status === AsyncStatus.Success ? (
- previewStatus.data ? (
- renderContent(previewStatus.data)
- ) : (
-
-
- {decodeURIComponent(url)}
-
-
- )
- ) : (
-
-
-
- )}
+ {previewContent}
);
}