π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Unignore option for named person
laurenspriem3e5f98dcf0c2
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.dartindex e20f05b460..fc5c2047cf 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@@ -38,6 +38,13 @@ class _PeopleSelectionActionWidgetStatelate Future<Map<String, PersonEntity>> personEntitiesMapFuture;final _logger = Logger("PeopleSelectionActionWidget");+ bool _isUnnamedIgnoredPerson(PersonEntity person) {+ final normalizedName = person.data.name.trim().toLowerCase();+ return normalizedName.isEmpty ||+ normalizedName == "(ignored)" ||+ normalizedName == "(hidden)";+ }+@overridevoid initState() {super.initState();@@ -98,45 +105,66 @@ class _PeopleSelectionActionWidgetStateselectedPersonIds.length == 1 && selectedClusterIds.isEmpty;final onlyPersonSelected =selectedPersonIds.isNotEmpty && selectedClusterIds.isEmpty;+ final ignoredSelectedPersonIds = selectedPersonIds+ .where((id) => personMap[id]?.data.isIgnored ?? false)+ .toList();+ final onlyIgnoredPersonsSelected =+ ignoredSelectedPersonIds.isNotEmpty &&+ selectedClusterIds.isEmpty &&+ ignoredSelectedPersonIds.length == selectedPersonIds.length;final bool namedPersonsSelected = selectedPersonIds.isNotEmpty &&selectedPersonIds.every((id) => (personMap[id]?.data.name ?? "").isNotEmpty,);final bool showEditAction = onlyOnePerson;final bool showReviewAction = onlyOnePerson;- final bool showMergeAction = selectedClusterIds.isNotEmpty;- final bool showResetAction = onlyOnePerson;- final bool showAutoAddAction = onlyPersonSelected;- final bool showPinAction = onlyPersonSelected &&- namedPersonsSelected &&- selectedPersonIds.every(- (id) => !(personMap[id]?.data.isPinned ?? false),- );- final bool showUnpinAction = onlyPersonSelected &&- namedPersonsSelected &&- selectedPersonIds.every(- (id) => personMap[id]?.data.isPinned ?? false,- );- final bool showHideFromMemoriesAction = onlyPersonSelected &&- namedPersonsSelected &&- selectedPersonIds.every(- (id) => !(personMap[id]?.data.hideFromMemories ?? false),- );- final bool showShowInMemoriesAction = onlyPersonSelected &&- namedPersonsSelected &&- selectedPersonIds.every(- (id) => personMap[id]?.data.hideFromMemories ?? false,- );+ final bool showMergeAction =+ onlyIgnoredPersonsSelected ? false : selectedClusterIds.isNotEmpty;+ final bool showResetAction =+ onlyIgnoredPersonsSelected ? false : onlyOnePerson;+ final bool showShowPersonAction = onlyIgnoredPersonsSelected;+ final bool showAutoAddAction =+ onlyIgnoredPersonsSelected ? false : onlyPersonSelected;+ final bool showPinAction = onlyIgnoredPersonsSelected+ ? false+ : onlyPersonSelected &&+ namedPersonsSelected &&+ selectedPersonIds.every(+ (id) => !(personMap[id]?.data.isPinned ?? false),+ );+ final bool showUnpinAction = onlyIgnoredPersonsSelected+ ? false+ : onlyPersonSelected &&+ namedPersonsSelected &&+ selectedPersonIds.every(+ (id) => personMap[id]?.data.isPinned ?? false,+ );+ final bool showHideFromMemoriesAction = onlyIgnoredPersonsSelected+ ? false+ : onlyPersonSelected &&+ namedPersonsSelected &&+ selectedPersonIds.every(+ (id) => !(personMap[id]?.data.hideFromMemories ?? false),+ );+ final bool showShowInMemoriesAction = onlyIgnoredPersonsSelected+ ? false+ : onlyPersonSelected &&+ namedPersonsSelected &&+ selectedPersonIds.every(+ (id) => personMap[id]?.data.hideFromMemories ?? false,+ );final bool hasNonIgnoredSelectedPerson = selectedPersonIds.any((id) => !(personMap[id]?.data.isIgnored ?? true),);- final bool showIgnoreAction =- selectedClusterIds.isNotEmpty || hasNonIgnoredSelectedPerson;+ final bool showIgnoreAction = onlyIgnoredPersonsSelected+ ? false+ : selectedClusterIds.isNotEmpty || hasNonIgnoredSelectedPerson;final bool hasVisibleAction = showEditAction ||showReviewAction ||showIgnoreAction ||showMergeAction ||showResetAction ||+ showShowPersonAction ||showPinAction ||showUnpinAction ||showHideFromMemoriesAction ||@@ -187,6 +215,14 @@ class _PeopleSelectionActionWidgetStateshouldShow: showResetAction,),);+ items.add(+ SelectionActionButton(+ labelText: AppLocalizations.of(context).showPerson,+ icon: Icons.visibility_outlined,+ onTap: _onShowPerson,+ shouldShow: showShowPersonAction,+ ),+ );items.add(SelectionActionButton(labelText: AppLocalizations.of(context).pin,@@ -416,6 +452,47 @@ class _PeopleSelectionActionWidgetState);}+ Future<void> _onShowPerson() async {+ final personMap = await personEntitiesMapFuture;+ final selectedPersonIds = _getSelectedPersonIds(personMap);+ if (selectedPersonIds.isEmpty) return;+ final ignoredSelectedPersonIds = selectedPersonIds+ .where((id) => personMap[id]?.data.isIgnored ?? false)+ .toList();+ if (ignoredSelectedPersonIds.length != selectedPersonIds.length) {+ return;+ }+ final multiple = ignoredSelectedPersonIds.length > 1;++ await showChoiceDialog(+ context,+ title: multiple+ ? "Are you sure you want to show these people in the people section again?"+ : "Are you sure you want to show this person in the people section again?",+ firstButtonLabel: multiple ? "Yes, show people" : "Yes, show person",+ firstButtonOnTap: () async {+ try {+ for (final personID in ignoredSelectedPersonIds) {+ final person = personMap[personID];+ if (person == null) continue;+ if (_isUnnamedIgnoredPerson(person)) {+ await PersonService.instance.deletePerson(person.remoteID);+ } else {+ await PersonService.instance.updateAttributes(+ person.remoteID,+ isHidden: false,+ );+ }+ }+ Bus.instance.fire(PeopleChangedEvent());+ widget.selectedPeople.clearAll();+ } catch (e, s) {+ _logger.severe('Failed to show person(s)', e, s);+ }+ },+ );+ }+Future<void> _onMerge() async {final personMap = await personEntitiesMapFuture;final selectedPersonIds = _getSelectedPersonIds(personMap);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.dartindex 2c22e2d7c6..64a72b62e5 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@@ -10,7 +10,6 @@ import "package:photos/events/people_changed_event.dart";import 'package:photos/events/subscription_purchased_event.dart';import "package:photos/generated/l10n.dart";import "package:photos/l10n/l10n.dart";-import "package:photos/models/file/file.dart";import 'package:photos/models/gallery_type.dart';import "package:photos/models/ml/face/person.dart";import 'package:photos/models/selected_files.dart';@@ -22,8 +21,6 @@ import "package:photos/ui/viewer/gallery/hooks/pick_person_avatar.dart";import "package:photos/ui/viewer/gallery/state/inherited_search_filter_data.dart";import "package:photos/ui/viewer/hierarchicial_search/applied_filters_for_appbar.dart";import "package:photos/ui/viewer/hierarchicial_search/recommended_filters_for_appbar.dart";-import "package:photos/ui/viewer/people/add_person_action_sheet.dart";-import "package:photos/ui/viewer/people/people_page.dart";import "package:photos/ui/viewer/people/person_cluster_suggestion.dart";import "package:photos/ui/viewer/people/person_selection_action_widgets.dart";import "package:photos/ui/viewer/people/save_or_edit_person.dart";@@ -402,6 +399,36 @@ class _AppBarWidgetState extends State<PeopleAppBar> {} else {items.addAll([+ PopupMenuItem(+ value: PeoplePopupAction.rename,+ child: Row(+ children: [+ const Icon(Icons.edit),+ const Padding(+ padding: EdgeInsets.all(8),+ ),+ Text(+ AppLocalizations.of(context).edit,+ style: textTheme.bodyBold,+ ),+ ],+ ),+ ),+ PopupMenuItem(+ value: PeoplePopupAction.reviewSuggestions,+ child: Row(+ children: [+ const Icon(Icons.search_outlined),+ const Padding(+ padding: EdgeInsets.all(8),+ ),+ Text(+ AppLocalizations.of(context).review,+ style: textTheme.bodyBold,+ ),+ ],+ ),+ ),PopupMenuItem(value: PeoplePopupAction.unignore,child: Row(@@ -410,7 +437,10 @@ class _AppBarWidgetState extends State<PeopleAppBar> {const Padding(padding: EdgeInsets.all(8),),- Text(AppLocalizations.of(context).showPerson),+ Text(+ AppLocalizations.of(context).showPerson,+ style: textTheme.bodyBold,+ ),],),),@@ -526,7 +556,7 @@ class _AppBarWidgetState extends State<PeopleAppBar> {}bool _isLegacyIgnoredName(String name) {- final normalizedName = name.trim();+ final normalizedName = name.trim().toLowerCase();return normalizedName.isEmpty ||normalizedName == "(ignored)" ||normalizedName == "(hidden)";@@ -563,27 +593,28 @@ class _AppBarWidgetState extends State<PeopleAppBar> {}Future<void> _showPerson(BuildContext context) async {- if (!_isLegacyIgnoredName(person.data.name)) {- await showChoiceDialog(- context,- title:- "Are you sure you want to show this person in people section again?",- firstButtonLabel: "Yes, show person",- firstButtonOnTap: () async {- try {+ final isUnnamedIgnoredPerson = _isLegacyIgnoredName(person.data.name);+ await showChoiceDialog(+ context,+ title:+ "Are you sure you want to show this person in people section again?",+ firstButtonLabel: "Yes, show person",+ firstButtonOnTap: () async {+ try {+ if (isUnnamedIgnoredPerson) {+ await PersonService.instance.deletePerson(person.remoteID);+ Bus.instance.fire(PeopleChangedEvent());+ } else {final updatedPerson = await PersonService.instance.updateAttributes(person.remoteID,isHidden: false,);setState(() {person = updatedPerson;- if (person.data.email == Configuration.instance.getEmail()) {- _appBarTitle = context.l10n.accountOwnerPersonAppbarTitle(- title: person.data.name,- );- } else {- _appBarTitle = person.data.name;- }+ _appBarTitle = _resolveAppBarTitle(+ sourcePerson: person,+ title: person.data.name,+ );});Bus.instance.fire(PeopleChangedEvent(@@ -592,49 +623,13 @@ class _AppBarWidgetState extends State<PeopleAppBar> {person: updatedPerson,),);- } catch (e, s) {- _logger.severe('Unignoring/showing person failed', e, s);}- },- );- return;- }-- bool assignName = false;- await showChoiceDialog(- context,- title:- "Are you sure you want to show this person in people section again?",- firstButtonLabel: "Yes, show person",- firstButtonOnTap: () async {- try {- await PersonService.instance.deletePerson(person.remoteID);- Bus.instance.fire(PeopleChangedEvent());- assignName = true;+ Navigator.of(context).pop();} catch (e, s) {- _logger.severe('Unignoring/showing and naming person failed', e, s);- // await showGenericErrorDialog(context: context, error: e);+ _logger.severe('Unignoring/showing person failed', e, s);}},);- if (assignName) {- final result = await showAssignPersonAction(- context,- clusterID: person.data.assigned.first.id,- );- Navigator.pop(context);- if (result != null) {- final person = result is (PersonEntity, EnteFile) ? result.$1 : result;- // ignore: unawaited_futures- routeToPage(- context,- PeoplePage(- person: person,- searchResult: null,- ),- );- }- }}Future<void> setCoverPhoto(BuildContext context) async {