Skip to content

armgit / ente

Public Imported from GitHub
0

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

Prevent rerenders

Manav Rathif3a079e73425
diff --git a/web/apps/photos/src/components/PhotoFrame.tsx b/web/apps/photos/src/components/PhotoFrame.tsx
index 2df66688ee..a60768019a 100644
--- a/web/apps/photos/src/components/PhotoFrame.tsx
+++ b/web/apps/photos/src/components/PhotoFrame.tsx
@@ -285,12 +285,11 @@ const PhotoFrame = ({
: undefined;
}, [favoriteFileIDs, onMarkUnsyncedFavoriteUpdate]);
- // TODO(PS): Missing dep!
const handleDownload = useCallback((file: EnteFile) => {
const setSingleFileDownloadProgress =
setFilesDownloadProgressAttributesCreator!(file.metadata.title);
void downloadSingleFile(file, setSingleFileDownloadProgress);
- }, []);
+ }, [setFilesDownloadProgressAttributesCreator]);
const handleDelete = useMemo(() => {
return onMarkTempDeleted
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 79de4d7458..3fed596013 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -630,8 +630,8 @@ const Page: React.FC = () => {
};
const setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator =
- (folderName, collectionID, isHidden) => {
- const id = filesDownloadProgressAttributesList?.length ?? 0;
+ useCallback((folderName, collectionID, isHidden) => {
+ const id = Math.random();
const updater: SetFilesDownloadProgressAttributes = (value) => {
setFilesDownloadProgressAttributesList((prev) => {
const attributes = prev?.find((attr) => attr.id === id);
@@ -660,7 +660,7 @@ const Page: React.FC = () => {
downloadDirPath: null,
});
return updater;
- };
+ }, []);
const collectionOpsHelper =
(ops: COLLECTION_OPS_TYPE) => async (collection: Collection) => {
diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsx
index 97a8374827..25812ee9a3 100644
--- a/web/apps/photos/src/pages/shared-albums.tsx
+++ b/web/apps/photos/src/pages/shared-albums.tsx
@@ -124,8 +124,8 @@ export default function PublicCollectionGallery() {
] = useState<FilesDownloadProgressAttributes[]>([]);
const setFilesDownloadProgressAttributesCreator: SetFilesDownloadProgressAttributesCreator =
- (folderName, collectionID, isHidden) => {
- const id = filesDownloadProgressAttributesList?.length ?? 0;
+ useCallback((folderName, collectionID, isHidden) => {
+ const id = Math.random();
const updater: SetFilesDownloadProgressAttributes = (value) => {
setFilesDownloadProgressAttributesList((prev) => {
const attributes = prev?.find((attr) => attr.id === id);
@@ -154,7 +154,7 @@ export default function PublicCollectionGallery() {
downloadDirPath: null,
});
return updater;
- };
+ }, []);
const onAddPhotos = useMemo(() => {
return publicCollection?.publicURLs?.[0]?.enableCollect