Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix contact saved handle format #740

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions submodules/AccountContext/Sources/DeviceContactData.swift
Original file line number Diff line number Diff line change
Expand Up @@ -187,11 +187,11 @@ public final class DeviceContactInstantMessagingProfileData: Equatable, Hashable
}

public let phonebookUsernamePathPrefix = "@id"
private let phonebookUsernamePrefix = "https://t.me/" + phonebookUsernamePathPrefix
private let phonebookUsernamePrefix = "https://t.me/"

public extension DeviceContactUrlData {
convenience init(appProfile: PeerId) {
self.init(label: "Telegram", value: "\(phonebookUsernamePrefix)\(appProfile.id)")
convenience init(addressName: String) {
self.init(label: "Telegram", value: "\(phonebookUsernamePrefix)\(addressName)")
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1072,7 +1072,8 @@ public func deviceContactInfoController(context: AccountContext, updatedPresenta
if let editingName = state.editingState?.editingName, case let .personName(firstName, lastName, _) = editingName, (!firstName.isEmpty || !lastName.isEmpty) {
var urls = filteredData.urls
if let createForPeer = createForPeer {
let appProfile = DeviceContactUrlData(appProfile: createForPeer.id)
let addressName: String = createForPeer.addressName ?? ""
let appProfile = DeviceContactUrlData(addressName: addressName)
Copy link

@aiosadchy aiosadchy Mar 31, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like you're using username instead of a raw numeric user ID, so the contact link may become invalid later as usernames may change, whereas user ID stays the same, so I would recommend using it instead.

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Up: I did some research and it seems like other clients (desktop, web) have no support for deep links right now so maybe it is fine to stick with usernames.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, username is working fine currently. So this pr should be good to go then?

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Well, this code was using deep links before, so maybe there was a reason for it. Anyways now it seems ok to me so let's wait for the others to decide (as I'm not a contributor).

var found = false
for url in urls {
if url.label == appProfile.label && url.value == appProfile.value {
Expand Down