Precache
This commit is contained in:
parent
f78e4d3914
commit
2bb3e152f8
1 changed files with 25 additions and 3 deletions
|
@ -162,12 +162,34 @@ export default function Slideshow() {
|
|||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
if (currentFile) {
|
||||
getRenderableFileURL();
|
||||
const precacheNextRenderableFileURL = async () => {
|
||||
if (!nextFile) return;
|
||||
|
||||
const cacheValue = renderableFileURLCache.get(nextFile.id);
|
||||
if (cacheValue) return;
|
||||
|
||||
try {
|
||||
const blob = await getPreviewableImage(
|
||||
nextFile as EnteFile,
|
||||
castToken,
|
||||
);
|
||||
|
||||
const url = URL.createObjectURL(blob);
|
||||
|
||||
renderableFileURLCache.set(nextFile?.id, url);
|
||||
} catch (e) {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
getRenderableFileURL();
|
||||
}, [currentFile]);
|
||||
|
||||
useEffect(() => {
|
||||
precacheNextRenderableFileURL();
|
||||
}, [nextFile]);
|
||||
|
||||
return (
|
||||
<>
|
||||
<SlideshowContext.Provider value={{ showNextSlide }}>
|
||||
|
|
Loading…
Add table
Reference in a new issue