Skip to content

armgit / ente

Public Imported from GitHub
0

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

empty state

Manav Rathib4a60fd2f4da
diff --git a/web/packages/gallery/services/video.ts b/web/packages/gallery/services/video.ts
index a17489328f..75021e7248 100644
--- a/web/packages/gallery/services/video.ts
+++ b/web/packages/gallery/services/video.ts
@@ -175,6 +175,10 @@ export const hlsGenerationStatusSubscribe = (
*
* See also {@link hlsGenerationStatusSubscribe}.
*
+ * This function can be safely called even if {@link isHLSGenerationSupported}
+ * is `false` (in such cases, it will always return `undefined`). This is so
+ * that it can be unconditionally called as part of a React hook.
+ *
* A return value of `undefined` indicates that the HLS generation subsystem has
* not been initialized yet.
*/
diff --git a/web/packages/new/photos/components/SearchBar.tsx b/web/packages/new/photos/components/SearchBar.tsx
index 8c9dd6acd6..0715727789 100644
--- a/web/packages/new/photos/components/SearchBar.tsx
+++ b/web/packages/new/photos/components/SearchBar.tsx
@@ -17,6 +17,10 @@ import { EnteLogo, EnteLogoBox } from "ente-base/components/EnteLogo";
import type { ButtonishProps } from "ente-base/components/mui";
import { useIsSmallWidth } from "ente-base/components/utils/hooks";
import { pt } from "ente-base/i18n";
+import {
+ hlsGenerationStatusSnapshot,
+ 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 { searchOptionsForString } from "ente-new/photos/services/search";
@@ -383,11 +387,26 @@ const shouldShowEmptyState = (inputValue: string) => {
// Don't show empty state if the user has entered search input.
if (inputValue) return false;
- // Don't show empty state if there is no ML related information.
- if (!isMLSupported) return false;
+ // Don't show empty state if there is no ML related information AND we're
+ // not processing videos.
+
+ if (!isMLSupported && !isHLSGenerationSupported()) {
+ // Neither of ML or HLS generation is supported on current client. This
+ // is the code path for web.
+ return false;
+ }
- const status = mlStatusSnapshot();
- if (!status || status.phase == "disabled") return false;
+ const mlStatus = mlStatusSnapshot();
+ const vpStatus = hlsGenerationStatusSnapshot();
+ 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.
+ return false;
+ }
// Show it otherwise.
return true;
@@ -429,9 +448,9 @@ const EmptyState: React.FC<
break;
}
- // If we're neither video processing, nor ML is enabled, then don't show the
+ // If ML is disabled and we're not video processing, then don't show the
// empty state content.
- if (!label && (!mlStatus || mlStatus.phase == "disabled")) {
+ if ((!mlStatus || mlStatus.phase == "disabled") && !label) {
return <></>;
}
diff --git a/web/packages/new/photos/services/ml/index.ts b/web/packages/new/photos/services/ml/index.ts
index f97d9d91bd..f02078a99b 100644
--- a/web/packages/new/photos/services/ml/index.ts
+++ b/web/packages/new/photos/services/ml/index.ts
@@ -471,10 +471,16 @@ export const mlStatusSubscribe = (onChange: () => void): (() => void) => {
*
* See also {@link mlStatusSubscribe}.
*
+ * This function can be safely called even if {@link isMLSupported} is `false`
+ * (in such cases, it will always return `undefined`). This is so that it can be
+ * unconditionally called as part of a React hook.
+ *
* A return value of `undefined` indicates that we're still performing the
* asynchronous tasks that are needed to get the status.
*/
export const mlStatusSnapshot = (): MLStatus | undefined => {
+ if (!isMLSupported) return undefined;
+
const result = _state.mlStatusSnapshot;
// We don't have it yet, trigger an update.
if (!result) triggerStatusUpdate();