From efb88f1c90614052d9269191d3dda87c4e4cec7a Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Mon, 14 Oct 2024 15:27:18 +0530 Subject: [PATCH] List 2 --- .../components/gallery/PeopleHeader.tsx | 129 ++++++++++++------ 1 file changed, 86 insertions(+), 43 deletions(-) diff --git a/web/packages/new/photos/components/gallery/PeopleHeader.tsx b/web/packages/new/photos/components/gallery/PeopleHeader.tsx index 5a52eff9c9..b72c9e659e 100644 --- a/web/packages/new/photos/components/gallery/PeopleHeader.tsx +++ b/web/packages/new/photos/components/gallery/PeopleHeader.tsx @@ -37,6 +37,8 @@ import { DialogContent, DialogTitle, IconButton, + List, + ListItem, Stack, Tooltip, Typography, @@ -257,7 +259,21 @@ interface SuggestionsDialogState { * This is a workaround for the lack of stable identity of the person prop. */ personID: string | undefined; + /** + * List of clusters (suitably augmented for the UI display) which might + * belong to the person, and being offered to the user as suggestions. + */ suggestions: PersonSuggestion[]; + /** + * IDs of the clusters (suggestions) that the user has accepted (as also + * belonging to the person under consideration). + */ + acceptedSuggestionIDs: Set; + /** + * IDs of the clusters (suggestions) that the user has rejected (as not + * belonging to the person under consideration). + */ + rejectedSuggestionIDs: Set; } type SuggestionsDialogAction = @@ -273,6 +289,8 @@ const initialSuggestionsDialogState: SuggestionsDialogState = { fetchFailed: false, hasUnsavedChanges: false, suggestions: [], + acceptedSuggestionIDs: new Set(), + rejectedSuggestionIDs: new Set(), }; const suggestionsDialogReducer = ( @@ -287,23 +305,17 @@ const suggestionsDialogReducer = ( fetchFailed: false, hasUnsavedChanges: false, suggestions: [], + acceptedSuggestionIDs: new Set(), + rejectedSuggestionIDs: new Set(), }; case "fetchFailed": if (action.personID != state.personID) return state; - return { - activity: undefined, - personID: state.personID, - fetchFailed: true, - hasUnsavedChanges: false, - suggestions: [], - }; + return { ...state, activity: undefined, fetchFailed: true }; case "fetched": if (action.personID != state.personID) return state; return { + ...state, activity: undefined, - personID: state.personID, - fetchFailed: false, - hasUnsavedChanges: false, suggestions: action.suggestions, }; case "save": @@ -437,17 +449,13 @@ const SuggestionsDialog: React.FC = ({ ) : ( -
    - {state.suggestions.map((suggestion) => ( -
  • - -
  • - ))} -
+ )} @@ -472,30 +480,65 @@ const SuggestionsDialog: React.FC = ({ ); }; -interface SuggestionRowProps { - suggestion: PersonSuggestion; - /** "Yes" */ +type SuggestionsListProps = Pick< + SuggestionsDialogState, + "suggestions" | "acceptedSuggestionIDs" | "rejectedSuggestionIDs" +> & { + /** + * Callback invoked when the user selects the "Yes" option next to a + * suggestion. + */ onAccept: (suggestion: PersonSuggestion) => void; - /** "No" */ + /** + * Callback invoked when the user selects the "No" option next to a + * suggestion. + */ onReject: (suggestion: PersonSuggestion) => void; -} +}; -const SuggestionRow: React.FC = ({ - suggestion, +const SuggestionsList: React.FC = ({ + suggestions, + acceptedSuggestionIDs, + rejectedSuggestionIDs, onAccept, onReject, -}) => { - return ( - - {`${suggestion.faces.length} faces`} - - onAccept(suggestion)} - > - {pt("Yes")} - - - - ); -}; +}) => ( + + {suggestions.map((suggestion) => ( + + {`${suggestion.faces.length} faces ntaoheu naoehtu aosnehu asoenuh aoenuht`} + + onAccept(suggestion)} + > + {pt("Yes")} + + onAccept(suggestion)} + > + {pt("No")} + + + + ))} + +);