Skip to content

armgit / ente

Public Imported from GitHub
0

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

List1

Manav Rathie0519d30e971
diff --git a/web/packages/new/photos/components/gallery/PeopleHeader.tsx b/web/packages/new/photos/components/gallery/PeopleHeader.tsx
index 33270cc0b6..5a52eff9c9 100644
--- a/web/packages/new/photos/components/gallery/PeopleHeader.tsx
+++ b/web/packages/new/photos/components/gallery/PeopleHeader.tsx
@@ -31,6 +31,7 @@ import EditIcon from "@mui/icons-material/Edit";
import ListAltOutlined from "@mui/icons-material/ListAltOutlined";
import MoreHoriz from "@mui/icons-material/MoreHoriz";
import {
+ Box,
Dialog,
DialogActions,
DialogContent,
@@ -337,6 +338,31 @@ const SuggestionsDialog: React.FC<SuggestionsDialogProps> = ({
onClose();
};
+ useEffect(() => {
+ if (!open) return;
+
+ // Avoid recomputing when the person object changes without its identity
+ // changing. This is a workaround, a better fix would be to fix upstream
+ // to guarantee a stable identity of the person object itself.
+ const personID = person.id;
+ if (person.id == state.personID) return;
+
+ dispatch({ type: "fetch", personID });
+
+ const go = async () => {
+ try {
+ const suggestions = await suggestionsForPerson(person);
+ console.log("fetching");
+ dispatch({ type: "fetched", personID, suggestions });
+ } catch (e) {
+ log.error("Failed to generate suggestions", e);
+ dispatch({ type: "fetchFailed", personID });
+ }
+ };
+
+ void go();
+ }, [open, person, state.personID]);
+
const handleClose = () => {
if (state.hasUnsavedChanges) {
showMiniDialog({
@@ -356,6 +382,14 @@ const SuggestionsDialog: React.FC<SuggestionsDialogProps> = ({
resetPersonAndClose();
};
+ const handleAccept = (suggestion: PersonSuggestion) => {
+ console.log("Accept", suggestion);
+ };
+
+ const handleReject = (suggestion: PersonSuggestion) => {
+ console.log("Reject", suggestion);
+ };
+
const handleSave = async () => {
try {
// TODO-Cluster
@@ -368,31 +402,6 @@ const SuggestionsDialog: React.FC<SuggestionsDialogProps> = ({
}
};
- useEffect(() => {
- if (!open) return;
-
- // Avoid recomputing when the person object changes without its identity
- // changing. This is a workaround, a better fix would be to fix upstream
- // to guarantee a stable identity of the person object itself.
- const personID = person.id;
- if (person.id == state.personID) return;
-
- dispatch({ type: "fetch", personID });
-
- const go = async () => {
- try {
- const suggestions = await suggestionsForPerson(person);
- console.log("fetching");
- dispatch({ type: "fetched", personID, suggestions });
- } catch (e) {
- log.error("Failed to generate suggestions", e);
- dispatch({ type: "fetchFailed", personID });
- }
- };
-
- void go();
- }, [open, person, state.personID]);
-
console.log({ f: "render", open, person, state });
return (
@@ -405,7 +414,7 @@ const SuggestionsDialog: React.FC<SuggestionsDialogProps> = ({
PaperProps={{ sx: { minHeight: "80svh" } }}
>
<DialogTitle sx={{ "&&&": { py: "20px" } }}>
- {pt(`${person.name}?`)}
+ {person.name && pt(`${person.name}?`)}
</DialogTitle>
<DialogContent dividers sx={{ display: "flex" }}>
{state.activity == "fetching" ? (
@@ -430,9 +439,13 @@ const SuggestionsDialog: React.FC<SuggestionsDialogProps> = ({
) : (
<ul>
{state.suggestions.map((suggestion) => (
- <li
- key={suggestion.id}
- >{`${suggestion.faces.length} faces`}</li>
+ <li key={suggestion.id}>
+ <SuggestionRow
+ suggestion={suggestion}
+ onAccept={handleAccept}
+ onReject={handleReject}
+ />
+ </li>
))}
</ul>
)}
@@ -458,3 +471,31 @@ const SuggestionsDialog: React.FC<SuggestionsDialogProps> = ({
</Dialog>
);
};
+
+interface SuggestionRowProps {
+ suggestion: PersonSuggestion;
+ /** "Yes" */
+ onAccept: (suggestion: PersonSuggestion) => void;
+ /** "No" */
+ onReject: (suggestion: PersonSuggestion) => void;
+}
+
+const SuggestionRow: React.FC<SuggestionRowProps> = ({
+ suggestion,
+ onAccept,
+ onReject,
+}) => {
+ return (
+ <SpaceBetweenFlex>
+ <Typography>{`${suggestion.faces.length} faces`}</Typography>
+ <Box sx={{ display: "flex", gap: 1 }}>
+ <FocusVisibleButton
+ color="accent"
+ onClick={() => onAccept(suggestion)}
+ >
+ {pt("Yes")}
+ </FocusVisibleButton>
+ </Box>
+ </SpaceBetweenFlex>
+ );
+};