Merge commit '7621e2f8dec938cf48181c8b10afc9b01f444e68' into beta

This commit is contained in:
Ilya Laktyushin
2025-12-06 02:17:48 +04:00
commit 8344b97e03
28070 changed files with 7995182 additions and 0 deletions
+20
View File
@@ -0,0 +1,20 @@
load("@build_bazel_rules_swift//swift:swift.bzl", "swift_library")
swift_library(
name = "LocalizedPeerData",
module_name = "LocalizedPeerData",
srcs = glob([
"Sources/**/*.swift",
]),
copts = [
"-warnings-as-errors",
],
deps = [
"//submodules/TelegramCore:TelegramCore",
"//submodules/TelegramPresentationData:TelegramPresentationData",
"//submodules/TelegramUIPreferences:TelegramUIPreferences",
],
visibility = [
"//visibility:public",
],
)
@@ -0,0 +1,127 @@
import Foundation
import TelegramCore
import TelegramPresentationData
import TelegramUIPreferences
//import PhoneNumberFormat
public extension EnginePeer {
var compactDisplayTitle: String {
switch self {
case let .user(user):
if let firstName = user.firstName, !firstName.isEmpty {
return firstName
} else if let lastName = user.lastName, !lastName.isEmpty {
return lastName
} else if let _ = user.phone {
return "" //formatPhoneNumber("+\(phone)")
} else {
return "Deleted Account"
}
case let .legacyGroup(group):
return group.title
case let .channel(channel):
return channel.title
case .secretChat:
return ""
}
}
func displayTitle(strings: PresentationStrings, displayOrder: PresentationPersonNameOrder) -> String {
switch self {
case let .user(user):
if user.id.isReplies {
return strings.DialogList_Replies
}
if let firstName = user.firstName, !firstName.isEmpty {
if let lastName = user.lastName, !lastName.isEmpty {
switch displayOrder {
case .firstLast:
return "\(firstName) \(lastName)"
case .lastFirst:
return "\(lastName) \(firstName)"
}
} else {
return firstName
}
} else if let lastName = user.lastName, !lastName.isEmpty {
return lastName
} else if let _ = user.phone {
return "" //formatPhoneNumber("+\(phone)")
} else {
return strings.User_DeletedAccount
}
case let .legacyGroup(group):
return group.title
case let .channel(channel):
return channel.title
case .secretChat:
return ""
}
}
}
public extension EnginePeer.IndexName {
func isLessThan(other: EnginePeer.IndexName, ordering: PresentationPersonNameOrder) -> ComparisonResult {
switch self {
case let .title(lhsTitle, _):
let rhsString: String
switch other {
case let .title(title, _):
rhsString = title
case let .personName(first, last, _, _):
switch ordering {
case .firstLast:
if first.isEmpty {
rhsString = last
} else {
rhsString = first + last
}
case .lastFirst:
if last.isEmpty {
rhsString = first
} else {
rhsString = last + first
}
}
}
return lhsTitle.caseInsensitiveCompare(rhsString)
case let .personName(lhsFirst, lhsLast, _, _):
let lhsString: String
switch ordering {
case .firstLast:
if lhsFirst.isEmpty {
lhsString = lhsLast
} else {
lhsString = lhsFirst + lhsLast
}
case .lastFirst:
if lhsLast.isEmpty {
lhsString = lhsFirst
} else {
lhsString = lhsLast + lhsFirst
}
}
let rhsString: String
switch other {
case let .title(title, _):
rhsString = title
case let .personName(first, last, _, _):
switch ordering {
case .firstLast:
if first.isEmpty {
rhsString = last
} else {
rhsString = first + last
}
case .lastFirst:
if last.isEmpty {
rhsString = first
} else {
rhsString = last + first
}
}
}
return lhsString.caseInsensitiveCompare(rhsString)
}
}
}