Skip to content

armgit / ente

Public Imported from GitHub
0

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

cleanup dead code

Abhinav68ffb8340000
diff --git a/apps/photos/public/locales/en/translation.json b/apps/photos/public/locales/en/translation.json
index da7c6a6d4a..9c97bc1064 100644
--- a/apps/photos/public/locales/en/translation.json
+++ b/apps/photos/public/locales/en/translation.json
@@ -425,7 +425,6 @@
"FILES": "Files",
"EACH": "Each",
"DEDUPLICATE_BASED_ON_SIZE": "The following files were clubbed based on their sizes, please review and delete items you believe are duplicates",
- "DEDUPLICATE_BASED_ON_SIZE_AND_CAPTURE_TIME": "The following files were clubbed based on their sizes and capture time, please review and delete items you believe are duplicates",
"STOP_ALL_UPLOADS_MESSAGE": "Are you sure that you want to stop all the uploads in progress?",
"STOP_UPLOADS_HEADER": "Stop uploads?",
"YES_STOP_UPLOADS": "Yes, stop uploads",
diff --git a/apps/photos/src/components/PhotoList/index.tsx b/apps/photos/src/components/PhotoList/index.tsx
index e23e969a7c..d19f515bcb 100644
--- a/apps/photos/src/components/PhotoList/index.tsx
+++ b/apps/photos/src/components/PhotoList/index.tsx
@@ -19,14 +19,12 @@ import {
import { PublicCollectionGalleryContext } from 'utils/publicCollectionGallery';
import { ENTE_WEBSITE_LINK } from '@ente/shared/constants/urls';
import { convertBytesToHumanReadable } from '@ente/shared/utils/size';
-import { DeduplicateContext } from 'pages/deduplicate';
import { FlexWrapper } from '@ente/shared/components/Container';
import { Typography } from '@mui/material';
import { GalleryContext } from 'pages/gallery';
import { formatDate } from '@ente/shared/time/format';
import { Trans } from 'react-i18next';
import { t } from 'i18next';
-import { areFilesWithFileHashSame, hasFileHash } from 'utils/upload';
import memoize from 'memoize-one';
const A_DAY = 24 * 60 * 60 * 1000;
@@ -261,7 +259,6 @@ export function PhotoList({
const publicCollectionGalleryContext = useContext(
PublicCollectionGalleryContext
);
- const deduplicateContext = useContext(DeduplicateContext);
const [timeStampList, setTimeStampList] = useState<TimeStampListItem[]>([]);
const refreshInProgress = useRef(false);
@@ -306,9 +303,6 @@ export function PhotoList({
}
if (galleryContext.isClipSearchResult) {
noGrouping(timeStampList);
- } else if (deduplicateContext.isOnDeduplicatePage) {
- skipMerge = true;
- groupByFileSize(timeStampList);
} else {
groupByTime(timeStampList);
}
@@ -345,9 +339,6 @@ export function PhotoList({
width,
height,
displayFiles,
- deduplicateContext.isOnDeduplicatePage,
- deduplicateContext.fileSizeMap,
- deduplicateContext.clubSameTimeFilesOnly,
galleryContext.photoListHeader,
publicCollectionGalleryContext.photoListHeader,
galleryContext.isClipSearchResult,
@@ -420,67 +411,6 @@ export function PhotoList({
refreshList();
}, [timeStampList]);
- const groupByFileSize = (timeStampList: TimeStampListItem[]) => {
- let index = 0;
- while (index < displayFiles.length) {
- const firstFile = displayFiles[index];
- const firstFileSize = deduplicateContext.fileSizeMap.get(
- firstFile.id
- );
- const firstFileCreationTime = firstFile.metadata.creationTime;
- let lastFileIndex = index;
-
- while (lastFileIndex < displayFiles.length) {
- const lastFile = displayFiles[lastFileIndex];
-
- const lastFileSize = deduplicateContext.fileSizeMap.get(
- lastFile.id
- );
- if (lastFileSize !== firstFileSize) {
- break;
- }
-
- const lastFileCreationTime = lastFile.metadata.creationTime;
- if (
- deduplicateContext.clubSameTimeFilesOnly &&
- lastFileCreationTime !== firstFileCreationTime
- ) {
- break;
- }
-
- const eitherFileHasFileHash =
- hasFileHash(lastFile.metadata) ||
- hasFileHash(firstFile.metadata);
- if (
- eitherFileHasFileHash &&
- !areFilesWithFileHashSame(
- lastFile.metadata,
- firstFile.metadata
- )
- ) {
- break;
- }
- lastFileIndex++;
- }
- lastFileIndex--;
- timeStampList.push({
- itemType: ITEM_TYPE.SIZE_AND_COUNT,
- fileSize: firstFileSize,
- fileCount: lastFileIndex - index + 1,
- });
-
- while (index <= lastFileIndex) {
- const tileSize = Math.min(columns, lastFileIndex - index + 1);
- timeStampList.push({
- itemType: ITEM_TYPE.FILE,
- items: displayFiles.slice(index, index + tileSize),
- itemStartIndex: index,
- });
- index += tileSize;
- }
- }
- };
-
const groupByTime = (timeStampList: TimeStampListItem[]) => {
let listItemIndex = 0;
let currentDate;
diff --git a/apps/photos/src/pages/deduplicate/index.tsx b/apps/photos/src/pages/deduplicate/index.tsx
index 16bbc02597..898972f2c1 100644
--- a/apps/photos/src/pages/deduplicate/index.tsx
+++ b/apps/photos/src/pages/deduplicate/index.tsx
@@ -4,12 +4,8 @@ import PhotoFrame from 'components/PhotoFrame';
import { ALL_SECTION } from 'constants/collection';
import { AppContext } from 'pages/_app';
import { createContext, useContext, useEffect, useState } from 'react';
-import {
- getDuplicates,
- deClubDuplicatesWithDifferentTime,
- Duplicate,
-} from 'services/deduplicationService';
-import { syncFiles, trashFiles } from 'services/fileService';
+import { getDuplicates, Duplicate } from 'services/deduplicationService';
+import { getLocalFiles, trashFiles } from 'services/fileService';
import { SelectedState } from 'types/gallery';
import { ApiError } from '@ente/shared/error';
@@ -24,7 +20,7 @@ import { PHOTOS_PAGES as PAGES } from '@ente/shared/constants/pages';
import router from 'next/router';
import { getKey, SESSION_KEYS } from '@ente/shared/storage/sessionStorage';
import { styled } from '@mui/material';
-import { getLatestCollections } from 'services/collectionService';
+import { getLocalCollections } from 'services/collectionService';
import EnteSpinner from '@ente/shared/components/EnteSpinner';
import { VerticallyCentered } from '@ente/shared/components/Container';
import Typography from '@mui/material/Typography';
@@ -44,8 +40,6 @@ export default function Deduplicate() {
const { setDialogMessage, startLoading, finishLoading, showNavBar } =
useContext(AppContext);
const [duplicates, setDuplicates] = useState<Duplicate[]>(null);
- const [clubSameTimeFilesOnly, setClubSameTimeFilesOnly] = useState(false);
- const [fileSizeMap, setFileSizeMap] = useState(new Map<number, number>());
const [collectionNameMap, setCollectionNameMap] = useState(
new Map<number, string>()
);
@@ -69,7 +63,7 @@ export default function Deduplicate() {
useEffect(() => {
syncWithRemote();
- }, [clubSameTimeFilesOnly]);
+ }, []);
const duplicateFiles = useMemoSingleThreaded(() => {
return (duplicates ?? []).reduce((acc, dupe) => {
@@ -83,17 +77,14 @@ export default function Deduplicate() {
const syncWithRemote = async () => {
startLoading();
- const collections = await getLatestCollections();
+ const collections = await getLocalCollections();
const collectionNameMap = new Map<number, string>();
for (const collection of collections) {
collectionNameMap.set(collection.id, collection.name);
}
setCollectionNameMap(collectionNameMap);
- const files = await syncFiles('normal', collections, () => null);
- let duplicateFiles = await getDuplicates(files, collectionNameMap);
- if (clubSameTimeFilesOnly) {
- duplicateFiles = deClubDuplicatesWithDifferentTime(duplicateFiles);
- }
+ const files = await getLocalFiles();
+ const duplicateFiles = await getDuplicates(files, collectionNameMap);
const currFileSizeMap = new Map<number, number>();
let toSelectFileIDs: number[] = [];
let count = 0;
@@ -110,7 +101,6 @@ export default function Deduplicate() {
}
}
setDuplicates(duplicateFiles);
- setFileSizeMap(currFileSizeMap);
const selectedFiles = {
count: count,
ownCount: count,
@@ -170,19 +160,9 @@ export default function Deduplicate() {
value={{
...DefaultDeduplicateContext,
collectionNameMap,
- clubSameTimeFilesOnly,
- setClubSameTimeFilesOnly,
- fileSizeMap,
- isOnDeduplicatePage: true,
}}>
{duplicates.length > 0 && (
- <Info>
- {t('DEDUPLICATE_BASED_ON', {
- context: clubSameTimeFilesOnly
- ? 'SIZE_AND_CAPTURE_TIME'
- : 'SIZE',
- })}
- </Info>
+ <Info>{t('DEDUPLICATE_BASED_ON_SIZE')}</Info>
)}
{duplicates.length === 0 ? (
<VerticallyCentered>
diff --git a/apps/photos/src/types/deduplicate/index.ts b/apps/photos/src/types/deduplicate/index.ts
index b026bf8d32..8376b36386 100644
--- a/apps/photos/src/types/deduplicate/index.ts
+++ b/apps/photos/src/types/deduplicate/index.ts
@@ -1,8 +1,4 @@
export type DeduplicateContextType = {
- clubSameTimeFilesOnly: boolean;
- setClubSameTimeFilesOnly: (clubSameTimeFilesOnly: boolean) => void;
- fileSizeMap: Map<number, number>;
- isOnDeduplicatePage: boolean;
collectionNameMap: Map<number, string>;
};