Skip to content

armgit / ente

Public Imported from GitHub
0

πŸ’š End-to-end encrypted cloud for everything.

fix(photos):release-slideshow-live-photo-urls

Aswin Asokede524134d3c
diff --git a/web/apps/photos/src/components/Collections/AlbumSlideshow.tsx b/web/apps/photos/src/components/Collections/AlbumSlideshow.tsx
index e72e9e4542..d778c1d039 100644
--- a/web/apps/photos/src/components/Collections/AlbumSlideshow.tsx
+++ b/web/apps/photos/src/components/Collections/AlbumSlideshow.tsx
@@ -215,31 +215,40 @@ function Slide({
useEffect(() => {
let cancelled = false;
+ const isCancelled = () => cancelled;
+ let livePhotoURL: string | undefined;
void downloadManager
.renderableThumbnailURL(file)
.then((url) => {
- if (!cancelled) setThumbnail(url);
+ if (!isCancelled()) setThumbnail(url);
})
.catch(() => undefined);
void downloadManager
.renderableSourceURLs(file)
.then(async (source) => {
- const url =
- source.type === "image"
- ? source.imageURL
- : source.type === "livePhoto"
- ? await source.imageURL()
- : undefined;
- if (!cancelled) setOriginal(url);
+ if (isCancelled()) return;
+ if (source.type === "livePhoto") {
+ const url = await source.imageURL();
+ if (isCancelled()) {
+ URL.revokeObjectURL(url);
+ } else {
+ // Only Live Photo still URLs are owned by this slide.
+ livePhotoURL = url;
+ setOriginal(url);
+ }
+ } else if (source.type === "image") {
+ setOriginal(source.imageURL);
+ }
})
.catch((error: unknown) => {
- if (!cancelled) {
+ if (!isCancelled()) {
log.error("Failed to load slideshow photo", error);
setFailed(true);
}
});
return () => {
cancelled = true;
+ if (livePhotoURL) URL.revokeObjectURL(livePhotoURL);
};
}, [file]);