Skip to content

armgit / ente

Public Imported from GitHub
0

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

Reduce scope

Manav Rathi77563a7483f2
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index e331efb6b1..b22c4d3a1c 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -309,7 +309,6 @@ export default function Gallery() {
state.view?.type == "people" ? state.view.activePerson : undefined;
const activePersonID = activePerson?.id;
const isInSearchMode = state.isInSearchMode;
- const selectedSearchOption = state.selectedSearchOption;
const filteredFiles = state.filteredFiles;
if (process.env.NEXT_PUBLIC_ENTE_WIP_CL) console.log("render", state);
@@ -446,29 +445,29 @@ export default function Gallery() {
}, [peopleState]);
useEffect(() => {
- if (isInSearchMode && selectedSearchOption) {
+ if (isInSearchMode && state.searchSuggestion) {
setPhotoListHeader({
height: 104,
item: (
<SearchResultsHeader
- selectedOption={selectedSearchOption}
+ searchSuggestion={state.searchSuggestion}
fileCount={state.searchResults?.length ?? 0}
/>
),
itemType: ITEM_TYPE.HEADER,
});
}
- }, [isInSearchMode, selectedSearchOption, state.searchResults]);
+ }, [isInSearchMode, state.searchSuggestion, state.searchResults]);
// TODO: Make this a normal useEffect.
useMemoSingleThreaded(async () => {
- if (selectedSearchOption) {
+ if (state.searchSuggestion) {
const searchResults = await filterSearchableFiles(
- selectedSearchOption.suggestion,
+ state.searchSuggestion,
);
dispatch({ type: "setSearchResults", searchResults });
}
- }, [selectedSearchOption]);
+ }, [state.searchSuggestion]);
const selectAll = (e: KeyboardEvent) => {
// ignore ctrl/cmd + a if the user is typing in a text field
@@ -782,7 +781,10 @@ export default function Gallery() {
});
}
} else if (searchOption) {
- dispatch({ type: "enterSearchMode", searchOption });
+ dispatch({
+ type: "enterSearchMode",
+ searchSuggestion: searchOption.suggestion,
+ });
} else {
dispatch({ type: "exitSearch" });
}
@@ -932,10 +934,7 @@ export default function Gallery() {
openUploader,
isInSearchMode,
onShowSearchInput: () =>
- dispatch({
- type: "enterSearchMode",
- searchOption: undefined,
- }),
+ dispatch({ type: "enterSearchMode" }),
onSelectSearchOption: handleSelectSearchOption,
onSelectPeople: () =>
dispatch({ type: "showPeople" }),
diff --git a/web/packages/new/photos/components/gallery/index.tsx b/web/packages/new/photos/components/gallery/index.tsx
index 17bdbb3073..216e08a2bc 100644
--- a/web/packages/new/photos/components/gallery/index.tsx
+++ b/web/packages/new/photos/components/gallery/index.tsx
@@ -8,7 +8,7 @@
*/
import { CenteredFill } from "@/base/components/mui/Container";
-import type { SearchOption } from "@/new/photos/services/search/types";
+import type { SearchSuggestion } from "@/new/photos/services/search/types";
import { Paper, Stack, Typography } from "@mui/material";
import { t } from "i18next";
import React, { useState } from "react";
@@ -29,12 +29,12 @@ export type SelectionContext =
| { mode: "people"; personID: string };
interface SearchResultsHeaderProps {
- selectedOption: SearchOption;
+ searchSuggestion: SearchSuggestion;
fileCount: number;
}
export const SearchResultsHeader: React.FC<SearchResultsHeaderProps> = ({
- selectedOption,
+ searchSuggestion,
fileCount,
}) => (
<GalleryItemsHeaderAdapter>
@@ -42,7 +42,7 @@ export const SearchResultsHeader: React.FC<SearchResultsHeaderProps> = ({
{t("search_results")}
</Typography>
<GalleryItemsSummary
- name={selectedOption.suggestion.label}
+ name={searchSuggestion.label}
fileCount={fileCount}
/>
</GalleryItemsHeaderAdapter>
diff --git a/web/packages/new/photos/components/gallery/reducer.ts b/web/packages/new/photos/components/gallery/reducer.ts
index ea65269023..75e2b3acb1 100644
--- a/web/packages/new/photos/components/gallery/reducer.ts
+++ b/web/packages/new/photos/components/gallery/reducer.ts
@@ -39,7 +39,7 @@ import {
isPinnedCollection,
} from "../../services/magic-metadata";
import type { PeopleState, Person } from "../../services/ml/people";
-import type { SearchOption } from "../../services/search/types";
+import type { SearchSuggestion } from "../../services/search/types";
import type { FamilyData } from "../../services/user-details";
/**
@@ -246,11 +246,11 @@ export interface GalleryState {
*/
extraVisiblePerson: Person | undefined;
/**
- * The option selected by the user selected from the search bar dropdown.
+ * The suggestion selected by the user from the search bar dropdown.
*
* This is used to compute the {@link searchResults}.
*/
- selectedSearchOption: SearchOption | undefined;
+ searchSuggestion: SearchSuggestion | undefined;
/**
* List of files that match the selected search option.
*
@@ -330,7 +330,7 @@ export type GalleryAction =
}
| { type: "showPeople" }
| { type: "showPerson"; personID: string }
- | { type: "enterSearchMode"; searchOption: SearchOption | undefined }
+ | { type: "enterSearchMode"; searchSuggestion?: SearchSuggestion }
| { type: "setSearchResults"; searchResults: EnteFile[] }
| { type: "exitSearch" };
@@ -356,7 +356,7 @@ const initialGalleryState: GalleryState = {
selectedCollectionSummaryID: undefined,
selectedPersonID: undefined,
extraVisiblePerson: undefined,
- selectedSearchOption: undefined,
+ searchSuggestion: undefined,
searchResults: undefined,
view: undefined,
filteredFiles: [],
@@ -689,7 +689,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
...state,
selectedCollectionSummaryID: undefined,
extraVisiblePerson: undefined,
- selectedSearchOption: undefined,
+ searchSuggestion: undefined,
searchResults: undefined,
view: {
type: "albums",
@@ -704,7 +704,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
...state,
selectedCollectionSummaryID: undefined,
extraVisiblePerson: undefined,
- selectedSearchOption: undefined,
+ searchSuggestion: undefined,
searchResults: undefined,
view: {
type: "hidden-albums",
@@ -725,7 +725,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
...state,
selectedCollectionSummaryID,
extraVisiblePerson: undefined,
- selectedSearchOption: undefined,
+ searchSuggestion: undefined,
searchResults: undefined,
view,
isInSearchMode: false,
@@ -738,7 +738,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
selectedCollectionSummaryID: action.collectionSummaryID,
extraVisiblePerson: undefined,
searchResults: undefined,
- selectedSearchOption: undefined,
+ searchSuggestion: undefined,
view: {
type:
action.collectionSummaryID !== undefined &&
@@ -769,7 +769,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
selectedPersonID: view.activePerson?.id,
extraVisiblePerson,
searchResults: undefined,
- selectedSearchOption: undefined,
+ searchSuggestion: undefined,
view,
isInSearchMode: false,
});
@@ -788,7 +788,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
selectedPersonID: view.activePerson?.id,
extraVisiblePerson,
searchResults: undefined,
- selectedSearchOption: undefined,
+ searchSuggestion: undefined,
view,
isInSearchMode: false,
});
@@ -798,7 +798,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
return stateByUpdatingFilteredFiles({
...state,
isInSearchMode: true,
- selectedSearchOption: action.searchOption,
+ searchSuggestion: action.searchSuggestion,
});
case "setSearchResults":
@@ -811,7 +811,7 @@ const galleryReducer: React.Reducer<GalleryState, GalleryAction> = (
return stateByUpdatingFilteredFiles({
...state,
searchResults: undefined,
- selectedSearchOption: undefined,
+ searchSuggestion: undefined,
isInSearchMode: false,
});
}
diff --git a/web/packages/new/photos/services/search/types.ts b/web/packages/new/photos/services/search/types.ts
index 81a8364b4a..ddd2505ae4 100644
--- a/web/packages/new/photos/services/search/types.ts
+++ b/web/packages/new/photos/services/search/types.ts
@@ -32,8 +32,7 @@ export type SearchSuggestion = { label: string } & (
* An option shown in the the search bar's select dropdown.
*
* The {@link SearchOption} wraps a {@link SearchSuggestion} with some metadata
- * used when showing a corresponding entry in the dropdown, and in the results
- * header.
+ * used when showing a corresponding entry in the dropdown.
*
* If the user selects the option, then we will re-run the search using the
* {@link suggestion} to filter the list of files shown to the user.
@@ -43,12 +42,6 @@ export interface SearchOption {
/**
* The count of files that matched the search option when it was initially
* computed.
- *
- * Later updates (e.g. deletion of files that are being shown as search
- * results) may make this diverge from the correct count, so the gallery
- * should instead take the count from the count of the computed search
- * results. This property is thus meant only for the search dropdown to the
- * show the count.
*/
fileCount: number;
previewFiles: EnteFile[];