Add methods to access real user names and enhanced setting to show original contact names #3
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
In Telegram Desktop, when a user has a contact saved in their address book, the local contact name overrides the real
first_nameandlast_namereceived from the Telegram API. This makes it impossible to access the original names from the API, even though they are still stored internally.For example:
first_name="John",last_name="Smith"user->name()anduser->topBarNameText()return "Johnny D"Solution
Added three new methods to the
UserDataclass that provide direct access to the original names from the Telegram API:realFirstName()- Returns the originalfirstNamefield from Telegram APIrealLastName()- Returns the originallastNamefield from Telegram APIrealFullName()- Returns the formatted full name without contact overridesAdditionally, implemented a new enhanced setting "Show original name of contacts" that, when enabled, displays the original names from the Telegram API instead of local contact overrides throughout the entire client interface.
Enhanced Setting Features
When the "Show original name of contacts" setting is enabled:
Usage Example
Implementation Details
PeerData::name()andPeerData::topBarNameText()methods to check the enhanced settingThe implementation provides both programmatic access to real names via the new methods and a user-facing setting to globally switch the display behavior, giving users full control over how contact names are shown throughout the application.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.