π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
fix load local file while scroll issue
Abhinav8a935d8a6e61
diff --git a/apps/photos/src/components/Collections/CollectionCard.tsx b/apps/photos/src/components/Collections/CollectionCard.tsxindex 3bee032b65..87bb8b64fe 100644--- a/apps/photos/src/components/Collections/CollectionCard.tsx+++ b/apps/photos/src/components/Collections/CollectionCard.tsx@@ -26,8 +26,13 @@ export default function CollectionCard(props: {if (!file) {return;}- const url = await downloadManager.getThumbnailForPreview(file);- setCoverImageURL(url);+ const url = await downloadManager.getThumbnailForPreview(+ file,+ isScrolling+ );+ if (url) {+ setCoverImageURL(url);+ }};main();}, [file, isScrolling]);diff --git a/apps/photos/src/components/pages/gallery/PreviewCard.tsx b/apps/photos/src/components/pages/gallery/PreviewCard.tsxindex aba12f70d1..1b79616873 100644--- a/apps/photos/src/components/pages/gallery/PreviewCard.tsx+++ b/apps/photos/src/components/pages/gallery/PreviewCard.tsx@@ -248,9 +248,12 @@ export default function PreviewCard(props: IProps) {return;}const url: string =- await DownloadManager.getThumbnailForPreview(file);+ await DownloadManager.getThumbnailForPreview(+ file,+ props.showPlaceholder+ );- if (!isMounted.current) {+ if (!isMounted.current || !url) {return;}setImgSrc(url);diff --git a/apps/photos/src/services/download/index.ts b/apps/photos/src/services/download/index.tsindex 9ffd454c10..637fb7ad75 100644--- a/apps/photos/src/services/download/index.ts+++ b/apps/photos/src/services/download/index.ts@@ -128,7 +128,7 @@ class DownloadManager {return decrypted;};- async getThumbnail(file: EnteFile) {+ async getThumbnail(file: EnteFile, localOnly = false) {try {if (!this.ready) {throw Error(CustomError.DOWNLOAD_MANAGER_NOT_READY);@@ -137,6 +137,9 @@ class DownloadManager {if (cachedThumb) {return cachedThumb;}+ if (localOnly) {+ return null;+ }const thumb = await this.downloadThumb(file);this.thumbnailCache@@ -152,19 +155,24 @@ class DownloadManager {}}- async getThumbnailForPreview(file: EnteFile) {+ async getThumbnailForPreview(file: EnteFile, localOnly = false) {try {if (!this.ready) {throw Error(CustomError.DOWNLOAD_MANAGER_NOT_READY);}if (!this.thumbnailObjectURLPromises.has(file.id)) {- const thumbPromise = this.getThumbnail(file);- const thumbURLPromise = thumbPromise.then((thumb) =>- URL.createObjectURL(new Blob([thumb]))+ const thumbPromise = this.getThumbnail(file, localOnly);+ const thumbURLPromise = thumbPromise.then(+ (thumb) => thumb && URL.createObjectURL(new Blob([thumb])));this.thumbnailObjectURLPromises.set(file.id, thumbURLPromise);}- return await this.thumbnailObjectURLPromises.get(file.id);+ let thumb = await this.thumbnailObjectURLPromises.get(file.id);+ if (!thumb) {+ this.thumbnailObjectURLPromises.delete(file.id);+ thumb = await this.getThumbnailForPreview(file, localOnly);+ }+ return thumb;} catch (e) {this.thumbnailObjectURLPromises.delete(file.id);logError(e, 'get DownloadManager preview Failed');