At a more opportune place

This commit is contained in:
Manav Rathi 2024-04-16 19:57:08 +05:30
parent 2bb3e152f8
commit 138b775c13
No known key found for this signature in database

View file

@ -130,6 +130,7 @@ export default function Slideshow() {
setCurrentFile(nextFile);
setNextFile(nextNextFile);
precacheRenderableFileURL(nextNextFile);
};
const [renderableFileURL, setRenderableFileURL] = useState<string>("");
@ -162,21 +163,12 @@ export default function Slideshow() {
}
};
const precacheNextRenderableFileURL = async () => {
if (!nextFile) return;
const cacheValue = renderableFileURLCache.get(nextFile.id);
if (cacheValue) return;
const precacheRenderableFileURL = async (file: EnteFile) => {
if (renderableFileURLCache.get(file.id)) return;
try {
const blob = await getPreviewableImage(
nextFile as EnteFile,
castToken,
);
const blob = await getPreviewableImage(file as EnteFile, castToken);
const url = URL.createObjectURL(blob);
renderableFileURLCache.set(nextFile?.id, url);
renderableFileURLCache.set(file?.id, url);
} catch (e) {
return;
}
@ -186,10 +178,6 @@ export default function Slideshow() {
getRenderableFileURL();
}, [currentFile]);
useEffect(() => {
precacheNextRenderableFileURL();
}, [nextFile]);
return (
<>
<SlideshowContext.Provider value={{ showNextSlide }}>