Skip to content

armgit / ente

Public Imported from GitHub
0

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

fix(photos):preserve-search-until-people-consent-succeeds

Aswin Asokfd0534fb228f
diff --git a/web/apps/photos/src/components/SearchBar.tsx b/web/apps/photos/src/components/SearchBar.tsx
index b38b9238fc..e0be8ebe4b 100644
--- a/web/apps/photos/src/components/SearchBar.tsx
+++ b/web/apps/photos/src/components/SearchBar.tsx
@@ -68,7 +68,7 @@ export interface SearchBarProps {
o: SearchOption | undefined,
options?: { shouldExitSearchMode?: boolean },
) => void;
- onSelectPeople: () => void;
+ onSelectPeople: (onNavigate: () => void) => void;
onSelectPerson: (personID: string) => void;
}
@@ -302,8 +302,7 @@ const SearchInput: React.FC<
};
const handleSelectPeople = () => {
- resetSearch();
- onSelectPeople();
+ onSelectPeople(resetSearch);
};
const handleSelectPerson = (personID: string) => {
@@ -689,7 +688,7 @@ const Input: React.FC<InputProps<SearchOption, false>> = (props) => (
);
const EmptyState: React.FC<
- Pick<SearchBarProps, "onSelectPeople" | "onSelectPerson">
+ Pick<SearchBarProps, "onSelectPerson"> & { onSelectPeople: () => void }
> = ({ onSelectPeople, onSelectPerson }) => {
const mlStatus = useMLStatusSnapshot();
const people = usePeopleStateSnapshot()?.visiblePeople;
diff --git a/web/apps/photos/src/components/gallery/index.tsx b/web/apps/photos/src/components/gallery/index.tsx
index 35386e6319..43d5dacded 100644
--- a/web/apps/photos/src/components/gallery/index.tsx
+++ b/web/apps/photos/src/components/gallery/index.tsx
@@ -256,8 +256,8 @@ export const PeopleConsentDialog: React.FC<
setSubmitting(true);
try {
await enableML();
- onClose();
onEnabled();
+ onClose();
} finally {
submittingRef.current = false;
setSubmitting(false);
diff --git a/web/apps/photos/src/pages/gallery.tsx b/web/apps/photos/src/pages/gallery.tsx
index 68d89812a0..914a0fd272 100644
--- a/web/apps/photos/src/pages/gallery.tsx
+++ b/web/apps/photos/src/pages/gallery.tsx
@@ -288,6 +288,9 @@ const Page: React.FC = () => {
useModalVisibility();
const { show: showPeopleConsent, props: peopleConsentVisibilityProps } =
useModalVisibility();
+ const pendingPeopleSearchReset = useRef<(() => void) | undefined>(
+ undefined,
+ );
const { show: showPlanSelector, props: planSelectorVisibilityProps } =
useModalVisibility();
const {
@@ -1483,11 +1486,13 @@ const Page: React.FC = () => {
[showCollectionSummary],
);
- const handleShowPeople = () => {
+ const handleShowPeople = (onNavigate?: () => void) => {
if (!isMLEnabled()) {
+ pendingPeopleSearchReset.current = onNavigate;
showPeopleConsent();
return false;
}
+ onNavigate?.();
setCleanupView(undefined);
dispatch({ type: "showPeople" });
return true;
@@ -2228,7 +2233,13 @@ const Page: React.FC = () => {
<WhatsNew {...whatsNewVisibilityProps} />
<PeopleConsentDialog
{...peopleConsentVisibilityProps}
- onEnabled={handleShowPeople}
+ onClose={() => {
+ pendingPeopleSearchReset.current = undefined;
+ peopleConsentVisibilityProps.onClose();
+ }}
+ onEnabled={() =>
+ handleShowPeople(pendingPeopleSearchReset.current)
+ }
/>
<AssignPersonDialog
{...contextMenuAssignPersonProps}