Initial peer id refactoring

This commit is contained in:
Ali
2021-03-24 19:35:52 +04:00
parent 86e3e2bc35
commit 4dae31e340
127 changed files with 505 additions and 532 deletions

View File

@@ -337,7 +337,7 @@ public final class AvatarNode: ASDisplayNode {
} else if peer?.restrictionText(platform: "ios", contentSettings: context.currentContentSettings.with { $0 }) == nil {
representation = peer?.smallProfileImage
}
let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? PeerId(namespace: 0, id: 0), peer?.displayLetters ?? [], representation)
let updatedState: AvatarNodeState = .peerAvatar(peer?.id ?? PeerId(0), peer?.displayLetters ?? [], representation)
if updatedState != self.state || overrideImage != self.overrideImage || theme !== self.theme {
self.state = updatedState
self.overrideImage = overrideImage
@@ -381,7 +381,7 @@ public final class AvatarNode: ASDisplayNode {
}
self.editOverlayNode?.isHidden = true
parameters = AvatarNodeParameters(theme: theme, accountPeerId: context.account.peerId, peerId: peer?.id ?? PeerId(namespace: 0, id: 0), letters: peer?.displayLetters ?? [], font: self.font, icon: icon, explicitColorIndex: nil, hasImage: false, clipStyle: clipStyle)
parameters = AvatarNodeParameters(theme: theme, accountPeerId: context.account.peerId, peerId: peer?.id ?? PeerId(0), letters: peer?.displayLetters ?? [], font: self.font, icon: icon, explicitColorIndex: nil, hasImage: false, clipStyle: clipStyle)
}
if self.parameters == nil || self.parameters != parameters {
self.parameters = parameters
@@ -453,10 +453,10 @@ public final class AvatarNode: ASDisplayNode {
colorIndex = explicitColorIndex
} else {
if let peerId = parameters.peerId {
if peerId.namespace == -1 {
if peerId.namespace == .max {
colorIndex = -1
} else {
colorIndex = abs(Int(clamping: peerId.id))
colorIndex = abs(Int(clamping: peerId.id._internalGetInt32Value()))
}
} else {
colorIndex = -1
@@ -630,10 +630,10 @@ public func drawPeerAvatarLetters(context: CGContext, size: CGSize, font: UIFont
context.clip()
let colorIndex: Int
if peerId.namespace == -1 {
if peerId.namespace == .max {
colorIndex = -1
} else {
colorIndex = Int(abs(peerId.id))
colorIndex = Int(abs(peerId.id._internalGetInt32Value()))
}
let colorsArray: NSArray