Skip to content

Commit 0d94785

Browse files
committed
update lastest api
1 parent b0e20bf commit 0d94785

37 files changed

+1067
-76
lines changed

‎Telegram-Mac.xcworkspace/contents.xcworkspacedata

+3
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎Telegram-Mac/AvatarLayer.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ class AvatarControl: NSView {
211211
photo = nil
212212
self.setState(account: account, state: .Empty)
213213
let icon = theme.icons.deletedAccount
214-
self.setSignal(generateEmptyPhoto(updatedSize, type: .icon(colors: theme.colors.peerColors(Int(peer.id.id % 7)), icon: icon, iconSize: icon.backingSize.aspectFitted(NSMakeSize(min(50, updatedSize.width - 20), min(updatedSize.height - 20, 50))), cornerRadius: nil)) |> map {($0, false)})
214+
self.setSignal(generateEmptyPhoto(updatedSize, type: .icon(colors: theme.colors.peerColors(Int(peer.id.id._internalGetInt32Value() % 7)), icon: icon, iconSize: icon.backingSize.aspectFitted(NSMakeSize(min(50, updatedSize.width - 20), min(updatedSize.height - 20, 50))), cornerRadius: nil)) |> map {($0, false)})
215215
return
216216
} else {
217217
photo = .peer(peer, representation, letters, message)

‎Telegram-Mac/CachedAdminIds.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CachedAdminIds: NSObject {
6666

6767
self.disposableTokens[peerId] = signal.start(next: { ids in
6868
idsContexts.ids = ids
69-
idsContexts.hash = hashForIdsReverse(ids.map({$0.id}))
69+
idsContexts.hash = hashForIdsReverse(ids.map { $0.id._internalGetInt32Value() } )
7070
for subscriber in idsContexts.subscribers.copyItems() {
7171
subscriber(idsContexts.ids)
7272
}

‎Telegram-Mac/CallRatingModalViewController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ class CallRatingModalViewController: ModalViewController {
157157

158158

159159
func rateCallAndSendLogs(account: Account, callId: CallId, starsCount: Int, comment: String, userInitiated: Bool, includeLogs: Bool) -> Signal<Void, NoError> {
160-
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 4244000)
160+
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(4244000))
161161

162162
let rate = rateCall(account: account, callId: callId, starsCount: Int32(starsCount), comment: comment, userInitiated: userInitiated)
163163
if includeLogs {

‎Telegram-Mac/ChannelEventLogItem.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ class ServiceEventLogItem: TableRowItem {
241241
if chatInteraction.context.peerId == peer.id {
242242
nameColor = theme.colors.link
243243
} else {
244-
let value = abs(Int(peer.id.id) % 7)
244+
let value = abs(Int(peer.id.id._internalGetInt32Value()) % 7)
245245
nameColor = theme.chat.peerName(value)
246246
}
247247

‎Telegram-Mac/ChannelMemberCategoryListContext.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ private final class ChannelMemberSingleCategoryListContext: ChannelMemberCategor
312312

313313
for i in 0 ..< min(strongSelf.listStateValue.list.count, Int(initialBatchSize)) {
314314
let peerId = strongSelf.listStateValue.list[i].peer.id
315-
hash = (hash &* 20261) &+ UInt32(peerId.id)
315+
hash = (hash &* 20261) &+ UInt32(bitPattern: peerId.id._internalGetInt32Value())
316316
}
317317
hash = hash % 0x7FFFFFFF
318318
strongSelf.headUpdateDisposable.set((strongSelf.loadSignal(offset: 0, count: initialBatchSize, hash: Int32(bitPattern: hash))

‎Telegram-Mac/ChatContactRowItem.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ class ChatContactRowItem: ChatRowItem {
5252
phoneLayout = TextViewLayout(.initialize(string: formatPhoneNumber(contact.phoneNumber), color: theme.chat.textColor(isIncoming, object.renderType == .bubble), font: .normal(.text)), maximumNumberOfLines: 1, truncationType: .end, alignment: .left)
5353

5454
} else {
55-
self.contactPeer = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: 0), accessHash: nil, firstName: name.components(separatedBy: " ").first ?? name, lastName: name.components(separatedBy: " ").count == 2 ? name.components(separatedBy: " ").last : "", username: nil, phone: contact.phoneNumber, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
55+
self.contactPeer = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: name.components(separatedBy: " ").first ?? name, lastName: name.components(separatedBy: " ").count == 2 ? name.components(separatedBy: " ").last : "", username: nil, phone: contact.phoneNumber, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
5656
_ = attr.append(string: name, color: theme.chat.textColor(isIncoming, object.renderType == .bubble), font: .medium(.text))
5757

5858
phoneLayout = TextViewLayout(.initialize(string: formatPhoneNumber(contact.phoneNumber), color: theme.chat.textColor(isIncoming, object.renderType == .bubble), font: .normal(.text)), maximumNumberOfLines: 1, truncationType: .end, alignment: .left)

‎Telegram-Mac/ChatController.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -2384,7 +2384,7 @@ class ChatController: EditableViewController<ChatControllerView>, Notifable, Tab
23842384
if peer.addressName == nil {
23852385
let state = strongSelf.chatInteraction.presentation.effectiveInput
23862386
var attributes = state.attributes
2387-
attributes.append(.uid(range.lowerBound ..< range.upperBound - 1, peer.id.id))
2387+
attributes.append(.uid(range.lowerBound ..< range.upperBound - 1, peer.id.id._internalGetInt32Value()))
23882388
let updatedState = ChatTextInputState(inputText: state.inputText, selectionRange: state.selectionRange, attributes: attributes)
23892389
strongSelf.chatInteraction.update({$0.withUpdatedEffectiveInputState(updatedState)})
23902390
}

‎Telegram-Mac/ChatInterfaceState.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -144,7 +144,7 @@ func chatTextAttributes(from entities:TextEntitiesMessageAttribute) -> [ChatText
144144
case .Pre:
145145
inputAttributes.append(.pre(entity.range))
146146
case let .TextMention(peerId: peerId):
147-
inputAttributes.append(.uid(entity.range, peerId.id))
147+
inputAttributes.append(.uid(entity.range, peerId.id._internalGetInt32Value()))
148148
case let .TextUrl(url):
149149
inputAttributes.append(.url(entity.range, url))
150150
case .Strikethrough:
@@ -503,7 +503,7 @@ final class ChatTextInputState: PostboxCoding, Equatable {
503503
case let .code(range):
504504
entities.append(.init(range: range, type: .Code))
505505
case let .uid(range, uid):
506-
entities.append(.init(range: range, type: .TextMention(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: uid))))
506+
entities.append(.init(range: range, type: .TextMention(peerId: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(uid)))))
507507
case let .url(range, url):
508508
entities.append(.init(range: range, type: .TextUrl(url: url)))
509509
}

‎Telegram-Mac/ChatListFilterController.swift

+12-12
Original file line numberDiff line numberDiff line change
@@ -521,15 +521,15 @@ func ChatListFilterController(context: AccountContext, filter: ChatListFilter, i
521521
var state = state
522522

523523
let categories = peerIds.filter {
524-
$0.namespace == ChatListFilterPeerCategories.Namespace
524+
$0.namespace._internalGetInt32Value() == ChatListFilterPeerCategories.Namespace
525525
}
526526
let peerIds = Set(peerIds).subtracting(categories)
527527

528528
state.withUpdatedFilter { filter in
529529
var filter = filter
530530
filter.data.includePeers.setPeers(Array(peerIds.uniqueElements.prefix(maximumPeers)))
531531
var updatedCats: ChatListFilterPeerCategories = []
532-
let cats = categories.map { ChatListFilterPeerCategories(rawValue: $0.id) }
532+
let cats = categories.map { ChatListFilterPeerCategories(rawValue: $0.id._internalGetInt32Value()) }
533533
for cat in cats {
534534
updatedCats.insert(cat)
535535
}
@@ -553,18 +553,18 @@ func ChatListFilterController(context: AccountContext, filter: ChatListFilter, i
553553
var filter = filter
554554

555555
let categories = peerIds.filter {
556-
$0.namespace == ChatListFilterPeerCategories.Namespace
556+
$0.namespace._internalGetInt32Value() == ChatListFilterPeerCategories.Namespace
557557
}
558558
let peerIds = Set(peerIds).subtracting(categories)
559559
filter.data.excludePeers = Array(peerIds.uniqueElements.prefix(maximumPeers))
560560
for cat in categories {
561-
if ChatListFilterPeerCategories(rawValue: cat.id) == .excludeMuted {
561+
if ChatListFilterPeerCategories(rawValue: cat.id._internalGetInt32Value()) == .excludeMuted {
562562
filter.data.excludeMuted = true
563563
}
564-
if ChatListFilterPeerCategories(rawValue: cat.id) == .excludeRead {
564+
if ChatListFilterPeerCategories(rawValue: cat.id._internalGetInt32Value()) == .excludeRead {
565565
filter.data.excludeRead = true
566566
}
567-
if ChatListFilterPeerCategories(rawValue: cat.id) == .excludeArchived {
567+
if ChatListFilterPeerCategories(rawValue: cat.id._internalGetInt32Value()) == .excludeArchived {
568568
filter.data.excludeArchived = true
569569
}
570570
}
@@ -584,8 +584,8 @@ func ChatListFilterController(context: AccountContext, filter: ChatListFilter, i
584584
var peers = filter.data.includePeers.peers
585585
peers.removeAll(where: { $0 == peerId })
586586
filter.data.includePeers.setPeers(peers)
587-
if peerId.namespace == ChatListFilterPeerCategories.Namespace {
588-
filter.data.categories.remove(ChatListFilterPeerCategories(rawValue: peerId.id))
587+
if peerId.namespace._internalGetInt32Value() == ChatListFilterPeerCategories.Namespace {
588+
filter.data.categories.remove(ChatListFilterPeerCategories(rawValue: peerId.id._internalGetInt32Value()))
589589
}
590590
return filter
591591
}
@@ -600,14 +600,14 @@ func ChatListFilterController(context: AccountContext, filter: ChatListFilter, i
600600
var peers = filter.data.excludePeers
601601
peers.removeAll(where: { $0 == peerId })
602602
filter.data.excludePeers = peers
603-
if peerId.namespace == ChatListFilterPeerCategories.Namespace {
604-
if ChatListFilterPeerCategories(rawValue: peerId.id) == .excludeMuted {
603+
if peerId.namespace._internalGetInt32Value() == ChatListFilterPeerCategories.Namespace {
604+
if ChatListFilterPeerCategories(rawValue: peerId.id._internalGetInt32Value()) == .excludeMuted {
605605
filter.data.excludeMuted = false
606606
}
607-
if ChatListFilterPeerCategories(rawValue: peerId.id) == .excludeRead {
607+
if ChatListFilterPeerCategories(rawValue: peerId.id._internalGetInt32Value()) == .excludeRead {
608608
filter.data.excludeRead = false
609609
}
610-
if ChatListFilterPeerCategories(rawValue: peerId.id) == .excludeArchived {
610+
if ChatListFilterPeerCategories(rawValue: peerId.id._internalGetInt32Value()) == .excludeArchived {
611611
filter.data.excludeArchived = false
612612
}
613613
}

‎Telegram-Mac/ChatListRowItem.swift

+5-3
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ class ChatListRowItem: TableRowItem {
239239
if case .ad = pinnedType {
240240
return false
241241
}
242-
let supportId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 777000)
242+
let supportId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000))
243243
if self.peer?.id == supportId {
244244
return false
245245
}
@@ -477,7 +477,8 @@ class ChatListRowItem: TableRowItem {
477477
embeddedState = nil
478478
}
479479
}
480-
let supportId = PeerId(namespace: Namespaces.Peer.CloudUser, id: 777000)
480+
481+
let supportId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(777000))
481482

482483
if let peerPresence = peerPresence, context.peerId != renderedPeer.peerId, renderedPeer.peerId != supportId {
483484
if let peerPresence = peerPresence as? TelegramUserPresence {
@@ -578,7 +579,8 @@ class ChatListRowItem: TableRowItem {
578579
if let peer = info.author {
579580
author = peer
580581
} else if let signature = info.authorSignature {
581-
author = TelegramUser(id: PeerId(namespace: 0, id: 0), accessHash: nil, firstName: signature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
582+
583+
author = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: signature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
582584
}
583585
} else {
584586
author = message.author

‎Telegram-Mac/ChatMediaContentView.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -253,7 +253,7 @@ class ChatMediaContentView: Control, NSDraggingSource, NSPasteboardItemDataProvi
253253
mouseDownPoint = convert(event.locationInWindow, from: nil)
254254
acceptDragging = draggingAbility(event) && parent != nil && !parent!.containsSecretMedia
255255

256-
if let parent = parent, parent.id.peerId.id == Namespaces.Peer.SecretChat {
256+
if let parent = parent, parent.id.peerId.namespace == Namespaces.Peer.SecretChat {
257257
acceptDragging = false
258258
}
259259
}

‎Telegram-Mac/ChatRowItem.swift

+5-4
Original file line numberDiff line numberDiff line change
@@ -1409,13 +1409,14 @@ class ChatRowItem: TableRowItem {
14091409
if let author = info.author {
14101410
self.peer = author
14111411
} else if let signature = info.authorSignature {
1412-
self.peer = TelegramUser(id: PeerId(namespace: 0, id: 0), accessHash: nil, firstName: signature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
1412+
1413+
self.peer = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: signature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
14131414
} else {
14141415
self.peer = message.chatPeer(context.peerId)
14151416
}
14161417
} else if let info = message.forwardInfo, chatInteraction.peerId == context.account.peerId || (object.renderType == .list && info.psaType != nil) {
14171418
if info.author == nil, let signature = info.authorSignature {
1418-
self.peer = TelegramUser(id: PeerId(namespace: 0, id: 0), accessHash: nil, firstName: signature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
1419+
self.peer = TelegramUser(id: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt32Value(0)), accessHash: nil, firstName: signature, lastName: nil, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
14191420
} else if (object.renderType == .list && info.psaType != nil) {
14201421
self.peer = info.author ?? message.chatPeer(context.peerId)
14211422
} else {
@@ -1640,7 +1641,7 @@ class ChatRowItem: TableRowItem {
16401641
if object.renderType == .bubble, message.isAnonymousMessage, !isIncoming {
16411642
nameColor = presentation.colors.accentIconBubble_outgoing
16421643
} else {
1643-
let value = abs(Int(peer.id.id) % 7)
1644+
let value = abs(Int(peer.id.id._internalGetInt32Value()) % 7)
16441645
nameColor = presentation.chat.peerName(value)
16451646
}
16461647
}
@@ -1652,7 +1653,7 @@ class ChatRowItem: TableRowItem {
16521653

16531654
if canFillAuthorName {
16541655
let range = attr.append(string: title, color: nameColor, font: .medium(.text))
1655-
if peer.id.id != 0 {
1656+
if peer.id.id._internalGetInt32Value() != 0 {
16561657
attr.addAttribute(NSAttributedString.Key.link, value: inAppLink.peerInfo(link: "", peerId:peer.id, action:nil, openChat: peer.isChannel, postId: nil, callback: chatInteraction.openInfo), range: range)
16571658
} else {
16581659
nameHide = L10n.chatTooltipHiddenForwardName

‎Telegram-Mac/ChatServiceItem.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class ChatServiceItem: ChatRowItem {
4747
if let peer = messageMainPeer(message) as? TelegramChannel, case .broadcast(_) = peer.info {
4848
return theme.chat.linkColor(isIncoming, entry.renderType == .bubble)
4949
} else if context.peerId != peerId {
50-
let value = abs(Int(peerId.id) % 7)
50+
let value = abs(Int(peerId.id._internalGetInt32Value()) % 7)
5151
return theme.chat.peerName(value)
5252
}
5353
}

‎Telegram-Mac/ContextSearchMessageItem.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ class ContextSearchMessageItem: GeneralRowItem {
7070
if let peer = messageMainPeer(message) as? TelegramChannel, case .broadcast(_) = peer.info {
7171
nameColor = theme.chat.linkColor(true, false)
7272
} else if context.peerId != peer.id {
73-
let value = abs(Int(peer.id.id) % 7)
73+
let value = abs(Int(peer.id.id._internalGetInt32Value()) % 7)
7474
nameColor = theme.chat.peerName(value)
7575
}
7676
}

‎Telegram-Mac/CoreExtension.swift

+1-1
Original file line numberDiff line numberDiff line change
@@ -791,7 +791,7 @@ extension SuggestedLocalizationInfo {
791791

792792
public extension MessageId {
793793
func toInt64() -> Int64 {
794-
return (Int64(id) << 32) | Int64(peerId.id)
794+
return (Int64(id) << 32) | Int64(peerId.id._internalGetInt32Value())
795795
}
796796
}
797797

‎Telegram-Mac/ImageUtils.swift

+2-2
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ private func peerImage(account: Account, peer: Peer, displayDimensions: NSSize,
117117
}
118118

119119

120-
let color = theme.colors.peerColors(Int(abs(peer.id.id % 7)))
120+
let color = theme.colors.peerColors(Int(abs(peer.id.id._internalGetInt32Value() % 7)))
121121

122122

123123
let symbol = letters.reduce("", { (current, letter) -> String in
@@ -278,7 +278,7 @@ func generateEmptyRoundAvatar(_ displayDimensions:NSSize, font: NSFont, account:
278278
return Signal { subscriber in
279279
let letters = peer.displayLetters
280280

281-
let color = theme.colors.peerColors(Int(abs(peer.id.id % 7)))
281+
let color = theme.colors.peerColors(Int(abs(peer.id.id._internalGetInt32Value() % 7)))
282282

283283
let image = generateImage(displayDimensions, contextGenerator: { (size, ctx) in
284284
ctx.clear(NSMakeRect(0, 0, size.width, size.height))

0 commit comments

Comments
 (0)