signalapp / Signal-iOS

A private messenger for iOS.
https://signal.org
GNU Affero General Public License v3.0
10.79k stars 3.02k forks source link

Contacts are sorted by nickname instead of considering the system preferences #4847

Open christianapel opened 3 years ago

christianapel commented 3 years ago

Bug description

The contacts on my phone are sorted by last name and Signal is using the same basic sort order. But some of my contacts have a nickname in the iOS contact list, and this is where the sort order is different.

While Signal is sorting contacts with nickname into the bucket of the nicknames first character, the iOS contacts list doesn't consider the nickname. In the iOS contacts list all names are sorted by last name, no matter if a nickname is configured or not.

Steps to reproduce

Actual result: Contacts with nicknames are not sorted by their last name, but by their nickname instead.

Expected result: Contacts should always be sorted as it's configured for the iOS contacts.

Device info

Device: iPhone 11 Pro

iOS version: 14.4

Signal version: 5.3.1.0

sbilling commented 3 years ago

@christianapel the sorting is a function of the OS. The device favors the nickname in the CNContact object returned from fetching the device contacts.

christianapel commented 3 years ago

@christianapel the sorting is a function of the OS. The device favors the nickname in the CNContact object returned from fetching the device contacts.

In that case I'm wondering why the sort order in the iOS contacts list isn't considering the nickname. Beside that, Signal is the first app which is using my contacts and is sorting like that.

Which function is used to sort them? In CNContacts, the following enum is referenced and it doesn't contain a nickname: CNContactSortOrder

sbilling commented 3 years ago

@christianapel after further investigation it looks like we are using .userDefault as the CNContactSortOrder. I don't see anything that would point to the nickname playing a role in that so this is either an OS bug or I am missing something. I notice a bunch of weird behavior with the "nickname" attribute within the Signal app - sometimes it shows as the name, sometimes it doesn't. Very odd.

farovitus commented 3 years ago

I have the same issue, i have my contacts settings set to 'First, Last' and Signal app does respect my system preference until i add a nickname to any contact. In the cropped screenshot below you can see that the contact name start with the letter 'R' but signal listed him under "#" cause the contact's nickname start with a number. Hope this information make our issue clear to developers so they can address it ASAP cause it's the only messaging app that treat contacts list in this way. Thanks, image

farovitus commented 3 years ago

Also, here's a link to a similar (may not be caused by the same bug) issue reported previously https://github.com/signalapp/Signal-iOS/issues/4719

janseeger commented 3 years ago

I do experience the same issue. And I dug a bit around in the code and while it is true that the OS gives back the contacts array in the user preferred order, the collation into the different sections is done manually: https://github.com/signalapp/Signal-iOS/blob/db8f8c1e76a64b6522d59336a4c9b1248d968ca7/Signal/src/ViewControllers/ContactsPicker.swift#L378

stale[bot] commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

christianapel commented 2 years ago

This is still relevant. I've also had a look into the code and couldn't find any reference to the nickname being considered for sorting. If the nickname is automatically used once it is available for a contact, I could imagine that it would be required to set keys when fetching the contacts: https://developer.apple.com/documentation/contacts/cncontactfetchrequest/1403360-keystofetch

It should be sufficient to just read the contact keys that are relevant for the Signal UI, and if no other keys are available they cannot be used for sorting.

This is an example with some names to show how they are currently sorted on my device. The first two are sorted by nickname, and others are sorted by last name because they don't have a nickname configured:

Last Name First Name Nickname Name Bucket
Apel E*** Mum M
Apel P*** Dad D
Apel N*** - A
B*** L*** - B

As mentioned before, Signal is the only app that is sorting like this. The iOS contacts as well as other messaging apps are sorting by last name, first name as its configured.

stale[bot] commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

NiklasBr commented 2 years ago

This is still relevant. Please make the Stale bot stop spamming.

stale[bot] commented 2 years ago

Is this still relevant? If so, what is blocking it? Is there anything you can do to help move it forward?

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs.

janseeger commented 2 years ago

Yes, unfortunately still relevant. I checked a second ago.

stale[bot] commented 2 years ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

NiklasBr commented 2 years ago

Can's see anything has changed. The bot should stop.

stale[bot] commented 1 year ago

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

NiklasBr commented 1 year ago

Can's see anything has changed. The bot should stop.