Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix src not loading issue

Abhinav90a3459b8dfd
diff --git a/apps/photos/src/components/PhotoFrame.tsx b/apps/photos/src/components/PhotoFrame.tsx
index 85f158ae3b..23d6d8bf96 100644
--- a/apps/photos/src/components/PhotoFrame.tsx
+++ b/apps/photos/src/components/PhotoFrame.tsx
@@ -81,6 +81,9 @@ const PhotoFrame = ({
const [open, setOpen] = useState(false);
const [currentIndex, setCurrentIndex] = useState<number>(0);
const [fetching, setFetching] = useState<{ [k: number]: boolean }>({});
+ const [thumbFetching, setThumbFetching] = useState<{
+ [k: number]: boolean;
+ }>({});
const galleryContext = useContext(GalleryContext);
const publicCollectionGalleryContext = useContext(
PublicCollectionGalleryContext
@@ -104,6 +107,7 @@ const PhotoFrame = ({
useEffect(() => {
setFetching({});
+ setThumbFetching({});
}, [displayFiles]);
useEffect(() => {
@@ -370,9 +374,17 @@ const PhotoFrame = ({
item.isSourceLoaded
} fetching:${fetching[item.id]}`
);
+
if (!item.msrc) {
- addLogLine(`[${item.id}] doesn't have thumbnail`);
try {
+ if (thumbFetching[item.id]) {
+ addLogLine(
+ `[${item.id}] thumb download already in progress`
+ );
+ return;
+ }
+ addLogLine(`[${item.id}] doesn't have thumbnail`);
+ thumbFetching[item.id] = true;
const url = await DownloadManager.getThumbnailForPreview(item);
updateURL(index)(item.id, url);
try {
@@ -394,6 +406,7 @@ const PhotoFrame = ({
}
} catch (e) {
logError(e, 'getSlideData failed get msrc url failed');
+ thumbFetching[item.id] = false;
}
}
diff --git a/apps/photos/src/components/PhotoViewer/index.tsx b/apps/photos/src/components/PhotoViewer/index.tsx
index 776f1cda98..e876fbb27c 100644
--- a/apps/photos/src/components/PhotoViewer/index.tsx
+++ b/apps/photos/src/components/PhotoViewer/index.tsx
@@ -543,7 +543,8 @@ function PhotoViewer(props: Iprops) {
if (file.isSourceLoaded) {
exifExtractionInProgress.current = file.src;
const fileObject = await getFileFromURL(
- file.originalImageURL
+ file.src as string,
+ file.metadata.title
);
const fileTypeInfo = await getFileType(fileObject);
const exifData = await getParsedExifData(
diff --git a/apps/photos/src/types/file/index.ts b/apps/photos/src/types/file/index.ts
index 7c55a8af2a..a4a15e387a 100644
--- a/apps/photos/src/types/file/index.ts
+++ b/apps/photos/src/types/file/index.ts
@@ -57,9 +57,6 @@ export interface EnteFile
title?: string;
deleteBy?: number;
isSourceLoaded?: boolean;
- originalVideoURL?: string;
- originalImageURL?: string;
- dataIndex?: number;
conversionFailed?: boolean;
isConverted?: boolean;
}
diff --git a/apps/photos/src/utils/file/index.ts b/apps/photos/src/utils/file/index.ts
index 51cf035cfc..e8e5919a15 100644
--- a/apps/photos/src/utils/file/index.ts
+++ b/apps/photos/src/utils/file/index.ts
@@ -577,9 +577,9 @@ export function updateExistingFilePubMetadata(
existingFile.metadata = mergeMetadata([existingFile])[0].metadata;
}
-export async function getFileFromURL(fileURL: string) {
+export async function getFileFromURL(fileURL: string, name: string) {
const fileBlob = await (await fetch(fileURL)).blob();
- const fileFile = new File([fileBlob], 'temp');
+ const fileFile = new File([fileBlob], name);
return fileFile;
}
diff --git a/apps/photos/src/utils/photoFrame/index.ts b/apps/photos/src/utils/photoFrame/index.ts
index a6435fe5a6..3207377a95 100644
--- a/apps/photos/src/utils/photoFrame/index.ts
+++ b/apps/photos/src/utils/photoFrame/index.ts
@@ -69,6 +69,11 @@ export function updateFileMsrcProps(file: EnteFile, url: string) {
export async function updateFileSrcProps(file: EnteFile, srcURLs: SourceURLs) {
const { url, isRenderable } = srcURLs;
+ file.w = window.innerWidth;
+ file.h = window.innerHeight;
+ file.isSourceLoaded = true;
+ file.isConverted = !srcURLs.isOriginal;
+ file.conversionFailed = !srcURLs.isRenderable;
if (!isRenderable) {
return;
}