π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Move
Manav Rathic012055835ac
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsxindex 4c40d02b27..10481b3a84 100644--- a/web/apps/photos/src/pages/gallery.tsx+++ b/web/apps/photos/src/pages/gallery.tsx@@ -19,6 +19,7 @@ import downloadManager from "@/new/photos/services/download";import {getLocalFiles,getLocalTrashedFiles,+ sortFiles,} from "@/new/photos/services/files";import { peopleSnapshot, peopleSubscribe } from "@/new/photos/services/ml";import type { Person } from "@/new/photos/services/ml/people";@@ -146,7 +147,6 @@ import {getSelectedFiles,getUniqueFiles,handleFileOps,- sortFiles,} from "utils/file";import { isArchivedFile } from "utils/magicMetadata";import { getSessionExpiredMessage } from "utils/ui";diff --git a/web/apps/photos/src/pages/shared-albums.tsx b/web/apps/photos/src/pages/shared-albums.tsxindex 78b5c08ed4..15fb04898a 100644--- a/web/apps/photos/src/pages/shared-albums.tsx+++ b/web/apps/photos/src/pages/shared-albums.tsx@@ -9,6 +9,7 @@ import {} from "@/new/photos/components/Gallery/ListHeader";import { SpaceBetweenFlex } from "@/new/photos/components/mui";import downloadManager from "@/new/photos/services/download";+import { sortFiles } from "@/new/photos/services/files";import { EnteFile } from "@/new/photos/types/file";import { mergeMetadata } from "@/new/photos/utils/file";import {@@ -76,7 +77,7 @@ import {downloadCollectionFiles,isHiddenCollection,} from "utils/collection";-import { downloadSelectedFiles, getSelectedFiles, sortFiles } from "utils/file";+import { downloadSelectedFiles, getSelectedFiles } from "utils/file";import { formatNumber } from "utils/number/format";import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";diff --git a/web/apps/photos/src/services/collectionService.ts b/web/apps/photos/src/services/collectionService.tsindex 5cc7f68e79..74198d6191 100644--- a/web/apps/photos/src/services/collectionService.ts+++ b/web/apps/photos/src/services/collectionService.ts@@ -19,13 +19,16 @@ import {UpdatePublicURL,} from "@/media/collection";import { ItemVisibility } from "@/media/file-metadata";-import { getLocalFiles } from "@/new/photos/services/files";+import { getLocalFiles, sortFiles } from "@/new/photos/services/files";import type {CollectionSummaries,CollectionSummary,CollectionSummaryType,} from "@/new/photos/types/collection";-import { CollectionsSortBy, CollectionSummaryOrder } from "@/new/photos/types/collection";+import {+ CollectionSummaryOrder,+ CollectionsSortBy,+} from "@/new/photos/types/collection";import { EnteFile } from "@/new/photos/types/file";import {EncryptedMagicMetadata,@@ -60,11 +63,7 @@ import {isSharedOnlyViaLink,isValidMoveTarget,} from "utils/collection";-import {- getUniqueFiles,- groupFilesBasedOnCollectionID,- sortFiles,-} from "utils/file";+import { getUniqueFiles, groupFilesBasedOnCollectionID } from "utils/file";import {isArchivedCollection,isArchivedFile,diff --git a/web/apps/photos/src/services/fileService.ts b/web/apps/photos/src/services/fileService.tsindex e26b24a466..09c9db5307 100644--- a/web/apps/photos/src/services/fileService.ts+++ b/web/apps/photos/src/services/fileService.ts@@ -6,6 +6,7 @@ import {clearCachedThumbnailsIfChanged,getLocalFiles,setLocalFiles,+ sortFiles,} from "@/new/photos/services/files";import {EncryptedEnteFile,@@ -21,7 +22,7 @@ import HTTPService from "@ente/shared/network/HTTPService";import { getToken } from "@ente/shared/storage/localStorage/helpers";import exportService from "services/export";import { SetFiles } from "types/gallery";-import { decryptFile, getLatestVersionFiles, sortFiles } from "utils/file";+import { decryptFile, getLatestVersionFiles } from "utils/file";import {getCollectionLastSyncTime,REQUEST_BATCH_SIZE,diff --git a/web/apps/photos/src/services/publicCollectionService.ts b/web/apps/photos/src/services/publicCollectionService.tsindex 9deed90281..ece90c8162 100644--- a/web/apps/photos/src/services/publicCollectionService.ts+++ b/web/apps/photos/src/services/publicCollectionService.ts@@ -5,13 +5,14 @@ import type {Collection,CollectionPublicMagicMetadata,} from "@/media/collection";+import { sortFiles } from "@/new/photos/services/files";import { EncryptedEnteFile, EnteFile } from "@/new/photos/types/file";import { mergeMetadata } from "@/new/photos/utils/file";import { CustomError, parseSharingErrorCodes } from "@ente/shared/error";import HTTPService from "@ente/shared/network/HTTPService";import localForage from "@ente/shared/storage/localForage";import { LocalSavedPublicCollectionFiles } from "types/publicCollection";-import { decryptFile, sortFiles } from "utils/file";+import { decryptFile } from "utils/file";const PUBLIC_COLLECTION_FILES_TABLE = "public-collection-files";const PUBLIC_COLLECTIONS_TABLE = "public-collections";diff --git a/web/apps/photos/src/services/upload/uploadManager.ts b/web/apps/photos/src/services/upload/uploadManager.tsindex fb6ceb26fa..817e4c535c 100644--- a/web/apps/photos/src/services/upload/uploadManager.ts+++ b/web/apps/photos/src/services/upload/uploadManager.ts@@ -7,7 +7,7 @@ import { ComlinkWorker } from "@/base/worker/comlink-worker";import type { Collection } from "@/media/collection";import { FileType } from "@/media/file-type";import { potentialFileTypeFromExtension } from "@/media/live-photo";-import { getLocalFiles } from "@/new/photos/services/files";+import { getLocalFiles, sortFiles } from "@/new/photos/services/files";import { indexNewUpload } from "@/new/photos/services/ml";import type { UploadItem } from "@/new/photos/services/upload/types";import {@@ -28,7 +28,7 @@ import {import { getDisableCFUploadProxyFlag } from "services/userService";import watcher from "services/watch";import { SetFiles } from "types/gallery";-import { decryptFile, getUserOwnedFiles, sortFiles } from "utils/file";+import { decryptFile, getUserOwnedFiles } from "utils/file";import {getMetadataJSONMapKeyForJSON,tryParseTakeoutMetadataJSON,diff --git a/web/apps/photos/src/utils/file/index.ts b/web/apps/photos/src/utils/file/index.tsindex 6ca064a92b..dd3c4e3163 100644--- a/web/apps/photos/src/utils/file/index.ts+++ b/web/apps/photos/src/utils/file/index.ts@@ -113,20 +113,6 @@ export function getSelectedFiles(return files.filter((file) => selectedFilesIDs.has(file.id));}-export function sortFiles(files: EnteFile[], sortAsc = false) {- // sort based on the time of creation time of the file,- // for files with same creation time, sort based on the time of last modification- const factor = sortAsc ? -1 : 1;- return files.sort((a, b) => {- if (a.metadata.creationTime === b.metadata.creationTime) {- return (- factor *- (b.metadata.modificationTime - a.metadata.modificationTime)- );- }- return factor * (b.metadata.creationTime - a.metadata.creationTime);- });-}export async function decryptFile(file: EncryptedEnteFile,diff --git a/web/packages/new/photos/services/files.ts b/web/packages/new/photos/services/files.tsindex 11fe776807..ae9c71c81d 100644--- a/web/packages/new/photos/services/files.ts+++ b/web/packages/new/photos/services/files.ts@@ -38,6 +38,22 @@ export const setLocalFiles = async (await localForage.setItem(tableName, files);};+export function sortFiles(files: EnteFile[], sortAsc = false) {+ // sort based on the time of creation time of the file,+ // for files with same creation time, sort based on the time of last modification+ const factor = sortAsc ? -1 : 1;+ return files.sort((a, b) => {+ if (a.metadata.creationTime === b.metadata.creationTime) {+ return (+ factor *+ (b.metadata.modificationTime - a.metadata.modificationTime)+ );+ }+ return factor * (b.metadata.creationTime - a.metadata.creationTime);+ });+}++export const TRASH = "file-trash";export async function getLocalTrash() {