From 66bded813d22a4cf2f99110fd07f9d7655219d3b Mon Sep 17 00:00:00 2001 From: thislight Date: Sun, 27 Oct 2024 23:57:10 +0800 Subject: [PATCH] remove old placeholder algorithm - TootPreviewCard and MediaAttachmentGrid - the placeholder thing is now offloaded to the browser --- src/timelines/MediaAttachmentGrid.tsx | 40 ++++++++++++--------------- src/timelines/RegularToot.tsx | 3 ++ src/timelines/toot.module.css | 14 ++++++---- 3 files changed, 29 insertions(+), 28 deletions(-) diff --git a/src/timelines/MediaAttachmentGrid.tsx b/src/timelines/MediaAttachmentGrid.tsx index e22a767..2ae56be 100644 --- a/src/timelines/MediaAttachmentGrid.tsx +++ b/src/timelines/MediaAttachmentGrid.tsx @@ -81,58 +81,52 @@ const MediaAttachmentGrid: Component<{ > {(item, index) => { - const [loaded, setLoaded] = createSignal(false); - const width = item.meta?.small?.width; - const height = item.meta?.small?.height; - const aspectRatio = item.meta?.small?.aspect; - const maxHeight = vh35(); - const realHeight = height && height > maxHeight ? maxHeight : height; - const realWidth = - width && height && height > maxHeight - ? maxHeight * (aspectRatio ?? 1) - : width; - const style = () => - loaded() - ? undefined - : { - width: realWidth ? `${realWidth}px` : undefined, - height: realHeight ? `${realHeight}px` : undefined, - }; + // I don't know why mastodon does not return this + // and the condition for it to return this. + // Anyway, It is useless now. + // My hope is the FastAverageColor, but + // we may need better tool to manage the performance impact + // before using this. See #37. + // TODO: use fast average color to extract accent color + const accentColor = item.meta?.colors?.accent; switch (item.type) { case "image": return ( {item.description ); case "video": return (