Skip to content

Commit

Permalink
[desktop] Fetch face indexes - Part 1/x (#2297)
Browse files Browse the repository at this point in the history
No functional changes yet, just prep.
  • Loading branch information
mnvr authored Jun 26, 2024
2 parents 3193139 + bfa4806 commit 80d5d7e
Show file tree
Hide file tree
Showing 70 changed files with 377 additions and 211 deletions.
12 changes: 6 additions & 6 deletions web/apps/cast/src/services/render.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ import { FILE_TYPE } from "@/media/file-type";
import { isHEICExtension, isNonWebImageFileExtension } from "@/media/formats";
import { heicToJPEG } from "@/media/heic-convert";
import { decodeLivePhoto } from "@/media/live-photo";
import type {
EncryptedEnteFile,
EnteFile,
FileMagicMetadata,
FilePublicMagicMetadata,
} from "@/new/photos/types/file";
import { nameAndExtension } from "@/next/file";
import log from "@/next/log";
import { apiOrigin, customAPIOrigin } from "@/next/origins";
Expand All @@ -21,12 +27,6 @@ import HTTPService from "@ente/shared/network/HTTPService";
import type { AxiosResponse } from "axios";
import type { CastData } from "services/cast-data";
import { detectMediaMIMEType } from "services/detect-type";
import type {
EncryptedEnteFile,
EnteFile,
FileMagicMetadata,
FilePublicMagicMetadata,
} from "types/file";
import { isChromecast } from "./chromecast";

/**
Expand Down
2 changes: 1 addition & 1 deletion web/apps/cast/src/types/file/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type {
EncryptedMagicMetadata,
MagicMetadataCore,
VISIBILITY_STATE,
} from "types/magicMetadata";
} from "@/new/photos/types/magicMetadata";

export interface MetadataFileAttributes {
encryptedData: string;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { EnteFile } from "@/new/photos/types/file";
import {
LoadingThumbnail,
StaticThumbnail,
} from "components/PlaceholderThumbnails";
import { useEffect, useState } from "react";
import downloadManager from "services/download";
import { EnteFile } from "types/file";

export default function CollectionCard(props: {
children?: any;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { VISIBILITY_STATE } from "@/new/photos/types/magicMetadata";
import log from "@/next/log";
import { HorizontalFlex } from "@ente/shared/components/Container";
import OverflowMenu from "@ente/shared/components/OverflowMenu/menu";
Expand All @@ -18,7 +19,6 @@ import * as CollectionAPI from "services/collectionService";
import * as TrashService from "services/trashService";
import { Collection } from "types/collection";
import { SetFilesDownloadProgressAttributesCreator } from "types/gallery";
import { VISIBILITY_STATE } from "types/magicMetadata";
import {
changeCollectionOrder,
changeCollectionSortOrder,
Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/components/ExportFinished.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import { SpaceBetweenFlex } from "@ente/shared/components/Container";
import { formatDateTime } from "@ente/shared/time/format";
import {
Expand All @@ -9,7 +10,6 @@ import {
} from "@mui/material";
import { t } from "i18next";
import { useState } from "react";
import { EnteFile } from "types/file";
import { formatNumber } from "utils/number/format";
import ExportPendingList from "./ExportPendingList";
import LinkButton from "./pages/gallery/LinkButton";
Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/components/ExportModal.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import log from "@/next/log";
import ChangeDirectoryOption from "@ente/shared/components/ChangeDirectoryOption";
import {
Expand All @@ -24,7 +25,6 @@ import exportService, {
selectAndPrepareExportDirectory,
} from "services/export";
import { ExportProgress, ExportSettings } from "types/export";
import { EnteFile } from "types/file";
import { getExportDirectoryDoesNotExistMessage } from "utils/ui";
import { DirectoryPath } from "./Directory";
import ExportFinished from "./ExportFinished";
Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/components/ExportPendingList.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EnteFile } from "@/new/photos/types/file";
import { FlexWrapper } from "@ente/shared/components/Container";
import DialogBoxV2 from "@ente/shared/components/DialogBoxV2";
import { Box, styled } from "@mui/material";
import ItemList from "components/ItemList";
import { t } from "i18next";
import { EnteFile } from "types/file";
import CollectionCard from "./Collections/CollectionCard";
import { ResultPreviewTile } from "./Collections/styledComponents";

Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/components/FixCreationTime.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import DialogBox from "@ente/shared/components/DialogBox/";
import {
Button,
Expand All @@ -14,7 +15,6 @@ import { t } from "i18next";
import { GalleryContext } from "pages/gallery";
import React, { useContext, useEffect, useState } from "react";
import { updateCreationTimeWithExif } from "services/fix-exif";
import { EnteFile } from "types/file";
import EnteDateTimePicker from "./EnteDateTimePicker";

export interface FixCreationTimeAttributes {
Expand Down
8 changes: 3 additions & 5 deletions web/apps/photos/src/components/PhotoFrame.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { FILE_TYPE } from "@/media/file-type";
import type { LivePhotoSourceURL, SourceURLs } from "@/new/photos/types/file";
import { EnteFile } from "@/new/photos/types/file";
import log from "@/next/log";
import { PHOTOS_PAGES } from "@ente/shared/constants/pages";
import { CustomError } from "@ente/shared/error";
Expand All @@ -12,11 +14,7 @@ import PhotoSwipe from "photoswipe";
import { useContext, useEffect, useState } from "react";
import AutoSizer from "react-virtualized-auto-sizer";
import { Duplicate } from "services/deduplicationService";
import DownloadManager, {
LivePhotoSourceURL,
SourceURLs,
} from "services/download";
import { EnteFile } from "types/file";
import DownloadManager from "services/download";
import {
SelectedState,
SetFilesDownloadProgressAttributesCreator,
Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/components/PhotoList/dedupe.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import { FlexWrapper } from "@ente/shared/components/Container";
import { Box, styled } from "@mui/material";
import {
Expand All @@ -18,7 +19,6 @@ import {
areEqual,
} from "react-window";
import { Duplicate } from "services/deduplicationService";
import { EnteFile } from "types/file";
import { formattedByteSize } from "utils/units";

export enum ITEM_TYPE {
Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/components/PhotoList/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import { FlexWrapper } from "@ente/shared/components/Container";
import { formatDate } from "@ente/shared/time/format";
import { Box, Checkbox, Link, Typography, styled } from "@mui/material";
Expand All @@ -21,7 +22,6 @@ import {
ListChildComponentProps,
areEqual,
} from "react-window";
import { EnteFile } from "types/file";
import { handleSelectCreator } from "utils/photoFrame";
import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";
import { formattedByteSize } from "utils/units";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import log from "@/next/log";
import { FlexWrapper } from "@ente/shared/components/Container";
import Close from "@mui/icons-material/Close";
Expand All @@ -6,7 +7,6 @@ import { Box, IconButton, TextField } from "@mui/material";
import { Formik } from "formik";
import { t } from "i18next";
import { useState } from "react";
import { EnteFile } from "types/file";
import { changeCaption, updateExistingFilePubMetadata } from "utils/file";
import * as Yup from "yup";
import { SmallLoadingSpinner } from "../styledComponents/SmallLoadingSpinner";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { EnteFile } from "@/new/photos/types/file";
import log from "@/next/log";
import { FlexWrapper } from "@ente/shared/components/Container";
import { formatDate, formatTime } from "@ente/shared/time/format";
import CalendarTodayIcon from "@mui/icons-material/CalendarToday";
import EnteDateTimePicker from "components/EnteDateTimePicker";
import { useState } from "react";
import { EnteFile } from "types/file";
import {
changeFileCreationTime,
updateExistingFilePubMetadata,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import { FILE_TYPE } from "@/media/file-type";
import { EnteFile } from "@/new/photos/types/file";
import { nameAndExtension } from "@/next/file";
import log from "@/next/log";
import { FlexWrapper } from "@ente/shared/components/Container";
import PhotoOutlined from "@mui/icons-material/PhotoOutlined";
import VideocamOutlined from "@mui/icons-material/VideocamOutlined";
import Box from "@mui/material/Box";
import { useEffect, useState } from "react";
import { EnteFile } from "types/file";
import { changeFileName, updateExistingFilePubMetadata } from "utils/file";
import { formattedByteSize } from "utils/units";
import { FileNameEditDialog } from "./FileNameEditDialog";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import CopyButton from "@ente/shared/components/CodeBlock/CopyButton";
import { FlexWrapper } from "@ente/shared/components/Container";
import EnteSpinner from "@ente/shared/components/EnteSpinner";
Expand All @@ -18,7 +19,6 @@ import { AppContext } from "pages/_app";
import { GalleryContext } from "pages/gallery";
import { useContext, useEffect, useMemo, useState } from "react";
import { getEXIFLocation } from "services/exif";
import { EnteFile } from "types/file";
import { PublicCollectionGalleryContext } from "utils/publicCollectionGallery";
import {
getMapDisableConfirmationDialog,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import { nameAndExtension } from "@/next/file";
import log from "@/next/log";
import { ensure } from "@/utils/ensure";
Expand Down Expand Up @@ -36,7 +37,6 @@ import { createContext, useContext, useEffect, useRef, useState } from "react";
import { getLocalCollections } from "services/collectionService";
import downloadManager from "services/download";
import uploadManager from "services/upload/uploadManager";
import { EnteFile } from "types/file";
import { getEditorCloseConfirmationMessage } from "utils/ui";
import ColoursMenu from "./ColoursMenu";
import CropMenu, { cropRegionOfCanvas, getCropRegionArgs } from "./CropMenu";
Expand Down
5 changes: 3 additions & 2 deletions web/apps/photos/src/components/PhotoViewer/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import log from "@/next/log";
import Photoswipe from "photoswipe";
import PhotoswipeUIDefault from "photoswipe/dist/photoswipe-ui-default";
Expand All @@ -6,7 +7,6 @@ import {
addToFavorites,
removeFromFavorites,
} from "services/collectionService";
import { EnteFile } from "types/file";
import {
copyFileToClipboard,
downloadSingleFile,
Expand All @@ -16,6 +16,7 @@ import {

import { FILE_TYPE } from "@/media/file-type";
import { isNonWebImageFileExtension } from "@/media/formats";
import type { LoadedLivePhotoSourceURL } from "@/new/photos/types/file";
import { lowercaseExtension } from "@/next/file";
import { FlexWrapper } from "@ente/shared/components/Container";
import EnteSpinner from "@ente/shared/components/EnteSpinner";
Expand Down Expand Up @@ -44,7 +45,7 @@ import isElectron from "is-electron";
import { AppContext } from "pages/_app";
import { GalleryContext } from "pages/gallery";
import { detectFileTypeInfo } from "services/detect-type";
import downloadManager, { LoadedLivePhotoSourceURL } from "services/download";
import downloadManager from "services/download";
import { getParsedExifData } from "services/exif";
import { trashFiles } from "services/fileService";
import { SetFilesDownloadProgressAttributesCreator } from "types/gallery";
Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/components/Search/SearchBar/index.tsx
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { Collection } from "types/collection";
import { SearchBarMobile } from "./searchBarMobile";

import { EnteFile } from "types/file";
import { EnteFile } from "@/new/photos/types/file";
import { UpdateSearch } from "types/search";
import SearchInput from "./searchInput";
import { SearchBarWrapper } from "./styledComponents";
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FILE_TYPE } from "@/media/file-type";
import { EnteFile } from "@/new/photos/types/file";
import CloseIcon from "@mui/icons-material/Close";
import { IconButton } from "@mui/material";
import { t } from "i18next";
Expand All @@ -17,7 +18,6 @@ import {
} from "services/searchService";
import { Collection } from "types/collection";
import { LocationTagData } from "types/entity";
import { EnteFile } from "types/file";
import {
ClipSearchScores,
DateValue,
Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/components/ml/PeopleList.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { EnteFile } from "@/new/photos/types/file";
import { blobCache } from "@/next/blob-cache";
import { Skeleton, styled } from "@mui/material";
import { Legend } from "components/PhotoViewer/styledComponents/Legend";
import { t } from "i18next";
import React, { useEffect, useState } from "react";
import { unidentifiedFaceIDs } from "services/face/indexer";
import type { Person } from "services/face/people";
import { EnteFile } from "types/file";

const FaceChipContainer = styled("div")`
display: flex;
Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/components/pages/gallery/Avatar.tsx
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { EnteFile } from "@/new/photos/types/file";
import log from "@/next/log";
import { styled } from "@mui/material";
import { useTheme } from "@mui/material/styles";
import { GalleryContext } from "pages/gallery";
import React, { useContext, useLayoutEffect, useState } from "react";
import { EnteFile } from "types/file";

interface AvatarProps {
file?: EnteFile;
Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/components/pages/gallery/Navbar.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import { FlexWrapper, HorizontalFlex } from "@ente/shared/components/Container";
import SidebarToggler from "@ente/shared/components/Navbar/SidebarToggler";
import NavbarBase from "@ente/shared/components/Navbar/base";
Expand All @@ -9,7 +10,6 @@ import { t } from "i18next";
import { AppContext } from "pages/_app";
import React from "react";
import { Collection } from "types/collection";
import { EnteFile } from "types/file";
import { UpdateSearch } from "types/search";

interface Iprops {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { FILE_TYPE } from "@/media/file-type";
import { EnteFile } from "@/new/photos/types/file";
import log from "@/next/log";
import { Overlay } from "@ente/shared/components/Container";
import { CustomError } from "@ente/shared/error";
Expand All @@ -17,7 +18,6 @@ import { DeduplicateContext } from "pages/deduplicate";
import { GalleryContext } from "pages/gallery";
import React, { useContext, useEffect, useRef, useState } from "react";
import DownloadManager from "services/download";
import { EnteFile } from "types/file";
import { shouldShowAvatar } from "utils/file";
import Avatar from "./Avatar";

Expand Down
6 changes: 3 additions & 3 deletions web/apps/photos/src/pages/deduplicate/index.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import { t } from "i18next";

import { getLocalFiles } from "@/new/photos/services/files";
import PhotoFrame from "components/PhotoFrame";
import { ALL_SECTION } from "constants/collection";
import { t } from "i18next";
import { AppContext } from "pages/_app";
import { createContext, useContext, useEffect, useState } from "react";
import { Duplicate, getDuplicates } from "services/deduplicationService";
import { getLocalFiles, syncFiles, trashFiles } from "services/fileService";
import { syncFiles, trashFiles } from "services/fileService";
import { SelectedState } from "types/gallery";

import { VerticallyCentered } from "@ente/shared/components/Container";
Expand Down
5 changes: 3 additions & 2 deletions web/apps/photos/src/pages/gallery/index.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
import { WhatsNew } from "@/new/photos/components/WhatsNew";
import { shouldShowWhatsNew } from "@/new/photos/services/changelog";
import { fetchAndSaveFeatureFlagsIfNeeded } from "@/new/photos/services/feature-flags";
import { getLocalFiles } from "@/new/photos/services/files";
import { EnteFile } from "@/new/photos/types/file";
import log from "@/next/log";
import { CenteredFlex } from "@ente/shared/components/Container";
import EnteSpinner from "@ente/shared/components/EnteSpinner";
Expand Down Expand Up @@ -90,13 +92,12 @@ import {
import downloadManager from "services/download";
import { syncCLIPEmbeddings } from "services/embeddingService";
import { syncEntities } from "services/entityService";
import { getLocalFiles, syncFiles } from "services/fileService";
import { syncFiles } from "services/fileService";
import locationSearchService from "services/locationSearchService";
import { getLocalTrashedFiles, syncTrash } from "services/trashService";
import uploadManager from "services/upload/uploadManager";
import { isTokenValid, syncMapEnabled } from "services/userService";
import { Collection, CollectionSummaries } from "types/collection";
import { EnteFile } from "types/file";
import {
GalleryContextType,
SelectedState,
Expand Down
2 changes: 1 addition & 1 deletion web/apps/photos/src/pages/shared-albums/index.tsx
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { EnteFile } from "@/new/photos/types/file";
import log from "@/next/log";
import {
CenteredFlex,
Expand Down Expand Up @@ -58,7 +59,6 @@ import {
verifyPublicCollectionPassword,
} from "services/publicCollectionService";
import { Collection } from "types/collection";
import { EnteFile } from "types/file";
import {
SelectedState,
SetFilesDownloadProgressAttributes,
Expand Down
4 changes: 2 additions & 2 deletions web/apps/photos/src/services/clip-service.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
import { FILE_TYPE } from "@/media/file-type";
import { getAllLocalFiles, getLocalFiles } from "@/new/photos/services/files";
import { EnteFile } from "@/new/photos/types/file";
import { ensureElectron } from "@/next/electron";
import log from "@/next/log";
import ComlinkCryptoWorker from "@ente/shared/crypto";
Expand All @@ -8,11 +10,9 @@ import { LS_KEYS, getData } from "@ente/shared/storage/localStorage";
import isElectron from "is-electron";
import PQueue from "p-queue";
import { Embedding } from "types/embedding";
import { EnteFile } from "types/file";
import { getPersonalFiles } from "utils/file";
import downloadManager from "./download";
import { localCLIPEmbeddings, putEmbedding } from "./embeddingService";
import { getAllLocalFiles, getLocalFiles } from "./fileService";

/** Status of CLIP indexing on the images in the user's local library. */
export interface CLIPIndexingStatus {
Expand Down
Loading

0 comments on commit 80d5d7e

Please sign in to comment.