Skip to content

armgit / ente

Public Imported from GitHub
0

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

[photos][web] Add search to Places navigation

AswinAsokffc28e6b963e
diff --git a/web/apps/photos/src/components/gallery/BarImpl.tsx b/web/apps/photos/src/components/gallery/BarImpl.tsx
index efee665f6f..b4717fb628 100644
--- a/web/apps/photos/src/components/gallery/BarImpl.tsx
+++ b/web/apps/photos/src/components/gallery/BarImpl.tsx
@@ -130,11 +130,19 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
const listRef = useRef<FixedSizeList | null>(null);
const albumListRef = useRef<VariableSizeList | null>(null);
const searchInputRef = useRef<HTMLInputElement>(null);
+ const [placesSearchQuery, setPlacesSearchQuery] = useState("");
const [peopleSearchQuery, setPeopleSearchQuery] = useState("");
const [groupExpanded, setGroupExpanded] = useState(true);
- const searchQuery = mode == "people" ? peopleSearchQuery : albumSearchQuery;
- const setSearchQuery =
- mode == "people" ? setPeopleSearchQuery : onAlbumSearchQueryChange;
+ const searchQuery = placesFiles
+ ? placesSearchQuery
+ : mode == "people"
+ ? peopleSearchQuery
+ : albumSearchQuery;
+ const setSearchQuery = placesFiles
+ ? setPlacesSearchQuery
+ : mode == "people"
+ ? setPeopleSearchQuery
+ : onAlbumSearchQueryChange;
const normalizedSearchQuery = searchQuery.trim().toLowerCase();
const isSearching = !!normalizedSearchQuery;
const matchingPeople = useMemo(
@@ -618,7 +626,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
sx={{
alignItems: "center",
flexShrink: 0,
- display: placesFiles ? "none" : "flex",
+ display: "flex",
height: 52,
gap: "10px",
px: "16px",
@@ -638,19 +646,23 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
inputRef={searchInputRef}
fullWidth
placeholder={t(
- mode == "people"
- ? "people_search_hint"
- : mode == "links"
- ? "search_links"
- : "search_in_albums",
+ placesFiles
+ ? "search_in_places"
+ : mode == "people"
+ ? "people_search_hint"
+ : mode == "links"
+ ? "search_links"
+ : "search_in_albums",
)}
inputProps={{
"aria-label": t(
- mode == "people"
- ? "people_search_hint"
- : mode == "links"
- ? "search_links"
- : "search_in_albums",
+ placesFiles
+ ? "search_in_places"
+ : mode == "people"
+ ? "people_search_hint"
+ : mode == "links"
+ ? "search_links"
+ : "search_in_albums",
),
}}
value={searchQuery}
@@ -681,6 +693,7 @@ export const GalleryBarImpl: React.FC<GalleryBarImplProps> = ({
{placesFiles ? (
<PlacesList
files={placesFiles}
+ searchQuery={placesSearchQuery}
selectedPlace={selectedPlace}
onSelectPlace={onSelectPlace}
/>
diff --git a/web/apps/photos/src/components/gallery/PlacesList.tsx b/web/apps/photos/src/components/gallery/PlacesList.tsx
index a5245bc68e..21160c264d 100644
--- a/web/apps/photos/src/components/gallery/PlacesList.tsx
+++ b/web/apps/photos/src/components/gallery/PlacesList.tsx
@@ -22,10 +22,12 @@ export interface PlaceSelection {
export const PlacesList = ({
files,
+ searchQuery,
selectedPlace,
onSelectPlace,
}: {
files: EnteFile[];
+ searchQuery: string;
selectedPlace?: PlaceSelection;
onSelectPlace: (place: PlaceSelection | undefined) => void;
}) => {
@@ -50,6 +52,10 @@ export const PlacesList = ({
}, [files]);
const currentResult = result?.files === files ? result : undefined;
+ const query = searchQuery.trim().toLocaleLowerCase();
+ const matchingGroups = currentResult?.groups?.filter(({ city }) =>
+ `${city.name}, ${city.country}`.toLocaleLowerCase().includes(query),
+ );
return (
<Stack sx={{ flex: 1, minHeight: 0, gap: "8px" }}>
@@ -85,7 +91,7 @@ export const PlacesList = ({
</Stack>
) : !currentResult.groups ? (
<Typography role="alert">{t("generic_error_retry")}</Typography>
- ) : !currentResult.groups.length ? (
+ ) : !matchingGroups?.length ? (
<Typography role="status">{t("no_results")}</Typography>
) : (
<List
@@ -100,7 +106,7 @@ export const PlacesList = ({
gap: "8px",
}}
>
- {currentResult.groups.map(({ city, coverFile }) => (
+ {matchingGroups.map(({ city, coverFile }) => (
<ListItem
key={`${city.name}-${city.country}-${city.latitude}-${city.longitude}`}
disableGutters
diff --git a/web/packages/base/locales/en-US/translation.json b/web/packages/base/locales/en-US/translation.json
index 6287cc5c09..73ae2aa5cc 100644
--- a/web/packages/base/locales/en-US/translation.json
+++ b/web/packages/base/locales/en-US/translation.json
@@ -498,6 +498,7 @@
"people_search_hint": "Search people",
"search_results": "Search results",
"search_places": "Places",
+ "search_in_places": "Search in Places",
"search_no_matches": "No matches found!",
"search_navigate_hint": "↑ ↓ to navigate Β· Enter to select",
"search_try_another": "Try another name, date or description.",