Skip to content

armgit / ente

Public Imported from GitHub
0

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

Guard empty people actions

Neeraj Guptaf1db3c804bec
diff --git a/mobile/apps/photos/lib/ui/viewer/actions/people_selection_action_widget.dart b/mobile/apps/photos/lib/ui/viewer/actions/people_selection_action_widget.dart
index db2d13412b..ef5765c854 100644
--- a/mobile/apps/photos/lib/ui/viewer/actions/people_selection_action_widget.dart
+++ b/mobile/apps/photos/lib/ui/viewer/actions/people_selection_action_widget.dart
@@ -78,6 +78,13 @@ class _PeopleSelectionActionWidgetState
.toList();
}
+ bool _hasAssignedCluster(
+ String personID,
+ Map<String, PersonEntity> personMap,
+ ) {
+ return personMap[personID]?.data.assigned.isNotEmpty ?? false;
+ }
+
void _selectionChangedListener() {
if (mounted) {
setState(() {});
@@ -104,6 +111,9 @@ class _PeopleSelectionActionWidgetState
selectedPersonIds.length == 1 && selectedClusterIds.isEmpty;
final onlyPersonSelected =
selectedPersonIds.isNotEmpty && selectedClusterIds.isEmpty;
+ final onlySelectedPersonHasAssignedCluster =
+ onlyOnePerson &&
+ _hasAssignedCluster(selectedPersonIds.first, personMap);
final ignoredSelectedPersonIds = selectedPersonIds
.where((id) => personMap[id]?.data.isIgnored ?? false)
.toList();
@@ -116,8 +126,8 @@ class _PeopleSelectionActionWidgetState
selectedPersonIds.every(
(id) => (personMap[id]?.data.name ?? "").isNotEmpty,
);
- final bool showEditAction = onlyOnePerson;
- final bool showReviewAction = onlyOnePerson;
+ final bool showEditAction = onlySelectedPersonHasAssignedCluster;
+ final bool showReviewAction = onlySelectedPersonHasAssignedCluster;
final bool showMergeAction = onlyIgnoredPersonsSelected
? false
: selectedClusterIds.isNotEmpty;
@@ -311,6 +321,7 @@ class _PeopleSelectionActionWidgetState
final personID = selectedPersonIds.first;
final person = personMap[personID];
if (person == null) return;
+ if (person.data.assigned.isEmpty) return;
await routeToPage(
context,
@@ -330,6 +341,7 @@ class _PeopleSelectionActionWidgetState
final personID = selectedPersonIds.first;
final person = personMap[personID];
if (person == null) return;
+ if (person.data.assigned.isEmpty) return;
await routeToPage(context, PersonReviewClusterSuggestion(person));
widget.selectedPeople.clearAll();
diff --git a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
index a9e2527336..4e953cda48 100644
--- a/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
+++ b/mobile/apps/photos/lib/ui/viewer/people/people_app_bar.dart
@@ -250,6 +250,9 @@ class _AppBarWidgetState extends State<PeopleAppBar> {
}
Future<dynamic> _editPerson(BuildContext context) async {
+ if (person.data.assigned.isEmpty) {
+ return;
+ }
final result = await routeToPage(
context,
SaveOrEditPerson(
@@ -270,6 +273,7 @@ class _AppBarWidgetState extends State<PeopleAppBar> {
final bool isIgnored = person.data.isIgnored;
final bool isPinned = person.data.isPinned;
final bool hideFromMemories = person.data.hideFromMemories;
+ final bool hasAssignedCluster = person.data.assigned.isNotEmpty;
final List<Widget> actions = <Widget>[];
// If the user has selected files, don't show any actions
if (widget.selectedFiles.files.isNotEmpty ||
@@ -295,30 +299,33 @@ class _AppBarWidgetState extends State<PeopleAppBar> {
if (!isIgnored) {
items.addAll([
- EntePopupMenuOption(
- value: PeoplePopupAction.rename,
- label: AppLocalizations.of(context).edit,
- leadingWidget: galleryAppBarMenuIcon(
- HugeIcons.strokeRoundedPencilEdit01,
- iconColor,
+ if (hasAssignedCluster)
+ EntePopupMenuOption(
+ value: PeoplePopupAction.rename,
+ label: AppLocalizations.of(context).edit,
+ leadingWidget: galleryAppBarMenuIcon(
+ HugeIcons.strokeRoundedPencilEdit01,
+ iconColor,
+ ),
),
- ),
- EntePopupMenuOption(
- value: PeoplePopupAction.reviewSuggestions,
- label: AppLocalizations.of(context).review,
- leadingWidget: galleryAppBarMenuIcon(
- HugeIcons.strokeRoundedSearch01,
- iconColor,
+ if (hasAssignedCluster)
+ EntePopupMenuOption(
+ value: PeoplePopupAction.reviewSuggestions,
+ label: AppLocalizations.of(context).review,
+ leadingWidget: galleryAppBarMenuIcon(
+ HugeIcons.strokeRoundedSearch01,
+ iconColor,
+ ),
),
- ),
- EntePopupMenuOption(
- value: PeoplePopupAction.setCover,
- label: AppLocalizations.of(context).setCover,
- leadingWidget: galleryAppBarMenuIcon(
- HugeIcons.strokeRoundedImage01,
- iconColor,
+ if (hasAssignedCluster)
+ EntePopupMenuOption(
+ value: PeoplePopupAction.setCover,
+ label: AppLocalizations.of(context).setCover,
+ leadingWidget: galleryAppBarMenuIcon(
+ HugeIcons.strokeRoundedImage01,
+ iconColor,
+ ),
),
- ),
EntePopupMenuOption(
value: PeoplePopupAction.pinPerson,
label: isPinned ? context.l10n.unpinPerson : context.l10n.pinPerson,
@@ -370,22 +377,24 @@ class _AppBarWidgetState extends State<PeopleAppBar> {
]);
} else {
items.addAll([
- EntePopupMenuOption(
- value: PeoplePopupAction.rename,
- label: AppLocalizations.of(context).edit,
- leadingWidget: galleryAppBarMenuIcon(
- HugeIcons.strokeRoundedPencilEdit01,
- iconColor,
+ if (hasAssignedCluster)
+ EntePopupMenuOption(
+ value: PeoplePopupAction.rename,
+ label: AppLocalizations.of(context).edit,
+ leadingWidget: galleryAppBarMenuIcon(
+ HugeIcons.strokeRoundedPencilEdit01,
+ iconColor,
+ ),
),
- ),
- EntePopupMenuOption(
- value: PeoplePopupAction.reviewSuggestions,
- label: AppLocalizations.of(context).review,
- leadingWidget: galleryAppBarMenuIcon(
- HugeIcons.strokeRoundedSearch01,
- iconColor,
+ if (hasAssignedCluster)
+ EntePopupMenuOption(
+ value: PeoplePopupAction.reviewSuggestions,
+ label: AppLocalizations.of(context).review,
+ leadingWidget: galleryAppBarMenuIcon(
+ HugeIcons.strokeRoundedSearch01,
+ iconColor,
+ ),
),
- ),
EntePopupMenuOption(
value: PeoplePopupAction.unignore,
label: AppLocalizations.of(context).showPerson,