Skip to content

Commit

Permalink
Move setIsActive to onLoadEnd in AttachmentCarouselPage
Browse files Browse the repository at this point in the history
  • Loading branch information
WojtekBoman committed Dec 5, 2023
1 parent 692c787 commit 03435e5
Showing 1 changed file with 1 addition and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -42,16 +42,6 @@ function AttachmentCarouselPage({source, isAuthTokenRequired, isActive: initialI
const dimensions = cachedDimensions.get(source);

const [isActive, setIsActive] = useState(initialIsActive);
// We delay setting a page to active state by a (few) millisecond(s),
// to prevent the image transformer from flashing while still rendering
// Instead, we show the fallback image while the image transformer is loading the image
useEffect(() => {
if (initialIsActive) {
setTimeout(() => setIsActive(true), 1);
} else {
setIsActive(false);
}
}, [initialIsActive]);

const [initialActivePageLoad, setInitialActivePageLoad] = useState(isActive);
const isImageLoaded = useRef(null);
Expand Down Expand Up @@ -158,6 +148,7 @@ function AttachmentCarouselPage({source, isAuthTokenRequired, isActive: initialI
return;
}
setIsFallbackLoading(false);
setIsActive(true);
}}
onLoad={(evt) => {
const imageWidth = evt.nativeEvent.width;
Expand Down

0 comments on commit 03435e5

Please sign in to comment.