Skip to content

armgit / ente

Public Imported from GitHub
0

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

Hide search dropdown when there are no people to display

Anand Baburajan68cb6382196c
diff --git a/web/packages/new/photos/components/SearchBar.tsx b/web/packages/new/photos/components/SearchBar.tsx
index 31cb79f07f..0d364859bf 100644
--- a/web/packages/new/photos/components/SearchBar.tsx
+++ b/web/packages/new/photos/components/SearchBar.tsx
@@ -24,7 +24,11 @@ import {
isHLSGenerationSupported,
} from "ente-gallery/services/video";
import { ItemCard, PreviewItemTile } from "ente-new/photos/components/Tiles";
-import { isMLSupported, mlStatusSnapshot } from "ente-new/photos/services/ml";
+import {
+ isMLSupported,
+ mlStatusSnapshot,
+ peopleStateSnapshot,
+} from "ente-new/photos/services/ml";
import { searchOptionsForString } from "ente-new/photos/services/search";
import type { SearchOption } from "ente-new/photos/services/search/types";
import { nullToUndefined } from "ente-utils/transform";
@@ -547,17 +551,22 @@ const shouldShowEmptyState = (inputValue: string) => {
vpStatus: vpStatus?.enabled ? vpStatus.status : "disabled",
});
- if (
- (!mlStatus || mlStatus.phase == "disabled") &&
- (!vpStatus?.enabled || vpStatus.status != "processing")
- ) {
- // ML is either not supported or currently disabled AND video processing
- // is either not supported or currently not happening. Don't show the
- // empty state.
- log.info(
- "[SearchBar] shouldShowEmptyState: false (ML disabled, no video processing)",
- );
- return false;
+ const isMLInactive =
+ !mlStatus || mlStatus.phase == "disabled" || mlStatus.phase == "done";
+ const isVideoProcessing =
+ vpStatus?.enabled && vpStatus.status == "processing";
+
+ if (isMLInactive && !isVideoProcessing) {
+ // ML is inactive AND video processing is not happening.
+ // Only show empty state if there are people to display.
+ const people = peopleStateSnapshot()?.visiblePeople;
+ const hasPeople = people && people.length > 0;
+ if (!hasPeople) {
+ log.info(
+ "[SearchBar] shouldShowEmptyState: false (ML inactive, no video processing, no people)",
+ );
+ return false;
+ }
}
// Show it otherwise.
@@ -612,9 +621,9 @@ const EmptyState: React.FC<
break;
}
- // If ML is disabled and we're not video processing, then don't show the
- // empty state content.
- if ((!mlStatus || mlStatus.phase == "disabled") && !label) {
+ // If there's nothing to show (no people and no status label), return empty.
+ const hasPeople = people && people.length > 0;
+ if (!hasPeople && !label) {
return <></>;
}