From a96038bcb7fffac56569964fe0464f43015d15f9 Mon Sep 17 00:00:00 2001 From: schroda <50052685+schroda@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:03:20 +0100 Subject: [PATCH] Prevent image loading placeholder for cached images (#669) Give the image time to get loaded from the cache before setting the loading state --- src/components/util/SpinnerImage.tsx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/components/util/SpinnerImage.tsx b/src/components/util/SpinnerImage.tsx index 65e70754..406b8982 100644 --- a/src/components/util/SpinnerImage.tsx +++ b/src/components/util/SpinnerImage.tsx @@ -49,6 +49,7 @@ export const SpinnerImage = forwardRef((props: IProps, imgRef: ForwardedRef { let tmpImageSourceUrl: string; const imageRequest = requestManager.requestImage(src); + let cacheTimeout: NodeJS.Timeout; const fetchImage = async () => { try { @@ -60,7 +61,12 @@ export const SpinnerImage = forwardRef((props: IProps, imgRef: ForwardedRef { + cacheTimeout = setTimeout(resolve, 50); + }), + ]); const isImageCached = !!checkCache; if (isImageCached) { @@ -82,6 +88,7 @@ export const SpinnerImage = forwardRef((props: IProps, imgRef: ForwardedRef