π End-to-end encrypted cloud for everything.
Dart 2faandroidauthye2eeencryptionend-to-end-encryptionfluttergolanggoogle-photosgoogle-photos-alternativeiosopensourcephotosprivacyprivacy-toolstypescriptzero-knowledge
Tighten contact linking cleanup
Neeraj Gupta85ac15d43180
diff --git a/mobile/apps/photos/lib/services/photos_contacts_service.dart b/mobile/apps/photos/lib/services/photos_contacts_service.dartindex e5b5c3305a..26d680e09c 100644--- a/mobile/apps/photos/lib/services/photos_contacts_service.dart+++ b/mobile/apps/photos/lib/services/photos_contacts_service.dart@@ -139,26 +139,22 @@ class PhotosContactsService {}String? getCachedSavedName({int? contactUserId, String? email}) {- final savedName = getCachedContact(- contactUserId: contactUserId,- email: email,- )?.data?.name;- if (savedName == null) {- return null;- }- final trimmed = savedName.trim();- return trimmed.isEmpty ? null : trimmed;+ return _trimmedNonEmpty(+ getCachedContact(contactUserId: contactUserId, email: email)?.data?.name,+ );}String? getCachedResolvedEmail({int? contactUserId, String? email}) {- final resolved = getCachedContact(- contactUserId: contactUserId,- email: email,- )?.email;- if (resolved == null) {+ return _trimmedNonEmpty(+ getCachedContact(contactUserId: contactUserId, email: email)?.email,+ );+ }++ String? _trimmedNonEmpty(String? value) {+ if (value == null) {return null;}- final trimmed = resolved.trim();+ final trimmed = value.trim();return trimmed.isEmpty ? null : trimmed;}diff --git a/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart b/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dartindex 6b3099dc63..9f7b6498e6 100644--- a/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/person_selection_action_widgets.dart@@ -674,6 +674,7 @@ class _ReassignMeSelectionPageState extends State<ReassignMeSelectionPage> {itemCount: results.length,itemBuilder: (context, index) {return _RoundedPersonFaceWidget(+ key: ValueKey(results[index].remoteID),onTap: () async {final dialog = createProgressDialog(context,diff --git a/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dart b/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dartindex 195d96122a..5a52e38f5b 100644--- a/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dart+++ b/mobile/apps/photos/lib/ui/viewer/people/save_or_edit_person.dart@@ -354,6 +354,7 @@ class _SaveOrEditPersonState extends State<SaveOrEditPerson> {context,);if (updatedPersonEntity != null) {+ if (!mounted) return;Navigator.pop(context, updatedPersonEntity);}} else {@@ -372,6 +373,7 @@ class _SaveOrEditPersonState extends State<SaveOrEditPerson> {return null;});if (newPersonEntity != null) {+ if (!mounted) return;Navigator.pop(context, newPersonEntity);}}diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/contact_person_picker_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/contact_person_picker_page.dartindex 44548551d5..36a648f504 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/contact_person_picker_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/contact_person_picker_page.dart@@ -57,20 +57,7 @@ class ContactPersonPickerPage extends StatelessWidget {},),],- slivers: [- if (persons.isEmpty)- SliverFillRemaining(- hasScrollBody: false,- child: Center(- child: Text(- "${l10n.noResultsFound}.",- style: TextStyles.body.copyWith(color: colors.textLight),- ),- ),- )- else- _buildGrid(persons),- ],+ slivers: [_buildGrid(persons)],),);}@@ -100,6 +87,7 @@ class ContactPersonPickerPage extends StatelessWidget {delegate: SliverChildBuilderDelegate(childCount: persons.length,(context, index) => _PersonTile(+ key: ValueKey(persons[index].remoteID),person: persons[index],size: tileSize,contactUserId: contactUserId,@@ -115,6 +103,7 @@ class ContactPersonPickerPage extends StatelessWidget {class _PersonTile extends StatelessWidget {const _PersonTile({+ super.key,required this.person,required this.size,required this.contactUserId,diff --git a/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart b/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dartindex 252ae68efb..9b34fde2d1 100644--- a/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart+++ b/mobile/apps/photos/lib/ui/viewer/search/result/edit_contact_page.dart@@ -182,9 +182,10 @@ class _EditContactPageState extends State<EditContactPage> {),),const SizedBox(height: 20),- _ReadOnlyContactTextInput(+ TextInputComponent(label: l10n.email,- value: widget.email,+ initialValue: widget.email,+ isDisabled: true,),const SizedBox(height: 20),TextInputComponent(@@ -577,7 +578,7 @@ class _EditContactPageState extends State<EditContactPage> {contactNameChanged &&contactName.isNotEmpty &&selectedPerson.data.name.trim() != contactName;- if (shouldUpdateSelectedLink) {+ if (shouldUpdateSelectedLink || shouldUpdateSelectedName) {updatedPersons.add(await PersonService.instance.updateAttributes(selectedPerson.remoteID,@@ -587,14 +588,6 @@ class _EditContactPageState extends State<EditContactPage> {syncLinkedContactName: false,),);- } else if (shouldUpdateSelectedName) {- updatedPersons.add(- await PersonService.instance.updateAttributes(- selectedPerson.remoteID,- name: contactName,- syncLinkedContactName: false,- ),- );}}@@ -669,42 +662,6 @@ class _EditContactPageState extends State<EditContactPage> {}}-class _ReadOnlyContactTextInput extends StatelessWidget {- const _ReadOnlyContactTextInput({required this.label, required this.value});-- final String label;- final String value;-- @override- Widget build(BuildContext context) {- final colors = context.componentColors;- return Column(- crossAxisAlignment: CrossAxisAlignment.start,- mainAxisSize: MainAxisSize.min,- children: [- Text(label, style: TextStyles.body.copyWith(color: colors.textBase)),- const SizedBox(height: 9),- Container(- height: 52,- width: double.infinity,- alignment: Alignment.centerLeft,- padding: const EdgeInsets.symmetric(horizontal: Spacing.lg),- decoration: BoxDecoration(- color: colors.fillLight,- borderRadius: BorderRadius.circular(Radii.lg),- ),- child: Text(- value,- maxLines: 1,- overflow: TextOverflow.ellipsis,- style: TextStyles.body.copyWith(color: colors.textLightest),- ),- ),- ],- );- }-}-class _AvatarActionButton extends StatelessWidget {final double size;final bool isUnlink;diff --git a/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart b/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dartindex 1df341e96a..96b044e0fe 100644--- a/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart+++ b/mobile/apps/photos/lib/ui/viewer/search_tab/contacts_section.dart@@ -103,13 +103,16 @@ class _ContactsSectionState extends State<ContactsSection> {streamSubscriptions.add(stream.listen((event) async {_debouncer.run(() async {- _contactSearchResults =+ final contactSearchResults =(await SectionType.contacts.getData(context,limit: widget.resultLimit + 1,))as List<GenericSearchResult>;- setState(() {});+ if (!mounted) return;+ setState(() {+ _contactSearchResults = contactSearchResults;+ });});}),);diff --git a/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dart b/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dartindex 234e7ec556..02b159f1e7 100644--- a/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dart+++ b/mobile/apps/photos/test/models/ml/face/person_contact_link_test.dart@@ -168,25 +168,6 @@ void main() {expect(contactsService.createOrUpdateCalls, 0);expect(contactsService.lastUpdatedName, isNull);});-- test("updateAttributes clears userID when explicitly provided", () async {- final updated = await personService.updateAttributes(- "person-1",- email: null,- userID: null,- );-- expect(updated.data.userID, isNull);- expect(updated.data.email, isNull);-- final stored = await entityService.getEntity(- EntityType.cgroup,- "person-1",- );- final storedJson = jsonDecode(stored!.data) as Map<String, dynamic>;- expect(storedJson["userID"], isNull);- expect(storedJson["email"], isNull);- });});group("contact link conflict rules", () {