diff --git a/mobile/lib/ui/viewer/people/add_person_action_sheet.dart b/mobile/lib/ui/viewer/people/add_person_action_sheet.dart index ecfa6b56b5..b63034c440 100644 --- a/mobile/lib/ui/viewer/people/add_person_action_sheet.dart +++ b/mobile/lib/ui/viewer/people/add_person_action_sheet.dart @@ -290,6 +290,7 @@ class _PersonActionSheetState extends State { String initValue = '', required String clusterID, }) async { + PersonEntity? personEntity; final result = await showTextInputDialog( context, title: S.of(context).newPerson, @@ -308,15 +309,14 @@ class _PersonActionSheetState extends State { } try { userAlreadyAssigned = true; - final PersonEntity p = + personEntity = await PersonService.instance.addPerson(text, clusterID); final bool extraPhotosFound = await ClusterFeedbackService.instance - .checkAndDoAutomaticMerges(p, personClusterID: clusterID); + .checkAndDoAutomaticMerges(personEntity!, + personClusterID: clusterID); if (extraPhotosFound) { showShortToast(context, S.of(context).extraPhotosFound); } - Bus.instance.fire(PeopleChangedEvent()); - Navigator.pop(context, p); } catch (e, s) { Logger("_PersonActionSheetState") .severe("Failed to add person", e, s); @@ -327,6 +327,10 @@ class _PersonActionSheetState extends State { if (result is Exception) { await showGenericErrorDialog(context: context, error: result); } + if (personEntity != null) { + Bus.instance.fire(PeopleChangedEvent()); + Navigator.pop(context, personEntity); + } } Future> _getPersonsWithRecentFile({