π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Prune
Manav Rathi7b890e21d5e5
diff --git a/web/apps/photos/src/components/SearchBar.tsx b/web/apps/photos/src/components/SearchBar.tsxindex b44a836f36..dc1a444a4a 100644--- a/web/apps/photos/src/components/SearchBar.tsx+++ b/web/apps/photos/src/components/SearchBar.tsx@@ -431,9 +431,6 @@ const EmptyState: React.FC<EmptyStateProps> = () => {</Typography></Box>);- // const indexStatusSuggestion = options.filter(- // (o) => o.type === SuggestionType.INDEX_STATUS,- // )[0] as Suggestion;// TODO-Cluster// const options = props.selectProps.options as SearchOption[];@@ -482,6 +479,52 @@ const EmptyState: React.FC<EmptyStateProps> = () => {// padding: 0px 12px;// `;+/*+TODO: Cluster++export async function getAllPeopleSuggestion(): Promise<Array<Suggestion>> {+ try {+ const people = await getAllPeople(200);+ return people.map((person) => ({+ label: person.name,+ type: SuggestionType.PERSON,+ value: person,+ hide: true,+ }));+ } catch (e) {+ log.error("getAllPeopleSuggestion failed", e);+ return [];+ }+}++async function getAllPeople(limit: number = undefined) {+ return (await wipSearchPersons()).slice(0, limit);+ // TODO-Clustetr+ // if (done) return [];++ // done = true;+ // if (process.env.NEXT_PUBLIC_ENTE_WIP_CL_FETCH) {+ // await syncCGroups();+ // const people = await clusterGroups();+ // log.debug(() => ["people", { people }]);+ // }++ // let people: Array<SearchPerson> = []; // await mlIDbStorage.getAllPeople();+ // people = await wipCluster();+ // // await mlPeopleStore.iterate<Person, void>((person) => {+ // // people.push(person);+ // // });+ // people = people ?? [];+ // const result = people+ // .sort((p1, p2) => p2.files.length - p1.files.length)+ // .slice(0, limit);+ // // log.debug(() => ["getAllPeople", result]);++ // return result;+}++*/+const Option: React.FC<OptionProps<SearchOption, false>> = (props) => (<SelectComponents.Option {...props}><LabelWithInfo data={props.data} />@@ -490,39 +533,37 @@ const Option: React.FC<OptionProps<SearchOption, false>> = (props) => (const LabelWithInfo = ({ data }: { data: SearchOption }) => {return (- !data.hide && (- <>- <Box className="main" px={2} py={1}>- <Typography variant="mini" mb={1}>- {labelForSuggestionType(data.type)}- </Typography>- <SpaceBetweenFlex>- <Box mr={1}>- <FreeFlowText>- <Typography fontWeight={"bold"}>- {data.label}- </Typography>- </FreeFlowText>- <Typography color="text.muted">- {t("photos_count", { count: data.fileCount })}+ <>+ <Box className="main" px={2} py={1}>+ <Typography variant="mini" mb={1}>+ {labelForSuggestionType(data.type)}+ </Typography>+ <SpaceBetweenFlex>+ <Box mr={1}>+ <FreeFlowText>+ <Typography fontWeight={"bold"}>+ {data.label}</Typography>- </Box>-- <Stack direction={"row"} spacing={1}>- {data.previewFiles.map((file) => (- <CollectionCard- key={file.id}- coverFile={file}- onClick={() => null}- collectionTile={ResultPreviewTile}- />- ))}- </Stack>- </SpaceBetweenFlex>- </Box>- <Divider sx={{ mx: 2, my: 1 }} />- </>- )+ </FreeFlowText>+ <Typography color="text.muted">+ {t("photos_count", { count: data.fileCount })}+ </Typography>+ </Box>++ <Stack direction={"row"} spacing={1}>+ {data.previewFiles.map((file) => (+ <CollectionCard+ key={file.id}+ coverFile={file}+ onClick={() => null}+ collectionTile={ResultPreviewTile}+ />+ ))}+ </Stack>+ </SpaceBetweenFlex>+ </Box>+ <Divider sx={{ mx: 2, my: 1 }} />+ </>);};diff --git a/web/apps/photos/src/services/searchService.ts b/web/apps/photos/src/services/searchService.tsindex de1bf355b2..47b6b27a2a 100644--- a/web/apps/photos/src/services/searchService.ts+++ b/web/apps/photos/src/services/searchService.ts@@ -1,10 +1,5 @@import log from "@/base/log";import { FileType } from "@/media/file-type";-import {- isMLSupported,- mlStatusSnapshot,- wipSearchPersons,-} from "@/new/photos/services/ml";import { createSearchQuery, search } from "@/new/photos/services/search";import type {SearchDateComponents,@@ -20,19 +15,9 @@ import {} from "@/new/photos/services/search/types";import type { LocationTag } from "@/new/photos/services/user-entity";import { EnteFile } from "@/new/photos/types/file";-import { t } from "i18next";import { Collection } from "types/collection";import { getUniqueFiles } from "utils/file";-// Suggestions shown in the search dropdown's empty state, i.e. when the user-// selects the search bar but does not provide any input.-export const getDefaultOptions = async () => {- return [- await getMLStatusSuggestion(),- ...(await convertSuggestionsToOptions(await getAllPeopleSuggestion())),- ].filter((t) => !!t);-};-// Suggestions shown in the search dropdown when the user has typed something.export const getAutoCompleteSuggestions =(files: EnteFile[], collections: Collection[]) =>@@ -87,55 +72,6 @@ async function convertSuggestionsToOptions(return previewImageAppendedOptions;}-export async function getAllPeopleSuggestion(): Promise<Array<Suggestion>> {- try {- const people = await getAllPeople(200);- return people.map((person) => ({- label: person.name,- type: SuggestionType.PERSON,- value: person,- hide: true,- }));- } catch (e) {- log.error("getAllPeopleSuggestion failed", e);- return [];- }-}--export async function getMLStatusSuggestion(): Promise<Suggestion> {- if (!isMLSupported) return undefined;-- const status = mlStatusSnapshot();-- if (!status || status.phase == "disabled") return undefined;-- let label: string;- switch (status.phase) {- case "scheduled":- label = t("indexing_scheduled");- break;- case "indexing":- label = t("indexing_photos", status);- break;- case "fetching":- label = t("indexing_fetching", status);- break;- case "clustering":- label = t("indexing_people", status);- break;- case "done":- label = t("indexing_done", status);- break;- }-- return {- label,- type: SuggestionType.INDEX_STATUS,- value: status,- hide: true,- };-}-function getCollectionSuggestion(searchPhrase: string,collections: Collection[],@@ -237,29 +173,3 @@ function convertSuggestionToSearchQuery(option: Suggestion): SearchQuery {return { clip: option.value as ClipSearchScores };}}--async function getAllPeople(limit: number = undefined) {- return (await wipSearchPersons()).slice(0, limit);- // TODO-Clustetr- // if (done) return [];-- // done = true;- // if (process.env.NEXT_PUBLIC_ENTE_WIP_CL_FETCH) {- // await syncCGroups();- // const people = await clusterGroups();- // log.debug(() => ["people", { people }]);- // }-- // let people: Array<SearchPerson> = []; // await mlIDbStorage.getAllPeople();- // people = await wipCluster();- // // await mlPeopleStore.iterate<Person, void>((person) => {- // // people.push(person);- // // });- // people = people ?? [];- // const result = people- // .sort((p1, p2) => p2.files.length - p1.files.length)- // .slice(0, limit);- // // log.debug(() => ["getAllPeople", result]);-- // return result;-}diff --git a/web/packages/new/photos/services/search/types.ts b/web/packages/new/photos/services/search/types.tsindex df62193df0..4f5915d87e 100644--- a/web/packages/new/photos/services/search/types.ts+++ b/web/packages/new/photos/services/search/types.ts@@ -5,7 +5,6 @@import type { Location } from "@/base/types";import { FileType } from "@/media/file-type";-import type { MLStatus } from "@/new/photos/services/ml";import type { EnteFile } from "@/new/photos/types/file";import type { LocationTag } from "../user-entity";@@ -106,7 +105,6 @@ export enum SuggestionType {COLLECTION = "COLLECTION",FILE_NAME = "FILE_NAME",PERSON = "PERSON",- INDEX_STATUS = "INDEX_STATUS",FILE_CAPTION = "FILE_CAPTION",FILE_TYPE = "FILE_TYPE",CLIP = "CLIP",@@ -120,12 +118,10 @@ export interface Suggestion {| SearchDateComponents| number[]| SearchPerson- | MLStatus| LocationTag| City| FileType| ClipSearchScores;- hide?: boolean;}export interface SearchQuery {diff --git a/web/packages/new/photos/services/search/ui.ts b/web/packages/new/photos/services/search/ui.tsindex c6e9de7668..eeeac84d8c 100644--- a/web/packages/new/photos/services/search/ui.ts+++ b/web/packages/new/photos/services/search/ui.ts@@ -18,8 +18,6 @@ export const labelForSuggestionType = (type: SuggestionType) => {return t("file_name");case SuggestionType.PERSON:return t("person");- case SuggestionType.INDEX_STATUS:- throw new Error("Not a displayable key");case SuggestionType.FILE_CAPTION:return t("description");case SuggestionType.FILE_TYPE: