Refactoring
This commit is contained in:
parent
8b7959710c
commit
6e5c503338
164 changed files with 786 additions and 1208 deletions
|
|
@ -1,18 +1,17 @@
|
|||
import Foundation
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
|
||||
public protocol LiveLocationSummaryManager {
|
||||
func broadcastingToMessages() -> Signal<[MessageId: Message], NoError>
|
||||
func peersBroadcastingTo(peerId: PeerId) -> Signal<[(Peer, Message)]?, NoError>
|
||||
func broadcastingToMessages() -> Signal<[EngineMessage.Id: EngineMessage], NoError>
|
||||
func peersBroadcastingTo(peerId: EnginePeer.Id) -> Signal<[(EnginePeer, EngineMessage)]?, NoError>
|
||||
}
|
||||
|
||||
public protocol LiveLocationManager {
|
||||
var summaryManager: LiveLocationSummaryManager { get }
|
||||
var isPolling: Signal<Bool, NoError> { get }
|
||||
|
||||
func cancelLiveLocation(peerId: PeerId)
|
||||
func cancelLiveLocation(peerId: EnginePeer.Id)
|
||||
func pollOnce()
|
||||
func internalMessageForPeerId(_ peerId: PeerId) -> MessageId?
|
||||
func internalMessageForPeerId(_ peerId: EnginePeer.Id) -> EngineMessage.Id?
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ swift_library(
|
|||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/TelegramUIPreferences:TelegramUIPreferences",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ swift_library(
|
|||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import AsyncDisplayKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import ActivityIndicator
|
||||
|
|
@ -20,8 +19,8 @@ private struct ArchivedStickersNoticeEntry: Comparable, Identifiable {
|
|||
let topItem: StickerPackItem?
|
||||
let count: String
|
||||
|
||||
var stableId: ItemCollectionId {
|
||||
return info.id
|
||||
var stableId: AnyHashable {
|
||||
return AnyHashable(self.info.id)
|
||||
}
|
||||
|
||||
static func ==(lhs: ArchivedStickersNoticeEntry, rhs: ArchivedStickersNoticeEntry) -> Bool {
|
||||
|
|
|
|||
|
|
@ -448,7 +448,7 @@ public final class CallListController: TelegramBaseController {
|
|||
if let cachedUserData = view.cachedData as? CachedUserData, cachedUserData.callsPrivate {
|
||||
let presentationData = strongSelf.context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
strongSelf.present(textAlertController(context: strongSelf.context, title: presentationData.strings.Call_ConnectionErrorTitle, text: presentationData.strings.Call_PrivacyErrorMessage(peer.compactDisplayTitle).string, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
strongSelf.present(textAlertController(context: strongSelf.context, title: presentationData.strings.Call_ConnectionErrorTitle, text: presentationData.strings.Call_PrivacyErrorMessage(EnginePeer(peer).compactDisplayTitle).string, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
return
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
|
|||
}
|
||||
|> deliverOnMainQueue).start(completed: {
|
||||
c.dismiss(completion: {
|
||||
chatListController?.present(UndoOverlayController(presentationData: presentationData, content: .chatRemovedFromFolder(chatTitle: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), folderTitle: currentFilter.title), elevatedLayout: false, animateInAsReplacement: true, action: { _ in
|
||||
chatListController?.present(UndoOverlayController(presentationData: presentationData, content: .chatRemovedFromFolder(chatTitle: EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), folderTitle: currentFilter.title), elevatedLayout: false, animateInAsReplacement: true, action: { _ in
|
||||
return false
|
||||
}), in: .current)
|
||||
})
|
||||
|
|
@ -239,7 +239,7 @@ func chatContextMenuItems(context: AccountContext, peerId: PeerId, promoInfo: Ch
|
|||
return filters
|
||||
}).start()
|
||||
|
||||
chatListController?.present(UndoOverlayController(presentationData: presentationData, content: .chatAddedToFolder(chatTitle: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), folderTitle: filter.title), elevatedLayout: false, animateInAsReplacement: true, action: { _ in
|
||||
chatListController?.present(UndoOverlayController(presentationData: presentationData, content: .chatAddedToFolder(chatTitle: EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), folderTitle: filter.title), elevatedLayout: false, animateInAsReplacement: true, action: { _ in
|
||||
return false
|
||||
}), in: .current)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -2338,7 +2338,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||
beginClear(.forLocalPeer)
|
||||
actionSheet?.dismissAnimated()
|
||||
}))
|
||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.ChatList_DeleteForEveryone(mainPeer.compactDisplayTitle).string, color: .destructive, action: { [weak actionSheet] in
|
||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.ChatList_DeleteForEveryone(EnginePeer(mainPeer).compactDisplayTitle).string, color: .destructive, action: { [weak actionSheet] in
|
||||
beginClear(.forEveryone)
|
||||
actionSheet?.dismissAnimated()
|
||||
}))
|
||||
|
|
@ -2367,7 +2367,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||
}
|
||||
|
||||
if chatPeer is TelegramSecretChat {
|
||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.ChatList_DeleteForEveryone(mainPeer.compactDisplayTitle).string, color: .destructive, action: { [weak actionSheet] in
|
||||
items.append(ActionSheetButtonItem(title: strongSelf.presentationData.strings.ChatList_DeleteForEveryone(EnginePeer(mainPeer).compactDisplayTitle).string, color: .destructive, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
|
|
@ -2509,7 +2509,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
|||
})
|
||||
completion(true)
|
||||
}))
|
||||
items.append(ActionSheetButtonItem(title: self.presentationData.strings.ChatList_DeleteForEveryone(mainPeer.compactDisplayTitle).string, color: .destructive, action: { [weak self, weak actionSheet] in
|
||||
items.append(ActionSheetButtonItem(title: self.presentationData.strings.ChatList_DeleteForEveryone(EnginePeer(mainPeer).compactDisplayTitle).string, color: .destructive, action: { [weak self, weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
guard let strongSelf = self else {
|
||||
return
|
||||
|
|
|
|||
|
|
@ -389,7 +389,7 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry {
|
|||
}
|
||||
)
|
||||
case let .includePeer(_, peer, isRevealed):
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: peer.chatMainPeer!, height: .peerList, aliasHandling: .threatSelfAsSaved, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: isRevealed), revealOptions: ItemListPeerItemRevealOptions(options: [ItemListPeerItemRevealOption(type: .destructive, title: presentationData.strings.Common_Delete, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: EnginePeer(peer.chatMainPeer!), height: .peerList, aliasHandling: .threatSelfAsSaved, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: isRevealed), revealOptions: ItemListPeerItemRevealOptions(options: [ItemListPeerItemRevealOption(type: .destructive, title: presentationData.strings.Common_Delete, action: {
|
||||
arguments.deleteIncludePeer(peer.peerId)
|
||||
})]), switchValue: nil, enabled: true, selectable: false, sectionId: self.section, action: nil, setPeerIdWithRevealedOptions: { lhs, rhs in
|
||||
arguments.setItemIdWithRevealedOptions(lhs.flatMap { .peer($0) }, rhs.flatMap { .peer($0) })
|
||||
|
|
@ -397,7 +397,7 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry {
|
|||
arguments.deleteIncludePeer(id)
|
||||
})
|
||||
case let .excludePeer(_, peer, isRevealed):
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: peer.chatMainPeer!, height: .peerList, aliasHandling: .threatSelfAsSaved, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: isRevealed), revealOptions: ItemListPeerItemRevealOptions(options: [ItemListPeerItemRevealOption(type: .destructive, title: presentationData.strings.Common_Delete, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: EnginePeer(peer.chatMainPeer!), height: .peerList, aliasHandling: .threatSelfAsSaved, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: isRevealed), revealOptions: ItemListPeerItemRevealOptions(options: [ItemListPeerItemRevealOption(type: .destructive, title: presentationData.strings.Common_Delete, action: {
|
||||
arguments.deleteExcludePeer(peer.peerId)
|
||||
})]), switchValue: nil, enabled: true, selectable: false, sectionId: self.section, action: nil, setPeerIdWithRevealedOptions: { lhs, rhs in
|
||||
arguments.setItemIdWithRevealedOptions(lhs.flatMap { .peer($0) }, rhs.flatMap { .peer($0) })
|
||||
|
|
|
|||
|
|
@ -362,8 +362,8 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||
isGroup = false
|
||||
}
|
||||
|
||||
var title: String = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
var compactDisplayTitle = peer.compactDisplayTitle
|
||||
var title: String = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
var compactDisplayTitle = EnginePeer(peer).compactDisplayTitle
|
||||
if peer.id == accountPeer?.id {
|
||||
title = presentationData.strings.DialogList_SavedMessages
|
||||
compactDisplayTitle = title
|
||||
|
|
@ -962,14 +962,14 @@ public final class ChatListSearchContainerNode: SearchDisplayControllerContentNo
|
|||
savedMessages = true
|
||||
} else {
|
||||
if displayPeers.count == 1, let peer = displayPeers.first {
|
||||
let peerName = peer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let peerName = peer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_Chat_One(peerName).string : presentationData.strings.Conversation_ForwardTooltip_Chat_Many(peerName).string
|
||||
} else if displayPeers.count == 2, let firstPeer = displayPeers.first, let secondPeer = displayPeers.last {
|
||||
let firstPeerName = firstPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : firstPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let secondPeerName = secondPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : secondPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let firstPeerName = firstPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(firstPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let secondPeerName = secondPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(secondPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_TwoChats_One(firstPeerName, secondPeerName).string : presentationData.strings.Conversation_ForwardTooltip_TwoChats_Many(firstPeerName, secondPeerName).string
|
||||
} else if let peer = displayPeers.first {
|
||||
let peerName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let peerName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_ManyChats_One(peerName, "\(displayPeers.count - 1)").string : presentationData.strings.Conversation_ForwardTooltip_ManyChats_Many(peerName, "\(displayPeers.count - 1)").string
|
||||
} else {
|
||||
text = ""
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ private enum ChatListRecentEntry: Comparable, Identifiable {
|
|||
status = .custom(string: strings.Bot_GenericBotStatus, multiline: false)
|
||||
} else if user.id != context.account.peerId && !servicePeer {
|
||||
let presence = peer.presence ?? TelegramUserPresence(status: .none, lastActivity: 0)
|
||||
status = .presence(presence, timeFormat)
|
||||
status = .presence(EnginePeer.Presence(presence), timeFormat)
|
||||
} else {
|
||||
status = .none
|
||||
}
|
||||
|
|
@ -194,7 +194,7 @@ private enum ChatListRecentEntry: Comparable, Identifiable {
|
|||
badge = ContactsPeerItemBadge(count: peer.unreadCount, type: isMuted ? .inactive : .active)
|
||||
}
|
||||
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(theme: presentationData.theme, fontSize: presentationData.fontSize, strings: presentationData.strings), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: status, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: ChatListSearchItemHeader(type: .recentPeers, theme: theme, strings: strings, actionTitle: strings.WebSearch_RecentSectionClear, action: {
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(theme: presentationData.theme, fontSize: presentationData.fontSize, strings: presentationData.strings), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: EnginePeer(primaryPeer), chatPeer: chatPeer.flatMap(EnginePeer.init)), status: status, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: ChatListSearchItemHeader(type: .recentPeers, theme: theme, strings: strings, actionTitle: strings.WebSearch_RecentSectionClear, action: {
|
||||
clearRecentlySearchedPeers()
|
||||
}), action: { _ in
|
||||
if let chatPeer = peer.peer.peers[peer.peer.peerId] {
|
||||
|
|
@ -441,9 +441,9 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
|
|||
})
|
||||
}
|
||||
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: primaryPeer, chatPeer: chatPeer), status: .none, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: EnginePeer(primaryPeer), chatPeer: chatPeer.flatMap(EnginePeer.init)), status: .none, badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { contactPeer in
|
||||
if case let .peer(maybePeer, maybeChatPeer) = contactPeer, let peer = maybePeer, let chatPeer = maybeChatPeer {
|
||||
interaction.peerSelected(chatPeer, peer, nil)
|
||||
interaction.peerSelected(chatPeer._asPeer(), peer._asPeer(), nil)
|
||||
} else {
|
||||
interaction.peerSelected(peer, nil, nil)
|
||||
}
|
||||
|
|
@ -508,7 +508,7 @@ public enum ChatListSearchEntry: Comparable, Identifiable {
|
|||
})
|
||||
}
|
||||
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: peer.peer, chatPeer: peer.peer), status: .addressName(suffixString), badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: EnginePeer(peer.peer), chatPeer: EnginePeer(peer.peer)), status: .addressName(suffixString), badge: badge, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in
|
||||
interaction.peerSelected(peer.peer, nil, nil)
|
||||
}, contextAction: peerContextAction.flatMap { peerContextAction in
|
||||
return { node, gesture in
|
||||
|
|
|
|||
|
|
@ -492,7 +492,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
if item.context.account.peerId == chatMainPeer.id {
|
||||
result += item.presentationData.strings.DialogList_SavedMessages
|
||||
} else {
|
||||
result += chatMainPeer.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
result += EnginePeer(chatMainPeer).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
}
|
||||
if let combinedReadState = combinedReadState, combinedReadState.count > 0 {
|
||||
result += "\n\(item.presentationData.strings.VoiceOver_Chat_UnreadMessages(combinedReadState.count))"
|
||||
|
|
@ -520,7 +520,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
}
|
||||
let (_, initialHideAuthor, messageText) = chatListItemStrings(strings: item.presentationData.strings, nameDisplayOrder: item.presentationData.nameDisplayOrder, dateTimeFormat: item.presentationData.dateTimeFormat, messages: messages, chatPeer: peer, accountPeerId: item.context.account.peerId, isPeerGroup: false)
|
||||
if message.flags.contains(.Incoming), !initialHideAuthor, let author = message.author, author is TelegramUser {
|
||||
result += "\n\(item.presentationData.strings.VoiceOver_ChatList_MessageFrom(author.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)).string)"
|
||||
result += "\n\(item.presentationData.strings.VoiceOver_ChatList_MessageFrom(EnginePeer(author).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)).string)"
|
||||
}
|
||||
result += "\n\(messageText)"
|
||||
return result
|
||||
|
|
@ -529,7 +529,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
var isFirst = true
|
||||
for peer in peers {
|
||||
if let chatMainPeer = peer.peer.chatMainPeer {
|
||||
let peerTitle = chatMainPeer.compactDisplayTitle
|
||||
let peerTitle = EnginePeer(chatMainPeer).compactDisplayTitle
|
||||
if !peerTitle.isEmpty {
|
||||
if isFirst {
|
||||
isFirst = false
|
||||
|
|
@ -554,7 +554,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
}
|
||||
let (_, initialHideAuthor, messageText) = chatListItemStrings(strings: item.presentationData.strings, nameDisplayOrder: item.presentationData.nameDisplayOrder, dateTimeFormat: item.presentationData.dateTimeFormat, messages: messages, chatPeer: peer, accountPeerId: item.context.account.peerId, isPeerGroup: false)
|
||||
if message.flags.contains(.Incoming), !initialHideAuthor, let author = message.author, author is TelegramUser {
|
||||
result += "\n\(item.presentationData.strings.VoiceOver_ChatList_MessageFrom(author.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)).string)"
|
||||
result += "\n\(item.presentationData.strings.VoiceOver_ChatList_MessageFrom(EnginePeer(author).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)).string)"
|
||||
}
|
||||
if !message.flags.contains(.Incoming), let combinedReadState = combinedReadState, combinedReadState.isOutgoingMessageIndexRead(message.index) {
|
||||
result += "\n\(item.presentationData.strings.VoiceOver_ChatList_MessageRead)"
|
||||
|
|
@ -981,7 +981,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
if author.id == item.context.account.peerId {
|
||||
inlineAuthorPrefix = item.presentationData.strings.DialogList_You
|
||||
} else if messages.last?.id.peerId.namespace != Namespaces.Peer.CloudUser && messages.last?.id.peerId.namespace != Namespaces.Peer.SecretChat {
|
||||
inlineAuthorPrefix = author.compactDisplayTitle
|
||||
inlineAuthorPrefix = EnginePeer(author).compactDisplayTitle
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1000,7 +1000,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
var peerText: String?
|
||||
if case .groupReference = item.content {
|
||||
if let messagePeer = itemPeer.chatMainPeer {
|
||||
peerText = messagePeer.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
peerText = EnginePeer(messagePeer).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
}
|
||||
} else if let message = messages.last, let author = message.author as? TelegramUser, let peer = itemPeer.chatMainPeer, !(peer is TelegramUser) {
|
||||
if let peer = peer as? TelegramChannel, case .broadcast = peer.info {
|
||||
|
|
@ -1008,7 +1008,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
if let forwardInfo = message.forwardInfo, forwardInfo.flags.contains(.isImported), let authorSignature = forwardInfo.authorSignature {
|
||||
peerText = authorSignature
|
||||
} else {
|
||||
peerText = author.id == account.peerId ? item.presentationData.strings.DialogList_You : author.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
peerText = author.id == account.peerId ? item.presentationData.strings.DialogList_You : EnginePeer(author).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1137,7 +1137,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
var peerText: String?
|
||||
if case .groupReference = item.content {
|
||||
if let messagePeer = itemPeer.chatMainPeer {
|
||||
peerText = messagePeer.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
peerText = EnginePeer(messagePeer).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -1150,7 +1150,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
var isFirst = true
|
||||
for peer in peers {
|
||||
if let chatMainPeer = peer.peer.chatMainPeer {
|
||||
let peerTitle = chatMainPeer.compactDisplayTitle
|
||||
let peerTitle = EnginePeer(chatMainPeer).compactDisplayTitle
|
||||
if !peerTitle.isEmpty {
|
||||
if isFirst {
|
||||
isFirst = false
|
||||
|
|
@ -1177,14 +1177,14 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
switch contentData {
|
||||
case let .chat(itemPeer, _, _, _):
|
||||
if let message = messages.last, let author = message.author as? TelegramUser, displayAsMessage {
|
||||
titleAttributedString = NSAttributedString(string: author.id == account.peerId ? item.presentationData.strings.DialogList_You : author.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder), font: titleFont, textColor: theme.titleColor)
|
||||
titleAttributedString = NSAttributedString(string: author.id == account.peerId ? item.presentationData.strings.DialogList_You : EnginePeer(author).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder), font: titleFont, textColor: theme.titleColor)
|
||||
} else if isPeerGroup {
|
||||
titleAttributedString = NSAttributedString(string: item.presentationData.strings.ChatList_ArchivedChatsTitle, font: titleFont, textColor: theme.titleColor)
|
||||
} else if itemPeer.chatMainPeer?.id == item.context.account.peerId {
|
||||
titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_SavedMessages, font: titleFont, textColor: theme.titleColor)
|
||||
} else if let id = itemPeer.chatMainPeer?.id, id.isReplies {
|
||||
titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_Replies, font: titleFont, textColor: theme.titleColor)
|
||||
} else if let displayTitle = itemPeer.chatMainPeer?.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder) {
|
||||
} else if let displayTitle = itemPeer.chatMainPeer.flatMap(EnginePeer.init)?.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder) {
|
||||
titleAttributedString = NSAttributedString(string: displayTitle, font: titleFont, textColor: item.index.messageIndex.id.peerId.namespace == Namespaces.Peer.SecretChat ? theme.secretTitleColor : theme.titleColor)
|
||||
}
|
||||
case .group:
|
||||
|
|
@ -1865,7 +1865,7 @@ class ChatListItemNode: ItemListRevealOptionsItemNode {
|
|||
strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: layoutOffset - separatorHeight - topNegativeInset), size: CGSize(width: layout.contentSize.width, height: layout.contentSize.height + separatorHeight + topNegativeInset))
|
||||
|
||||
if let peerPresence = peerPresence as? TelegramUserPresence {
|
||||
strongSelf.peerPresenceManager?.reset(presence: TelegramUserPresence(status: peerPresence.status, lastActivity: 0), isOnline: online)
|
||||
strongSelf.peerPresenceManager?.reset(presence: EnginePeer.Presence(TelegramUserPresence(status: peerPresence.status, lastActivity: 0)), isOnline: online)
|
||||
}
|
||||
|
||||
strongSelf.updateLayout(size: layout.contentSize, leftInset: params.leftInset, rightInset: params.rightInset)
|
||||
|
|
|
|||
|
|
@ -287,16 +287,16 @@ public func chatListItemStrings(strings: PresentationStrings, nameDisplayOrder:
|
|||
case .active:
|
||||
switch secretChat.role {
|
||||
case .creator:
|
||||
messageText = strings.DialogList_EncryptedChatStartedOutgoing(peer?.compactDisplayTitle ?? "").string
|
||||
messageText = strings.DialogList_EncryptedChatStartedOutgoing(peer.flatMap(EnginePeer.init)?.compactDisplayTitle ?? "").string
|
||||
case .participant:
|
||||
messageText = strings.DialogList_EncryptedChatStartedIncoming(peer?.compactDisplayTitle ?? "").string
|
||||
messageText = strings.DialogList_EncryptedChatStartedIncoming(peer.flatMap(EnginePeer.init)?.compactDisplayTitle ?? "").string
|
||||
}
|
||||
case .terminated:
|
||||
messageText = strings.DialogList_EncryptionRejected
|
||||
case .handshake:
|
||||
switch secretChat.role {
|
||||
case .creator:
|
||||
messageText = strings.DialogList_AwaitingEncryption(peer?.compactDisplayTitle ?? "").string
|
||||
messageText = strings.DialogList_AwaitingEncryption(peer.flatMap(EnginePeer.init)?.compactDisplayTitle ?? "").string
|
||||
case .participant:
|
||||
messageText = strings.DialogList_EncryptionProcessing
|
||||
}
|
||||
|
|
|
|||
|
|
@ -309,7 +309,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
|
|||
}
|
||||
}
|
||||
|
||||
return ListViewInsertItem(index: entry.index, previousIndex: entry.previousIndex, item: ContactsPeerItem(presentationData: ItemListPresentationData(theme: presentationData.theme, fontSize: presentationData.fontSize, strings: presentationData.strings), sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: itemPeer, chatPeer: chatPeer), status: status, enabled: enabled, selection: editing ? .selectable(selected: selected) : .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in
|
||||
return ListViewInsertItem(index: entry.index, previousIndex: entry.previousIndex, item: ContactsPeerItem(presentationData: ItemListPresentationData(theme: presentationData.theme, fontSize: presentationData.fontSize, strings: presentationData.strings), sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: itemPeer.flatMap(EnginePeer.init), chatPeer: chatPeer.flatMap(EnginePeer.init)), status: status, enabled: enabled, selection: editing ? .selectable(selected: selected) : .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in
|
||||
if let chatPeer = chatPeer {
|
||||
if editing {
|
||||
nodeInteraction.togglePeerSelected(chatPeer)
|
||||
|
|
@ -390,7 +390,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
|
|||
}
|
||||
}
|
||||
|
||||
return ListViewUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: ContactsPeerItem(presentationData: ItemListPresentationData(theme: presentationData.theme, fontSize: presentationData.fontSize, strings: presentationData.strings), sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: itemPeer, chatPeer: chatPeer), status: status, enabled: enabled, selection: editing ? .selectable(selected: selected) : .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in
|
||||
return ListViewUpdateItem(index: entry.index, previousIndex: entry.previousIndex, item: ContactsPeerItem(presentationData: ItemListPresentationData(theme: presentationData.theme, fontSize: presentationData.fontSize, strings: presentationData.strings), sortOrder: presentationData.nameSortOrder, displayOrder: presentationData.nameDisplayOrder, context: context, peerMode: .generalSearch, peer: .peer(peer: itemPeer.flatMap(EnginePeer.init), chatPeer: chatPeer.flatMap(EnginePeer.init)), status: status, enabled: enabled, selection: editing ? .selectable(selected: selected) : .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: header, action: { _ in
|
||||
if let chatPeer = chatPeer {
|
||||
if editing {
|
||||
nodeInteraction.togglePeerSelected(chatPeer)
|
||||
|
|
|
|||
|
|
@ -87,7 +87,7 @@ final class ChatListInputActivitiesNode: ASDisplayNode {
|
|||
} else {
|
||||
let text: String
|
||||
if let _ = commonKey {
|
||||
let peerTitle = activities[0].0.compactDisplayTitle
|
||||
let peerTitle = EnginePeer(activities[0].0).compactDisplayTitle
|
||||
switch activities[0].1 {
|
||||
case .uploadingVideo:
|
||||
text = strings.DialogList_SingleUploadingVideoSuffix(peerTitle).string
|
||||
|
|
@ -111,7 +111,7 @@ final class ChatListInputActivitiesNode: ASDisplayNode {
|
|||
text = ""
|
||||
}
|
||||
} else {
|
||||
text = activities[0].0.compactDisplayTitle
|
||||
text = EnginePeer(activities[0].0).compactDisplayTitle
|
||||
}
|
||||
let string = NSAttributedString(string: text, font: textFont, textColor: color)
|
||||
|
||||
|
|
@ -137,9 +137,9 @@ final class ChatListInputActivitiesNode: ASDisplayNode {
|
|||
} else {
|
||||
let string: NSAttributedString
|
||||
if activities.count > 1 {
|
||||
let peerTitle = activities[0].0.compactDisplayTitle
|
||||
let peerTitle = EnginePeer(activities[0].0).compactDisplayTitle
|
||||
if activities.count == 2 {
|
||||
let secondPeerTitle = activities[1].0.compactDisplayTitle
|
||||
let secondPeerTitle = EnginePeer(activities[1].0).compactDisplayTitle
|
||||
string = NSAttributedString(string: strings.DialogList_MultipleTypingPair(peerTitle, secondPeerTitle).string, font: textFont, textColor: color)
|
||||
} else {
|
||||
string = NSAttributedString(string: strings.DialogList_MultipleTyping(peerTitle, strings.DialogList_MultipleTypingSuffix(activities.count - 1).string).string, font: textFont, textColor: color)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ swift_library(
|
|||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/ItemListUI:ItemListUI",
|
||||
|
|
|
|||
|
|
@ -10,7 +10,6 @@ import AccountContext
|
|||
import AlertUI
|
||||
import PresentationDataUtils
|
||||
import TextFormat
|
||||
import Postbox
|
||||
|
||||
private struct OrderedLinkedListItemOrderingId: RawRepresentable, Hashable {
|
||||
var rawValue: Int
|
||||
|
|
@ -483,7 +482,36 @@ private func createPollControllerEntries(presentationData: PresentationData, pee
|
|||
return entries
|
||||
}
|
||||
|
||||
public func createPollController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peer: EnginePeer, isQuiz: Bool? = nil, completion: @escaping (EnqueueMessage) -> Void) -> ViewController {
|
||||
public final class ComposedPoll {
|
||||
public let publicity: TelegramMediaPollPublicity
|
||||
public let kind: TelegramMediaPollKind
|
||||
|
||||
public let text: String
|
||||
public let options: [TelegramMediaPollOption]
|
||||
public let correctAnswers: [Data]?
|
||||
public let results: TelegramMediaPollResults
|
||||
public let deadlineTimeout: Int32?
|
||||
|
||||
public init(
|
||||
publicity: TelegramMediaPollPublicity,
|
||||
kind: TelegramMediaPollKind,
|
||||
text: String,
|
||||
options: [TelegramMediaPollOption],
|
||||
correctAnswers: [Data]?,
|
||||
results: TelegramMediaPollResults,
|
||||
deadlineTimeout: Int32?
|
||||
) {
|
||||
self.publicity = publicity
|
||||
self.kind = kind
|
||||
self.text = text
|
||||
self.options = options
|
||||
self.correctAnswers = correctAnswers
|
||||
self.results = results
|
||||
self.deadlineTimeout = deadlineTimeout
|
||||
}
|
||||
}
|
||||
|
||||
public func createPollController(context: AccountContext, updatedPresentationData: (initial: PresentationData, signal: Signal<PresentationData, NoError>)? = nil, peer: EnginePeer, isQuiz: Bool? = nil, completion: @escaping (ComposedPoll) -> Void) -> ViewController {
|
||||
var initialState = CreatePollControllerState()
|
||||
if let isQuiz = isQuiz {
|
||||
initialState.isQuiz = isQuiz
|
||||
|
|
@ -819,14 +847,19 @@ public func createPollController(context: AccountContext, updatedPresentationDat
|
|||
kind = .poll(multipleAnswers: state.isMultipleChoice)
|
||||
}
|
||||
|
||||
var deadlineTimeout: Int32?
|
||||
#if DEBUG
|
||||
deadlineTimeout = 65
|
||||
#endif
|
||||
let deadlineTimeout: Int32? = nil
|
||||
|
||||
dismissImpl?()
|
||||
|
||||
completion(.message(text: "", attributes: [], mediaReference: .standalone(media: TelegramMediaPoll(pollId: MediaId(namespace: Namespaces.Media.LocalPoll, id: Int64.random(in: Int64.min ... Int64.max)), publicity: publicity, kind: kind, text: processPollText(state.text), options: options, correctAnswers: correctAnswers, results: TelegramMediaPollResults(voters: nil, totalVoters: nil, recentVoters: [], solution: resolvedSolution), isClosed: false, deadlineTimeout: deadlineTimeout)), replyToMessageId: nil, localGroupingKey: nil, correlationId: nil))
|
||||
completion(ComposedPoll(
|
||||
publicity: publicity,
|
||||
kind: kind,
|
||||
text: processPollText(state.text),
|
||||
options: options,
|
||||
correctAnswers: correctAnswers,
|
||||
results: TelegramMediaPollResults(voters: nil, totalVoters: nil, recentVoters: [], solution: resolvedSolution),
|
||||
deadlineTimeout: deadlineTimeout
|
||||
))
|
||||
})
|
||||
|
||||
let leftNavigationButton = ItemListNavigationButton(content: .text(presentationData.strings.Common_Cancel), style: .regular, enabled: true, action: {
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ private enum ContactListNodeEntry: Comparable, Identifiable {
|
|||
} else {
|
||||
if let _ = peer as? TelegramUser {
|
||||
let presence = presence ?? TelegramUserPresence(status: .none, lastActivity: 0)
|
||||
status = .presence(presence, dateTimeFormat)
|
||||
status = .presence(EnginePeer.Presence(presence), dateTimeFormat)
|
||||
} else if let group = peer as? TelegramGroup {
|
||||
status = .custom(string: strings.Conversation_StatusMembers(Int32(group.participantCount)), multiline: false)
|
||||
} else if let channel = peer as? TelegramChannel {
|
||||
|
|
@ -208,7 +208,7 @@ private enum ContactListNodeEntry: Comparable, Identifiable {
|
|||
status = .none
|
||||
}
|
||||
}
|
||||
itemPeer = .peer(peer: peer, chatPeer: peer)
|
||||
itemPeer = .peer(peer: EnginePeer(peer), chatPeer: EnginePeer(peer))
|
||||
case let .deviceContact(id, contact):
|
||||
status = .none
|
||||
itemPeer = .deviceContact(stableId: id, contact: contact)
|
||||
|
|
@ -222,7 +222,7 @@ private enum ContactListNodeEntry: Comparable, Identifiable {
|
|||
switch itemPeer {
|
||||
case let .peer(peer, _):
|
||||
if let peer = peer {
|
||||
contextAction(peer, node, gesture)
|
||||
contextAction(peer._asPeer(), node, gesture)
|
||||
}
|
||||
case .deviceContact:
|
||||
break
|
||||
|
|
|
|||
|
|
@ -135,7 +135,7 @@ private enum ContactListSearchEntry: Comparable, Identifiable {
|
|||
case .contacts:
|
||||
header = ChatListSearchItemHeader(type: .contacts, theme: theme, strings: strings, actionTitle: nil, action: nil)
|
||||
if let presence = presence {
|
||||
status = .presence(presence, timeFormat)
|
||||
status = .presence(EnginePeer.Presence(presence), timeFormat)
|
||||
} else {
|
||||
status = .none
|
||||
}
|
||||
|
|
@ -154,7 +154,7 @@ private enum ContactListSearchEntry: Comparable, Identifiable {
|
|||
let peerItem: ContactsPeerItemPeer
|
||||
switch peer {
|
||||
case let .peer(peer, _, _):
|
||||
peerItem = .peer(peer: peer, chatPeer: peer)
|
||||
peerItem = .peer(peer: EnginePeer(peer), chatPeer: EnginePeer(peer))
|
||||
nativePeer = peer
|
||||
case let .deviceContact(stableId, contact):
|
||||
peerItem = .deviceContact(stableId: stableId, contact: contact)
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ private enum InviteContactsEntry: Comparable, Identifiable {
|
|||
status = .none
|
||||
}
|
||||
let peer = TelegramUser(id: PeerId(namespace: .max, id: PeerId.Id._internalFromInt64Value(0)), accessHash: nil, firstName: contact.firstName, lastName: contact.lastName, username: nil, phone: nil, photo: [], botInfo: nil, restrictionInfo: nil, flags: [])
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: peer, chatPeer: peer), status: status, enabled: true, selection: selection, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: ChatListSearchItemHeader(type: .contacts, theme: theme, strings: strings, actionTitle: nil, action: nil), action: { _ in
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: EnginePeer(peer), chatPeer: EnginePeer(peer)), status: status, enabled: true, selection: selection, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: ChatListSearchItemHeader(type: .contacts, theme: theme, strings: strings, actionTitle: nil, action: nil), action: { _ in
|
||||
interaction.toggleContact(id)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ swift_library(
|
|||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
"//submodules/AvatarNode:AvatarNode",
|
||||
|
|
|
|||
|
|
@ -1,7 +1,6 @@
|
|||
import Foundation
|
||||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
|
|
@ -29,7 +28,7 @@ public final class ContactItemHighlighting {
|
|||
|
||||
public enum ContactsPeerItemStatus {
|
||||
case none
|
||||
case presence(PeerPresence, PresentationDateTimeFormat)
|
||||
case presence(EnginePeer.Presence, PresentationDateTimeFormat)
|
||||
case addressName(String)
|
||||
case custom(string: String, multiline: Bool)
|
||||
}
|
||||
|
|
@ -94,17 +93,17 @@ public struct ContactsPeerItemAction {
|
|||
}
|
||||
|
||||
public enum ContactsPeerItemPeer: Equatable {
|
||||
case peer(peer: Peer?, chatPeer: Peer?)
|
||||
case peer(peer: EnginePeer?, chatPeer: EnginePeer?)
|
||||
case deviceContact(stableId: DeviceContactStableId, contact: DeviceContactBasicData)
|
||||
|
||||
public static func ==(lhs: ContactsPeerItemPeer, rhs: ContactsPeerItemPeer) -> Bool {
|
||||
switch lhs {
|
||||
case let .peer(lhsPeer, lhsChatPeer):
|
||||
if case let .peer(rhsPeer, rhsChatPeer) = rhs {
|
||||
if !arePeersEqual(lhsPeer, rhsPeer) {
|
||||
if lhsPeer != rhsPeer {
|
||||
return false
|
||||
}
|
||||
if !arePeersEqual(lhsChatPeer, rhsChatPeer) {
|
||||
if lhsChatPeer != rhsChatPeer {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
|
|
@ -122,6 +121,11 @@ public enum ContactsPeerItemPeer: Equatable {
|
|||
}
|
||||
|
||||
public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
||||
public enum SortIndex {
|
||||
case firstNameFirst
|
||||
case lastNameFirst
|
||||
}
|
||||
|
||||
let presentationData: ItemListPresentationData
|
||||
let style: ItemListStyle
|
||||
public let sectionId: ItemListSectionId
|
||||
|
|
@ -141,8 +145,8 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
|||
let actionIcon: ContactsPeerItemActionIcon
|
||||
let action: (ContactsPeerItemPeer) -> Void
|
||||
let disabledAction: ((ContactsPeerItemPeer) -> Void)?
|
||||
let setPeerIdWithRevealedOptions: ((PeerId?, PeerId?) -> Void)?
|
||||
let deletePeer: ((PeerId) -> Void)?
|
||||
let setPeerIdWithRevealedOptions: ((EnginePeer.Id?, EnginePeer.Id?) -> Void)?
|
||||
let deletePeer: ((EnginePeer.Id) -> Void)?
|
||||
let itemHighlighting: ContactItemHighlighting?
|
||||
let contextAction: ((ASDisplayNode, ContextGesture?) -> Void)?
|
||||
let arrowAction: (() -> Void)?
|
||||
|
|
@ -153,7 +157,7 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
|||
|
||||
public let header: ListViewItemHeader?
|
||||
|
||||
public init(presentationData: ItemListPresentationData, style: ItemListStyle = .plain, sectionId: ItemListSectionId = 0, sortOrder: PresentationPersonNameOrder, displayOrder: PresentationPersonNameOrder, context: AccountContext, peerMode: ContactsPeerItemPeerMode, peer: ContactsPeerItemPeer, status: ContactsPeerItemStatus, badge: ContactsPeerItemBadge? = nil, enabled: Bool, selection: ContactsPeerItemSelection, selectionPosition: ContactsPeerItemSelectionPosition = .right, editing: ContactsPeerItemEditing, options: [ItemListPeerItemRevealOption] = [], additionalActions: [ContactsPeerItemAction] = [], actionIcon: ContactsPeerItemActionIcon = .none, index: PeerNameIndex?, header: ListViewItemHeader?, action: @escaping (ContactsPeerItemPeer) -> Void, disabledAction: ((ContactsPeerItemPeer) -> Void)? = nil, setPeerIdWithRevealedOptions: ((PeerId?, PeerId?) -> Void)? = nil, deletePeer: ((PeerId) -> Void)? = nil, itemHighlighting: ContactItemHighlighting? = nil, contextAction: ((ASDisplayNode, ContextGesture?) -> Void)? = nil, arrowAction: (() -> Void)? = nil) {
|
||||
public init(presentationData: ItemListPresentationData, style: ItemListStyle = .plain, sectionId: ItemListSectionId = 0, sortOrder: PresentationPersonNameOrder, displayOrder: PresentationPersonNameOrder, context: AccountContext, peerMode: ContactsPeerItemPeerMode, peer: ContactsPeerItemPeer, status: ContactsPeerItemStatus, badge: ContactsPeerItemBadge? = nil, enabled: Bool, selection: ContactsPeerItemSelection, selectionPosition: ContactsPeerItemSelectionPosition = .right, editing: ContactsPeerItemEditing, options: [ItemListPeerItemRevealOption] = [], additionalActions: [ContactsPeerItemAction] = [], actionIcon: ContactsPeerItemActionIcon = .none, index: SortIndex?, header: ListViewItemHeader?, action: @escaping (ContactsPeerItemPeer) -> Void, disabledAction: ((ContactsPeerItemPeer) -> Void)? = nil, setPeerIdWithRevealedOptions: ((EnginePeer.Id?, EnginePeer.Id?) -> Void)? = nil, deletePeer: ((EnginePeer.Id) -> Void)? = nil, itemHighlighting: ContactItemHighlighting? = nil, contextAction: ((ASDisplayNode, ContextGesture?) -> Void)? = nil, arrowAction: (() -> Void)? = nil) {
|
||||
self.presentationData = presentationData
|
||||
self.style = style
|
||||
self.sectionId = sectionId
|
||||
|
|
@ -185,7 +189,7 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
|||
var letter: String = "#"
|
||||
switch peer {
|
||||
case let .peer(peer, _):
|
||||
if let user = peer as? TelegramUser {
|
||||
if case let .user(user) = peer {
|
||||
switch index {
|
||||
case .firstNameFirst:
|
||||
if let firstName = user.firstName, !firstName.isEmpty {
|
||||
|
|
@ -200,11 +204,11 @@ public class ContactsPeerItem: ItemListItem, ListViewItemWithHeader {
|
|||
letter = String(firstName.prefix(1)).uppercased()
|
||||
}
|
||||
}
|
||||
} else if let group = peer as? TelegramGroup {
|
||||
} else if case let .legacyGroup(group) = peer {
|
||||
if !group.title.isEmpty {
|
||||
letter = String(group.title.prefix(1)).uppercased()
|
||||
}
|
||||
} else if let channel = peer as? TelegramChannel {
|
||||
} else if case let .channel(channel) = peer {
|
||||
if !channel.title.isEmpty {
|
||||
letter = String(channel.title.prefix(1)).uppercased()
|
||||
}
|
||||
|
|
@ -340,7 +344,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||
|
||||
private var peerPresenceManager: PeerPresenceStatusManager?
|
||||
private var layoutParams: (ContactsPeerItem, ListViewItemLayoutParams, Bool, Bool, Bool, ItemListNeighbors)?
|
||||
public var chatPeer: Peer? {
|
||||
public var chatPeer: EnginePeer? {
|
||||
if let peer = self.layoutParams?.0.peer {
|
||||
switch peer {
|
||||
case let .peer(peer, chatPeer):
|
||||
|
|
@ -598,18 +602,18 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||
var titleAttributedString: NSAttributedString?
|
||||
var statusAttributedString: NSAttributedString?
|
||||
var multilineStatus: Bool = false
|
||||
var userPresence: TelegramUserPresence?
|
||||
var userPresence: EnginePeer.Presence?
|
||||
|
||||
switch item.peer {
|
||||
case let .peer(peer, chatPeer):
|
||||
if let peer = peer {
|
||||
let textColor: UIColor
|
||||
if let _ = chatPeer as? TelegramSecretChat {
|
||||
if case .secretChat = chatPeer {
|
||||
textColor = item.presentationData.theme.chatList.secretTitleColor
|
||||
} else {
|
||||
textColor = item.presentationData.theme.list.itemPrimaryTextColor
|
||||
}
|
||||
if let user = peer as? TelegramUser {
|
||||
if case let .user(user) = peer {
|
||||
if peer.id == item.context.account.peerId, case .generalSearch = item.peerMode {
|
||||
titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_SavedMessages, font: titleBoldFont, textColor: textColor)
|
||||
} else if peer.id.isReplies {
|
||||
|
|
@ -634,9 +638,9 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||
} else {
|
||||
titleAttributedString = NSAttributedString(string: item.presentationData.strings.User_DeletedAccount, font: titleBoldFont, textColor: textColor)
|
||||
}
|
||||
} else if let group = peer as? TelegramGroup {
|
||||
} else if case let .legacyGroup(group) = peer {
|
||||
titleAttributedString = NSAttributedString(string: group.title, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
|
||||
} else if let channel = peer as? TelegramChannel {
|
||||
} else if case let .channel(channel) = peer {
|
||||
titleAttributedString = NSAttributedString(string: channel.title, font: titleBoldFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
|
||||
}
|
||||
|
||||
|
|
@ -644,7 +648,6 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||
case .none:
|
||||
break
|
||||
case let .presence(presence, dateTimeFormat):
|
||||
let presence = (presence as? TelegramUserPresence) ?? TelegramUserPresence(status: .none, lastActivity: 0)
|
||||
userPresence = presence
|
||||
let timestamp = CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970
|
||||
let (string, activity) = stringAndActivityForUserPresence(strings: item.presentationData.strings, dateTimeFormat: dateTimeFormat, presence: presence, relativeTo: Int32(timestamp))
|
||||
|
|
@ -825,7 +828,7 @@ public class ContactsPeerItemNode: ItemListRevealOptionsItemNode {
|
|||
} else if peer.isDeleted {
|
||||
overrideImage = .deletedIcon
|
||||
}
|
||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(peer), overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads)
|
||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads)
|
||||
}
|
||||
case let .deviceContact(_, contact):
|
||||
let letters: [String]
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ swift_library(
|
|||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
"//submodules/AvatarNode:AvatarNode",
|
||||
|
|
|
|||
|
|
@ -635,9 +635,9 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
|||
if let forwardInfo = message.forwardInfo, forwardInfo.flags.contains(.isImported), let authorSignature = forwardInfo.authorSignature {
|
||||
authorNameText = authorSignature
|
||||
} else if let author = message.effectiveAuthor {
|
||||
authorNameText = author.displayTitle(strings: self.strings, displayOrder: self.nameOrder)
|
||||
authorNameText = EnginePeer(author).displayTitle(strings: self.strings, displayOrder: self.nameOrder)
|
||||
} else if let peer = message.peers[message.id.peerId] {
|
||||
authorNameText = peer.displayTitle(strings: self.strings, displayOrder: self.nameOrder)
|
||||
authorNameText = EnginePeer(peer).displayTitle(strings: self.strings, displayOrder: self.nameOrder)
|
||||
}
|
||||
|
||||
var dateText = humanReadableStringForTimestamp(strings: self.strings, dateTimeFormat: self.dateTimeFormat, timestamp: message.timestamp).string
|
||||
|
|
@ -1028,7 +1028,7 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
|||
var isChannel = false
|
||||
let peerId: PeerId = messages[0].id.peerId
|
||||
if let user = messages[0].peers[messages[0].id.peerId] as? TelegramUser {
|
||||
personalPeerName = user.compactDisplayTitle
|
||||
personalPeerName = EnginePeer(user).compactDisplayTitle
|
||||
} else if let channel = messages[0].peers[messages[0].id.peerId] as? TelegramChannel, case .broadcast = channel.info {
|
||||
isChannel = true
|
||||
}
|
||||
|
|
@ -1211,14 +1211,14 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
|||
savedMessages = true
|
||||
} else {
|
||||
if peers.count == 1, let peer = peers.first {
|
||||
let peerName = peer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let peerName = peer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_Chat_One(peerName).string : presentationData.strings.Conversation_ForwardTooltip_Chat_Many(peerName).string
|
||||
} else if peers.count == 2, let firstPeer = peers.first, let secondPeer = peers.last {
|
||||
let firstPeerName = firstPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : firstPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let secondPeerName = secondPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : secondPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let firstPeerName = firstPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(firstPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let secondPeerName = secondPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(secondPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_TwoChats_One(firstPeerName, secondPeerName).string : presentationData.strings.Conversation_ForwardTooltip_TwoChats_Many(firstPeerName, secondPeerName).string
|
||||
} else if let peer = peers.first {
|
||||
let peerName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let peerName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_ManyChats_One(peerName, "\(peers.count - 1)").string : presentationData.strings.Conversation_ForwardTooltip_ManyChats_Many(peerName, "\(peers.count - 1)").string
|
||||
} else {
|
||||
text = ""
|
||||
|
|
@ -1275,14 +1275,14 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
|||
savedMessages = true
|
||||
} else {
|
||||
if peers.count == 1, let peer = peers.first {
|
||||
let peerName = peer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let peerName = peer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_Chat_One(peerName).string : presentationData.strings.Conversation_ForwardTooltip_Chat_Many(peerName).string
|
||||
} else if peers.count == 2, let firstPeer = peers.first, let secondPeer = peers.last {
|
||||
let firstPeerName = firstPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : firstPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let secondPeerName = secondPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : secondPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let firstPeerName = firstPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(firstPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let secondPeerName = secondPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(secondPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_TwoChats_One(firstPeerName, secondPeerName).string : presentationData.strings.Conversation_ForwardTooltip_TwoChats_Many(firstPeerName, secondPeerName).string
|
||||
} else if let peer = peers.first {
|
||||
let peerName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let peerName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = messages.count == 1 ? presentationData.strings.Conversation_ForwardTooltip_ManyChats_One(peerName, "\(peers.count - 1)").string : presentationData.strings.Conversation_ForwardTooltip_ManyChats_Many(peerName, "\(peers.count - 1)").string
|
||||
} else {
|
||||
text = ""
|
||||
|
|
@ -1400,14 +1400,14 @@ final class ChatItemGalleryFooterContentNode: GalleryFooterContentNode, UIScroll
|
|||
savedMessages = true
|
||||
} else {
|
||||
if peers.count == 1, let peer = peers.first {
|
||||
let peerName = peer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let peerName = peer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = presentationData.strings.Conversation_ForwardTooltip_Chat_One(peerName).string
|
||||
} else if peers.count == 2, let firstPeer = peers.first, let secondPeer = peers.last {
|
||||
let firstPeerName = firstPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : firstPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let secondPeerName = secondPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : secondPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let firstPeerName = firstPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(firstPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let secondPeerName = secondPeer.id == strongSelf.context.account.peerId ? presentationData.strings.DialogList_SavedMessages : EnginePeer(secondPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = presentationData.strings.Conversation_ForwardTooltip_TwoChats_One(firstPeerName, secondPeerName).string
|
||||
} else if let peer = peers.first {
|
||||
let peerName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let peerName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
text = presentationData.strings.Conversation_ForwardTooltip_ManyChats_One(peerName, "\(peers.count - 1)").string
|
||||
} else {
|
||||
text = ""
|
||||
|
|
|
|||
|
|
@ -177,7 +177,7 @@ public func galleryItemForEntry(context: AccountContext, presentationData: Prese
|
|||
}
|
||||
|
||||
let caption = galleryCaptionStringWithAppliedEntities(text, entities: entities)
|
||||
return UniversalVideoGalleryItem(context: context, presentationData: presentationData, content: content, originData: GalleryItemOriginData(title: message.effectiveAuthor?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), timestamp: message.timestamp), indexData: location.flatMap { GalleryItemIndexData(position: Int32($0.index), totalCount: Int32($0.count)) }, contentInfo: .message(message), caption: caption, displayInfoOnTop: displayInfoOnTop, hideControls: hideControls, fromPlayingVideo: fromPlayingVideo, isSecret: isSecret, landscape: landscape, timecode: timecode, playbackRate: playbackRate, configuration: configuration, playbackCompleted: playbackCompleted, performAction: performAction, openActionOptions: openActionOptions, storeMediaPlaybackState: storeMediaPlaybackState, present: present)
|
||||
return UniversalVideoGalleryItem(context: context, presentationData: presentationData, content: content, originData: GalleryItemOriginData(title: message.effectiveAuthor.flatMap(EnginePeer.init)?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), timestamp: message.timestamp), indexData: location.flatMap { GalleryItemIndexData(position: Int32($0.index), totalCount: Int32($0.count)) }, contentInfo: .message(message), caption: caption, displayInfoOnTop: displayInfoOnTop, hideControls: hideControls, fromPlayingVideo: fromPlayingVideo, isSecret: isSecret, landscape: landscape, timecode: timecode, playbackRate: playbackRate, configuration: configuration, playbackCompleted: playbackCompleted, performAction: performAction, openActionOptions: openActionOptions, storeMediaPlaybackState: storeMediaPlaybackState, present: present)
|
||||
} else {
|
||||
if let fileName = file.fileName, (fileName as NSString).pathExtension.lowercased() == "json" {
|
||||
return ChatAnimationGalleryItem(context: context, presentationData: presentationData, message: message, location: location)
|
||||
|
|
@ -218,7 +218,7 @@ public func galleryItemForEntry(context: AccountContext, presentationData: Prese
|
|||
}
|
||||
}
|
||||
if let content = content {
|
||||
return UniversalVideoGalleryItem(context: context, presentationData: presentationData, content: content, originData: GalleryItemOriginData(title: message.effectiveAuthor?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), timestamp: message.timestamp), indexData: location.flatMap { GalleryItemIndexData(position: Int32($0.index), totalCount: Int32($0.count)) }, contentInfo: .message(message), caption: NSAttributedString(string: ""), displayInfoOnTop: displayInfoOnTop, fromPlayingVideo: fromPlayingVideo, isSecret: isSecret, landscape: landscape, timecode: timecode, playbackRate: playbackRate, configuration: configuration, performAction: performAction, openActionOptions: openActionOptions, storeMediaPlaybackState: storeMediaPlaybackState, present: present)
|
||||
return UniversalVideoGalleryItem(context: context, presentationData: presentationData, content: content, originData: GalleryItemOriginData(title: message.effectiveAuthor.flatMap(EnginePeer.init)?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), timestamp: message.timestamp), indexData: location.flatMap { GalleryItemIndexData(position: Int32($0.index), totalCount: Int32($0.count)) }, contentInfo: .message(message), caption: NSAttributedString(string: ""), displayInfoOnTop: displayInfoOnTop, fromPlayingVideo: fromPlayingVideo, isSecret: isSecret, landscape: landscape, timecode: timecode, playbackRate: playbackRate, configuration: configuration, performAction: performAction, openActionOptions: openActionOptions, storeMediaPlaybackState: storeMediaPlaybackState, present: present)
|
||||
} else {
|
||||
return nil
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ import UIKit
|
|||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramStringFormatting
|
||||
|
||||
|
|
@ -33,7 +34,7 @@ final class GalleryTitleView: UIView, NavigationBarTitleView {
|
|||
}
|
||||
|
||||
func setMessage(_ message: Message, presentationData: PresentationData, accountPeerId: PeerId) {
|
||||
let authorNameText = stringForFullAuthorName(message: message, strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder, accountPeerId: accountPeerId)
|
||||
let authorNameText = stringForFullAuthorName(message: EngineMessage(message), strings: presentationData.strings, nameDisplayOrder: presentationData.nameDisplayOrder, accountPeerId: accountPeerId)
|
||||
let dateText = humanReadableStringForTimestamp(strings: presentationData.strings, dateTimeFormat: presentationData.dateTimeFormat, timestamp: message.timestamp).string
|
||||
|
||||
self.authorNameNode.attributedText = NSAttributedString(string: authorNameText, font: titleFont, textColor: .white)
|
||||
|
|
|
|||
|
|
@ -300,7 +300,7 @@ public final class SecretMediaPreviewController: ViewController {
|
|||
}, transition: .immediate)
|
||||
} else {
|
||||
let contentNode = SecretMediaPreviewFooterContentNode()
|
||||
let peerTitle = messageMainPeer(message)?.compactDisplayTitle ?? ""
|
||||
let peerTitle = messageMainPeer(message).flatMap(EnginePeer.init)?.compactDisplayTitle ?? ""
|
||||
let text: String
|
||||
if let file = media as? TelegramMediaFile {
|
||||
if file.isAnimated {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ swift_library(
|
|||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import AsyncDisplayKit
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
|
||||
|
|
@ -15,11 +14,11 @@ public final class GameController: ViewController {
|
|||
|
||||
private let context: AccountContext
|
||||
private let url: String
|
||||
private let message: Message
|
||||
private let message: EngineMessage
|
||||
|
||||
private var presentationData: PresentationData
|
||||
|
||||
public init(context: AccountContext, url: String, message: Message) {
|
||||
public init(context: AccountContext, url: String, message: EngineMessage) {
|
||||
self.context = context
|
||||
self.url = url
|
||||
self.message = message
|
||||
|
|
@ -36,10 +35,10 @@ public final class GameController: ViewController {
|
|||
if let game = media as? TelegramMediaGame {
|
||||
let titleView = GameControllerTitleView(theme: self.presentationData.theme)
|
||||
|
||||
var botPeer: Peer?
|
||||
var botPeer: EnginePeer?
|
||||
inner: for attribute in message.attributes {
|
||||
if let attribute = attribute as? InlineBotMessageAttribute, let peerId = attribute.peerId {
|
||||
botPeer = message.peers[peerId]
|
||||
botPeer = message.peers[peerId].flatMap(EnginePeer.init)
|
||||
break inner
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -4,7 +4,6 @@ import Display
|
|||
import AsyncDisplayKit
|
||||
import WebKit
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
import AccountContext
|
||||
|
|
@ -31,9 +30,9 @@ final class GameControllerNode: ViewControllerTracingNode {
|
|||
private let context: AccountContext
|
||||
var presentationData: PresentationData
|
||||
private let present: (ViewController, Any?) -> Void
|
||||
private let message: Message
|
||||
private let message: EngineMessage
|
||||
|
||||
init(context: AccountContext, presentationData: PresentationData, url: String, present: @escaping (ViewController, Any?) -> Void, message: Message) {
|
||||
init(context: AccountContext, presentationData: PresentationData, url: String, present: @escaping (ViewController, Any?) -> Void, message: EngineMessage) {
|
||||
self.context = context
|
||||
self.presentationData = presentationData
|
||||
self.present = present
|
||||
|
|
@ -107,14 +106,14 @@ final class GameControllerNode: ViewControllerTracingNode {
|
|||
})
|
||||
}
|
||||
|
||||
private func shareData() -> (Peer, String)? {
|
||||
var botPeer: Peer?
|
||||
private func shareData() -> (EnginePeer, String)? {
|
||||
var botPeer: EnginePeer?
|
||||
var gameName: String?
|
||||
for media in self.message.media {
|
||||
if let game = media as? TelegramMediaGame {
|
||||
inner: for attribute in self.message.attributes {
|
||||
if let attribute = attribute as? InlineBotMessageAttribute, let peerId = attribute.peerId {
|
||||
botPeer = self.message.peers[peerId]
|
||||
botPeer = self.message.peers[peerId].flatMap(EnginePeer.init)
|
||||
break inner
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ swift_library(
|
|||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/TelegramUIPreferences:TelegramUIPreferences",
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ final class HashtagSearchControllerNode: ASDisplayNode {
|
|||
} else if let id = peer?.id, id.isReplies {
|
||||
items.append(presentationData.strings.DialogList_Replies)
|
||||
} else {
|
||||
items.append(peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) ?? "")
|
||||
items.append(peer.flatMap(EnginePeer.init)?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) ?? "")
|
||||
}
|
||||
items.append(strings.HashtagSearch_AllChats)
|
||||
self.segmentedControlNode = SegmentedControlNode(theme: SegmentedControlTheme(theme: theme), items: items.map { SegmentedControlItem(title: $0) }, selectedIndex: 0)
|
||||
|
|
|
|||
|
|
@ -210,7 +210,7 @@ final class InstantPagePeerReferenceNode: ASDisplayNode, InstantPageNode {
|
|||
private func applyThemeAndStrings(themeUpdated: Bool) {
|
||||
if let peer = self.peer {
|
||||
let textColor = self.transparent ? UIColor.white : self.theme.panelPrimaryColor
|
||||
self.nameNode.attributedText = NSAttributedString(string: peer.displayTitle(strings: self.strings, displayOrder: self.nameDisplayOrder), font: Font.medium(17.0), textColor: textColor)
|
||||
self.nameNode.attributedText = NSAttributedString(string: EnginePeer(peer).displayTitle(strings: self.strings, displayOrder: self.nameDisplayOrder), font: Font.medium(17.0), textColor: textColor)
|
||||
}
|
||||
let accentColor = self.transparent ? UIColor.white : self.theme.panelAccentColor
|
||||
self.joinNode.setAttributedTitle(NSAttributedString(string: self.strings.Channel_JoinChannel, font: Font.medium(17.0), textColor: accentColor), for: [])
|
||||
|
|
|
|||
|
|
@ -261,7 +261,7 @@ private enum InviteLinksListEntry: ItemListNodeEntry {
|
|||
case let .adminsHeader(_, text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .admin(_, _, creator):
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: creator.peer.peer!, height: .peerList, aliasHandling: .standard, nameColor: .primary, nameStyle: .plain, presence: nil, text: .none, label: creator.count > 1 ? .disclosure("\(creator.count)") : .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: nil), revealOptions: nil, switchValue: nil, enabled: true, highlighted: false, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context, peer: EnginePeer(creator.peer.peer!), height: .peerList, aliasHandling: .standard, nameColor: .primary, nameStyle: .plain, presence: nil, text: .none, label: creator.count > 1 ? .disclosure("\(creator.count)") : .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: nil), revealOptions: nil, switchValue: nil, enabled: true, highlighted: false, selectable: true, sectionId: self.section, action: {
|
||||
arguments.openAdmin(creator)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in }, removePeer: { _ in }, toggleUpdated: nil, contextAction: nil)
|
||||
}
|
||||
|
|
@ -309,7 +309,7 @@ private func inviteLinkListControllerEntries(presentationData: PresentationData,
|
|||
|
||||
entries.append(.mainLink(presentationData.theme, mainInvite, importers?.importers.prefix(3).compactMap { $0.peer.peer } ?? [], importersCount, isPublic))
|
||||
if let adminPeer = admin?.peer.peer, let peer = peerViewMainPeer(view) {
|
||||
let string = presentationData.strings.InviteLink_OtherPermanentLinkInfo(adminPeer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder))
|
||||
let string = presentationData.strings.InviteLink_OtherPermanentLinkInfo(EnginePeer(adminPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder))
|
||||
entries.append(.mainLinkOtherInfo(presentationData.theme, string.string))
|
||||
}
|
||||
|
||||
|
|
@ -814,7 +814,7 @@ public func inviteLinkListController(context: AccountContext, updatedPresentatio
|
|||
|
||||
let title: ItemListControllerTitle
|
||||
if let admin = admin, let peer = admin.peer.peer {
|
||||
title = .textWithSubtitle(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), presentationData.strings.InviteLink_InviteLinks(admin.count))
|
||||
title = .textWithSubtitle(EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), presentationData.strings.InviteLink_InviteLinks(admin.count))
|
||||
} else {
|
||||
title = .text(presentationData.strings.InviteLink_Title)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ private enum InviteLinkViewEntry: Comparable, Identifiable {
|
|||
return SectionHeaderItem(presentationData: ItemListPresentationData(presentationData), title: title)
|
||||
case let .creator(_, dateTimeFormat, peer, date):
|
||||
let dateString = stringForFullDate(timestamp: date, strings: presentationData.strings, dateTimeFormat: dateTimeFormat)
|
||||
return ItemListPeerItem(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, context: interaction.context, peer: peer, height: .generic, nameStyle: .distinctBold, presence: nil, text: .text(dateString, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: peer.id != account.peerId, sectionId: 0, action: {
|
||||
return ItemListPeerItem(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, context: interaction.context, peer: EnginePeer(peer), height: .generic, nameStyle: .distinctBold, presence: nil, text: .text(dateString, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: peer.id != account.peerId, sectionId: 0, action: {
|
||||
interaction.openPeer(peer.id)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in }, removePeer: { _ in }, hasTopStripe: false, noInsets: true, tag: nil)
|
||||
case let .importerHeader(_, title, subtitle, expired):
|
||||
|
|
@ -189,7 +189,7 @@ private enum InviteLinkViewEntry: Comparable, Identifiable {
|
|||
return SectionHeaderItem(presentationData: ItemListPresentationData(presentationData), title: title, additionalText: additionalText)
|
||||
case let .importer(_, _, dateTimeFormat, peer, date, loading):
|
||||
let dateString = stringForFullDate(timestamp: date, strings: presentationData.strings, dateTimeFormat: dateTimeFormat)
|
||||
return ItemListPeerItem(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, context: interaction.context, peer: peer, height: .generic, nameStyle: .distinctBold, presence: nil, text: .text(dateString, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: peer.id != account.peerId, sectionId: 0, action: {
|
||||
return ItemListPeerItem(presentationData: ItemListPresentationData(presentationData), dateTimeFormat: dateTimeFormat, nameDisplayOrder: presentationData.nameDisplayOrder, context: interaction.context, peer: EnginePeer(peer), height: .generic, nameStyle: .distinctBold, presence: nil, text: .text(dateString, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: peer.id != account.peerId, sectionId: 0, action: {
|
||||
interaction.openPeer(peer.id)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in }, removePeer: { _ in }, hasTopStripe: false, noInsets: true, tag: nil, shimmering: loading ? ItemListPeerItemShimmering(alternationIndex: 0) : nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ swift_library(
|
|||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/PeerPresenceStatusManager:PeerPresenceStatusManager",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
|
@ -31,13 +30,13 @@ public enum ItemListAvatarAndNameInfoItemName: Equatable {
|
|||
case personName(firstName: String, lastName: String, phone: String)
|
||||
case title(title: String, type: ItemListAvatarAndNameInfoItemTitleType)
|
||||
|
||||
public init(_ peer: Peer) {
|
||||
public init(_ peer: EnginePeer) {
|
||||
switch peer.indexName {
|
||||
case let .personName(first, last, _, phone):
|
||||
self = .personName(firstName: first, lastName: last, phone: phone ?? "")
|
||||
case let .title(title, _):
|
||||
let type: ItemListAvatarAndNameInfoItemTitleType
|
||||
if let peer = peer as? TelegramChannel, case .broadcast = peer.info {
|
||||
if case let .channel(peer) = peer, case .broadcast = peer.info {
|
||||
type = .channel
|
||||
} else {
|
||||
type = .group
|
||||
|
|
@ -132,10 +131,10 @@ public class ItemListAvatarAndNameInfoItem: ListViewItem, ItemListItem {
|
|||
let presentationData: ItemListPresentationData
|
||||
let dateTimeFormat: PresentationDateTimeFormat
|
||||
let mode: ItemListAvatarAndNameInfoItemMode
|
||||
let peer: Peer?
|
||||
let presence: PeerPresence?
|
||||
let peer: EnginePeer?
|
||||
let presence: EnginePeer.Presence?
|
||||
let label: String?
|
||||
let cachedData: CachedPeerData?
|
||||
let memberCount: Int?
|
||||
let state: ItemListAvatarAndNameInfoItemState
|
||||
public let sectionId: ItemListSectionId
|
||||
let style: ItemListAvatarAndNameInfoItemStyle
|
||||
|
|
@ -151,7 +150,7 @@ public class ItemListAvatarAndNameInfoItem: ListViewItem, ItemListItem {
|
|||
|
||||
public let selectable: Bool
|
||||
|
||||
public init(accountContext: AccountContext, presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, mode: ItemListAvatarAndNameInfoItemMode, peer: Peer?, presence: PeerPresence?, label: String? = nil, cachedData: CachedPeerData?, state: ItemListAvatarAndNameInfoItemState, sectionId: ItemListSectionId, style: ItemListAvatarAndNameInfoItemStyle, editingNameUpdated: @escaping (ItemListAvatarAndNameInfoItemName) -> Void, editingNameCompleted: @escaping () -> Void = {}, avatarTapped: @escaping () -> Void, context: ItemListAvatarAndNameInfoItemContext? = nil, updatingImage: ItemListAvatarAndNameInfoItemUpdatingAvatar? = nil, call: (() -> Void)? = nil, action: (() -> Void)? = nil, longTapAction: (() -> Void)? = nil, tag: ItemListItemTag? = nil) {
|
||||
public init(accountContext: AccountContext, presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, mode: ItemListAvatarAndNameInfoItemMode, peer: EnginePeer?, presence: EnginePeer.Presence?, label: String? = nil, memberCount: Int?, state: ItemListAvatarAndNameInfoItemState, sectionId: ItemListSectionId, style: ItemListAvatarAndNameInfoItemStyle, editingNameUpdated: @escaping (ItemListAvatarAndNameInfoItemName) -> Void, editingNameCompleted: @escaping () -> Void = {}, avatarTapped: @escaping () -> Void, context: ItemListAvatarAndNameInfoItemContext? = nil, updatingImage: ItemListAvatarAndNameInfoItemUpdatingAvatar? = nil, call: (() -> Void)? = nil, action: (() -> Void)? = nil, longTapAction: (() -> Void)? = nil, tag: ItemListItemTag? = nil) {
|
||||
self.accountContext = accountContext
|
||||
self.presentationData = presentationData
|
||||
self.dateTimeFormat = dateTimeFormat
|
||||
|
|
@ -159,7 +158,7 @@ public class ItemListAvatarAndNameInfoItem: ListViewItem, ItemListItem {
|
|||
self.peer = peer
|
||||
self.presence = presence
|
||||
self.label = label
|
||||
self.cachedData = cachedData
|
||||
self.memberCount = memberCount
|
||||
self.state = state
|
||||
self.sectionId = sectionId
|
||||
self.style = style
|
||||
|
|
@ -396,7 +395,7 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
|
|||
|
||||
var statusText: String = ""
|
||||
let statusColor: UIColor
|
||||
if let peer = item.peer as? TelegramUser {
|
||||
if case let .user(peer) = item.peer {
|
||||
let servicePeer = isServicePeer(peer)
|
||||
switch item.mode {
|
||||
case .settings:
|
||||
|
|
@ -423,8 +422,7 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
|
|||
} else if let _ = peer.botInfo {
|
||||
statusText = item.presentationData.strings.Bot_GenericBotStatus
|
||||
statusColor = item.presentationData.theme.list.itemSecondaryTextColor
|
||||
} else if case .generic = item.mode, !servicePeer {
|
||||
let presence = (item.presence as? TelegramUserPresence) ?? TelegramUserPresence(status: .none, lastActivity: 0)
|
||||
} else if case .generic = item.mode, !servicePeer, let presence = item.presence {
|
||||
let timestamp = CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970
|
||||
let (string, activity) = stringAndActivityForUserPresence(strings: item.presentationData.strings, dateTimeFormat: item.dateTimeFormat, presence: presence, relativeTo: Int32(timestamp), expanded: true)
|
||||
statusText = string
|
||||
|
|
@ -438,19 +436,19 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
|
|||
statusColor = item.presentationData.theme.list.itemPrimaryTextColor
|
||||
}
|
||||
}
|
||||
} else if let channel = item.peer as? TelegramChannel {
|
||||
if let cachedChannelData = item.cachedData as? CachedChannelData, let memberCount = cachedChannelData.participantsSummary.memberCount {
|
||||
} else if case let .channel(channel) = item.peer {
|
||||
if let memberCount = item.memberCount {
|
||||
if case .group = channel.info {
|
||||
if memberCount == 0 {
|
||||
statusText = item.presentationData.strings.Group_Status
|
||||
} else {
|
||||
statusText = item.presentationData.strings.Conversation_StatusMembers(memberCount)
|
||||
statusText = item.presentationData.strings.Conversation_StatusMembers(Int32(memberCount))
|
||||
}
|
||||
} else {
|
||||
if memberCount == 0 {
|
||||
statusText = item.presentationData.strings.Channel_Status
|
||||
} else {
|
||||
statusText = item.presentationData.strings.Conversation_StatusSubscribers(memberCount)
|
||||
statusText = item.presentationData.strings.Conversation_StatusSubscribers(Int32(memberCount))
|
||||
}
|
||||
}
|
||||
statusColor = item.presentationData.theme.list.itemSecondaryTextColor
|
||||
|
|
@ -464,7 +462,7 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
|
|||
statusColor = item.presentationData.theme.list.itemSecondaryTextColor
|
||||
}
|
||||
}
|
||||
} else if let group = item.peer as? TelegramGroup {
|
||||
} else if case let .legacyGroup(group) = item.peer {
|
||||
statusText = item.presentationData.strings.GroupInfo_ParticipantCount(Int32(group.participantCount))
|
||||
statusColor = item.presentationData.theme.list.itemSecondaryTextColor
|
||||
} else {
|
||||
|
|
@ -666,7 +664,7 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
|
|||
overrideImage = .deletedIcon
|
||||
}
|
||||
|
||||
strongSelf.avatarNode.setPeer(context: item.accountContext, theme: item.presentationData.theme, peer: EnginePeer(peer), overrideImage: overrideImage, emptyColor: ignoreEmpty ? nil : item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads)
|
||||
strongSelf.avatarNode.setPeer(context: item.accountContext, theme: item.presentationData.theme, peer: peer, overrideImage: overrideImage, emptyColor: ignoreEmpty ? nil : item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoads)
|
||||
}
|
||||
|
||||
let avatarFrame = CGRect(origin: CGPoint(x: params.leftInset + 15.0, y: floor((layout.contentSize.height - 66.0) / 2.0)), size: CGSize(width: 66.0, height: 66.0))
|
||||
|
|
@ -950,7 +948,7 @@ public class ItemListAvatarAndNameInfoItemNode: ListViewItemNode, ItemListItemNo
|
|||
strongSelf.credibilityIconNode?.alpha = 1.0
|
||||
}
|
||||
}
|
||||
if let presence = item.presence as? TelegramUserPresence {
|
||||
if let presence = item.presence {
|
||||
strongSelf.peerPresenceManager?.reset(presence: presence)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ swift_library(
|
|||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/AvatarNode:AvatarNode",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
|
|
@ -317,12 +316,12 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem {
|
|||
let dateTimeFormat: PresentationDateTimeFormat
|
||||
let nameDisplayOrder: PresentationPersonNameOrder
|
||||
let context: AccountContext
|
||||
let peer: Peer
|
||||
let peer: EnginePeer
|
||||
let height: ItemListPeerItemHeight
|
||||
let aliasHandling: ItemListPeerItemAliasHandling
|
||||
let nameColor: ItemListPeerItemNameColor
|
||||
let nameStyle: ItemListPeerItemNameStyle
|
||||
let presence: PeerPresence?
|
||||
let presence: EnginePeer.Presence?
|
||||
let text: ItemListPeerItemText
|
||||
let label: ItemListPeerItemLabel
|
||||
let editing: ItemListPeerItemEditing
|
||||
|
|
@ -333,8 +332,8 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem {
|
|||
public let selectable: Bool
|
||||
public let sectionId: ItemListSectionId
|
||||
let action: (() -> Void)?
|
||||
let setPeerIdWithRevealedOptions: (PeerId?, PeerId?) -> Void
|
||||
let removePeer: (PeerId) -> Void
|
||||
let setPeerIdWithRevealedOptions: (EnginePeer.Id?, EnginePeer.Id?) -> Void
|
||||
let removePeer: (EnginePeer.Id) -> Void
|
||||
let toggleUpdated: ((Bool) -> Void)?
|
||||
let contextAction: ((ASDisplayNode, ContextGesture?) -> Void)?
|
||||
let hasTopStripe: Bool
|
||||
|
|
@ -346,7 +345,7 @@ public final class ItemListPeerItem: ListViewItem, ItemListItem {
|
|||
let displayDecorations: Bool
|
||||
let disableInteractiveTransitionIfNecessary: Bool
|
||||
|
||||
public init(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, context: AccountContext, peer: Peer, height: ItemListPeerItemHeight = .peerList, aliasHandling: ItemListPeerItemAliasHandling = .standard, nameColor: ItemListPeerItemNameColor = .primary, nameStyle: ItemListPeerItemNameStyle = .distinctBold, presence: PeerPresence?, text: ItemListPeerItemText, label: ItemListPeerItemLabel, editing: ItemListPeerItemEditing, revealOptions: ItemListPeerItemRevealOptions? = nil, switchValue: ItemListPeerItemSwitch?, enabled: Bool, highlighted: Bool = false, selectable: Bool, sectionId: ItemListSectionId, action: (() -> Void)?, setPeerIdWithRevealedOptions: @escaping (PeerId?, PeerId?) -> Void, removePeer: @escaping (PeerId) -> Void, toggleUpdated: ((Bool) -> Void)? = nil, contextAction: ((ASDisplayNode, ContextGesture?) -> Void)? = nil, hasTopStripe: Bool = true, hasTopGroupInset: Bool = true, noInsets: Bool = false, tag: ItemListItemTag? = nil, header: ListViewItemHeader? = nil, shimmering: ItemListPeerItemShimmering? = nil, displayDecorations: Bool = true, disableInteractiveTransitionIfNecessary: Bool = false) {
|
||||
public init(presentationData: ItemListPresentationData, dateTimeFormat: PresentationDateTimeFormat, nameDisplayOrder: PresentationPersonNameOrder, context: AccountContext, peer: EnginePeer, height: ItemListPeerItemHeight = .peerList, aliasHandling: ItemListPeerItemAliasHandling = .standard, nameColor: ItemListPeerItemNameColor = .primary, nameStyle: ItemListPeerItemNameStyle = .distinctBold, presence: EnginePeer.Presence?, text: ItemListPeerItemText, label: ItemListPeerItemLabel, editing: ItemListPeerItemEditing, revealOptions: ItemListPeerItemRevealOptions? = nil, switchValue: ItemListPeerItemSwitch?, enabled: Bool, highlighted: Bool = false, selectable: Bool, sectionId: ItemListSectionId, action: (() -> Void)?, setPeerIdWithRevealedOptions: @escaping (EnginePeer.Id?, EnginePeer.Id?) -> Void, removePeer: @escaping (EnginePeer.Id) -> Void, toggleUpdated: ((Bool) -> Void)? = nil, contextAction: ((ASDisplayNode, ContextGesture?) -> Void)? = nil, hasTopStripe: Bool = true, hasTopGroupInset: Bool = true, noInsets: Bool = false, tag: ItemListItemTag? = nil, header: ListViewItemHeader? = nil, shimmering: ItemListPeerItemShimmering? = nil, displayDecorations: Bool = true, disableInteractiveTransitionIfNecessary: Bool = false) {
|
||||
self.presentationData = presentationData
|
||||
self.dateTimeFormat = dateTimeFormat
|
||||
self.nameDisplayOrder = nameDisplayOrder
|
||||
|
|
@ -694,7 +693,7 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
|
|||
titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_SavedMessages, font: currentBoldFont, textColor: titleColor)
|
||||
} else if item.peer.id.isReplies {
|
||||
titleAttributedString = NSAttributedString(string: item.presentationData.strings.DialogList_Replies, font: currentBoldFont, textColor: titleColor)
|
||||
} else if let user = item.peer as? TelegramUser {
|
||||
} else if case let .user(user) = item.peer {
|
||||
if let firstName = user.firstName, let lastName = user.lastName, !firstName.isEmpty, !lastName.isEmpty {
|
||||
let string = NSMutableAttributedString()
|
||||
switch item.nameDisplayOrder {
|
||||
|
|
@ -715,15 +714,15 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
|
|||
} else {
|
||||
titleAttributedString = NSAttributedString(string: item.presentationData.strings.User_DeletedAccount, font: currentBoldFont, textColor: titleColor)
|
||||
}
|
||||
} else if let group = item.peer as? TelegramGroup {
|
||||
} else if case let .legacyGroup(group) = item.peer {
|
||||
titleAttributedString = NSAttributedString(string: group.title, font: currentBoldFont, textColor: titleColor)
|
||||
} else if let channel = item.peer as? TelegramChannel {
|
||||
} else if case let .channel(channel) = item.peer {
|
||||
titleAttributedString = NSAttributedString(string: channel.title, font: currentBoldFont, textColor: titleColor)
|
||||
}
|
||||
|
||||
switch item.text {
|
||||
case .presence:
|
||||
if let user = item.peer as? TelegramUser, let botInfo = user.botInfo {
|
||||
if case let .user(user) = item.peer, let botInfo = user.botInfo {
|
||||
let botStatus: String
|
||||
if botInfo.flags.contains(.hasAccessToChatHistory) {
|
||||
botStatus = item.presentationData.strings.Bot_GroupStatusReadsHistory
|
||||
|
|
@ -731,7 +730,7 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
|
|||
botStatus = item.presentationData.strings.Bot_GroupStatusDoesNotReadHistory
|
||||
}
|
||||
statusAttributedString = NSAttributedString(string: botStatus, font: statusFont, textColor: item.presentationData.theme.list.itemSecondaryTextColor)
|
||||
} else if let presence = item.presence as? TelegramUserPresence {
|
||||
} else if let presence = item.presence {
|
||||
let timestamp = CFAbsoluteTimeGetCurrent() + NSTimeIntervalSince1970
|
||||
let (string, activity) = stringAndActivityForUserPresence(strings: item.presentationData.strings, dateTimeFormat: item.dateTimeFormat, presence: presence, relativeTo: Int32(timestamp))
|
||||
statusAttributedString = NSAttributedString(string: string, font: statusFont, textColor: activity ? item.presentationData.theme.list.itemAccentColor : item.presentationData.theme.list.itemSecondaryTextColor)
|
||||
|
|
@ -1106,20 +1105,20 @@ public class ItemListPeerItemNode: ItemListRevealOptionsItemNode, ItemListItemNo
|
|||
transition.updateFrame(node: strongSelf.avatarNode, frame: avatarFrame)
|
||||
|
||||
if item.peer.id == item.context.account.peerId, case .threatSelfAsSaved = item.aliasHandling {
|
||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), overrideImage: .savedMessagesIcon, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad)
|
||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: .savedMessagesIcon, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad)
|
||||
} else if item.peer.id.isReplies {
|
||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), overrideImage: .repliesIcon, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad)
|
||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: .repliesIcon, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad)
|
||||
} else {
|
||||
var overrideImage: AvatarNodeImageOverride?
|
||||
if item.peer.isDeleted {
|
||||
overrideImage = .deletedIcon
|
||||
}
|
||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: EnginePeer(item.peer), overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad)
|
||||
strongSelf.avatarNode.setPeer(context: item.context, theme: item.presentationData.theme, peer: item.peer, overrideImage: overrideImage, emptyColor: item.presentationData.theme.list.mediaPlaceholderColor, synchronousLoad: synchronousLoad)
|
||||
}
|
||||
|
||||
strongSelf.highlightedBackgroundNode.frame = CGRect(origin: CGPoint(x: 0.0, y: -UIScreenPixel), size: CGSize(width: params.width, height: layout.contentSize.height + UIScreenPixel + UIScreenPixel))
|
||||
|
||||
if let presence = item.presence as? TelegramUserPresence {
|
||||
if let presence = item.presence {
|
||||
strongSelf.peerPresenceManager?.reset(presence: presence)
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,6 @@ swift_library(
|
|||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import AsyncDisplayKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import TextFormat
|
||||
|
|
@ -76,7 +75,7 @@ final class LanguageLinkPreviewContentNode: ASDisplayNode, ShareContentContainer
|
|||
func deactivate() {
|
||||
}
|
||||
|
||||
func setEnsurePeerVisibleOnLayout(_ peerId: PeerId?) {
|
||||
func setEnsurePeerVisibleOnLayout(_ peerId: EnginePeer.Id?) {
|
||||
}
|
||||
|
||||
func setContentOffsetUpdated(_ f: ((CGFloat, ContainedViewLayoutTransition) -> Void)?) {
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import AsyncDisplayKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import TelegramPresentationData
|
||||
|
|
|
|||
|
|
@ -3,7 +3,6 @@ import UIKit
|
|||
import Display
|
||||
import AsyncDisplayKit
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import TelegramPresentationData
|
||||
import ActivityIndicator
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public func legacyMediaEditor(context: AccountContext, peer: Peer, media: AnyMed
|
|||
}
|
||||
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let recipientName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let recipientName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
|
||||
let legacyController = LegacyController(presentation: .custom, theme: presentationData.theme, initialLayout: nil)
|
||||
legacyController.blocksBackgroundWhenInOverlay = true
|
||||
|
|
@ -182,7 +182,7 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, chatLocati
|
|||
carouselItemView = carouselItem
|
||||
carouselItem.stickersContext = paintStickersContext
|
||||
carouselItem.suggestionContext = legacySuggestionContext(context: context, peerId: peer.id, chatLocation: chatLocation)
|
||||
carouselItem.recipientName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
carouselItem.recipientName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
var openedCamera = false
|
||||
controller.willDismiss = { [weak carouselItem] _ in
|
||||
if let carouselItem = carouselItem, !openedCamera {
|
||||
|
|
@ -315,7 +315,7 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, chatLocati
|
|||
navigationController.setNavigationBarHidden(true, animated: false)
|
||||
legacyController.bind(controller: navigationController)
|
||||
|
||||
let recipientName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let recipientName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
|
||||
legacyController.enableSizeClassSignal = true
|
||||
|
||||
|
|
@ -439,7 +439,7 @@ public func presentLegacyPasteMenu(context: AccountContext, peer: Peer, chatLoca
|
|||
}
|
||||
hasSilentPosting = true
|
||||
}
|
||||
let recipientName = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let recipientName = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
|
||||
legacyController.enableSizeClassSignal = true
|
||||
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ public func legacyAssetPicker(context: AccountContext, presentationData: Present
|
|||
} else {
|
||||
Queue.mainQueue().async {
|
||||
subscriber.putNext({ context in
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: group, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, inhibitSelection: editingMedia, selectionLimit: Int32(selectionLimit))
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: group, intent: intent, recipientName: peer.flatMap(EnginePeer.init)?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, inhibitSelection: editingMedia, selectionLimit: Int32(selectionLimit))
|
||||
return controller!
|
||||
})
|
||||
subscriber.putCompletion()
|
||||
|
|
@ -93,7 +93,7 @@ public func legacyAssetPicker(context: AccountContext, presentationData: Present
|
|||
})
|
||||
} else {
|
||||
subscriber.putNext({ context in
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, inhibitSelection: editingMedia, selectionLimit: Int32(selectionLimit))
|
||||
let controller = TGMediaAssetsController(context: context, assetGroup: nil, intent: intent, recipientName: peer.flatMap(EnginePeer.init)?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), saveEditedPhotos: !isSecretChat && saveEditedPhotos, allowGrouping: allowGrouping, inhibitSelection: editingMedia, selectionLimit: Int32(selectionLimit))
|
||||
return controller!
|
||||
})
|
||||
subscriber.putCompletion()
|
||||
|
|
|
|||
|
|
@ -425,7 +425,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
}
|
||||
|
||||
if item.isGlobalSearchResult {
|
||||
let authorString = stringForFullAuthorName(message: item.message, strings: item.presentationData.strings, nameDisplayOrder: item.presentationData.nameDisplayOrder, accountPeerId: item.context.account.peerId)
|
||||
let authorString = stringForFullAuthorName(message: EngineMessage(item.message), strings: item.presentationData.strings, nameDisplayOrder: item.presentationData.nameDisplayOrder, accountPeerId: item.context.account.peerId)
|
||||
if descriptionString.isEmpty {
|
||||
descriptionString = authorString
|
||||
} else {
|
||||
|
|
@ -443,7 +443,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
}
|
||||
} else {
|
||||
titleText = NSAttributedString(string: " ", font: audioTitleFont, textColor: item.presentationData.theme.theme.list.itemPrimaryTextColor)
|
||||
descriptionText = NSAttributedString(string: item.message.author?.displayTitle(strings: item.presentationData.strings, displayOrder: .firstLast) ?? " ", font: descriptionFont, textColor: item.presentationData.theme.theme.list.itemSecondaryTextColor)
|
||||
descriptionText = NSAttributedString(string: item.message.author.flatMap(EnginePeer.init)?.displayTitle(strings: item.presentationData.strings, displayOrder: .firstLast) ?? " ", font: descriptionFont, textColor: item.presentationData.theme.theme.list.itemSecondaryTextColor)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -454,7 +454,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
if author.id == item.context.account.peerId {
|
||||
authorName = item.presentationData.strings.DialogList_You
|
||||
} else {
|
||||
authorName = author.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
authorName = EnginePeer(author).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
}
|
||||
} else if let signature = message.forwardInfo?.authorSignature {
|
||||
authorName = signature
|
||||
|
|
@ -462,14 +462,14 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
if author.id == item.context.account.peerId {
|
||||
authorName = item.presentationData.strings.DialogList_You
|
||||
} else {
|
||||
authorName = author.displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
authorName = EnginePeer(author).displayTitle(strings: item.presentationData.strings, displayOrder: item.presentationData.nameDisplayOrder)
|
||||
}
|
||||
} else {
|
||||
authorName = " "
|
||||
}
|
||||
|
||||
if item.isGlobalSearchResult {
|
||||
authorName = stringForFullAuthorName(message: item.message, strings: item.presentationData.strings, nameDisplayOrder: item.presentationData.nameDisplayOrder, accountPeerId: item.context.account.peerId)
|
||||
authorName = stringForFullAuthorName(message: EngineMessage(item.message), strings: item.presentationData.strings, nameDisplayOrder: item.presentationData.nameDisplayOrder, accountPeerId: item.context.account.peerId)
|
||||
}
|
||||
|
||||
titleText = NSAttributedString(string: authorName, font: audioTitleFont, textColor: item.presentationData.theme.theme.list.itemPrimaryTextColor)
|
||||
|
|
@ -522,7 +522,7 @@ public final class ListMessageFileItemNode: ListMessageNode {
|
|||
}
|
||||
|
||||
if item.isGlobalSearchResult {
|
||||
let authorString = stringForFullAuthorName(message: item.message, strings: item.presentationData.strings, nameDisplayOrder: item.presentationData.nameDisplayOrder, accountPeerId: item.context.account.peerId)
|
||||
let authorString = stringForFullAuthorName(message: EngineMessage(item.message), strings: item.presentationData.strings, nameDisplayOrder: item.presentationData.nameDisplayOrder, accountPeerId: item.context.account.peerId)
|
||||
if descriptionString.isEmpty {
|
||||
descriptionString = authorString
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -537,7 +537,7 @@ public final class ListMessageSnippetItemNode: ListMessageNode {
|
|||
|
||||
var authorString = ""
|
||||
if item.isGlobalSearchResult {
|
||||
authorString = stringForFullAuthorName(message: item.message, strings: item.presentationData.strings, nameDisplayOrder: item.presentationData.nameDisplayOrder, accountPeerId: item.context.account.peerId)
|
||||
authorString = stringForFullAuthorName(message: EngineMessage(item.message), strings: item.presentationData.strings, nameDisplayOrder: item.presentationData.nameDisplayOrder, accountPeerId: item.context.account.peerId)
|
||||
}
|
||||
|
||||
let authorText = NSAttributedString(string: authorString, font: authorFont, textColor: item.presentationData.theme.theme.list.itemSecondaryTextColor)
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ swift_library(
|
|||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/DeviceLocationManager:DeviceLocationManager",
|
||||
"//submodules/AccountContext:AccountContext",
|
||||
],
|
||||
|
|
|
|||
|
|
@ -1,6 +1,5 @@
|
|||
import Foundation
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import SwiftSignalKit
|
||||
import CoreLocation
|
||||
import DeviceLocationManager
|
||||
|
|
@ -9,7 +8,7 @@ import AccountContext
|
|||
public final class LiveLocationManagerImpl: LiveLocationManager {
|
||||
private let queue = Queue.mainQueue()
|
||||
|
||||
private let account: Account
|
||||
private let engine: TelegramEngine
|
||||
private let locationManager: DeviceLocationManager
|
||||
|
||||
private let summaryManagerImpl: LiveLocationSummaryManagerImpl
|
||||
|
|
@ -36,51 +35,48 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||
|
||||
private var deviceLocationPromise = Promise<(CLLocation, Double?)>()
|
||||
|
||||
private var broadcastToMessageIds: [MessageId: Int32] = [:]
|
||||
private var stopMessageIds = Set<MessageId>()
|
||||
private var broadcastToMessageIds: [EngineMessage.Id: Int32] = [:]
|
||||
private var stopMessageIds = Set<EngineMessage.Id>()
|
||||
|
||||
private let editMessageDisposables = DisposableDict<MessageId>()
|
||||
private let editMessageDisposables = DisposableDict<EngineMessage.Id>()
|
||||
|
||||
private var invalidationTimer: (SwiftSignalKit.Timer, Int32)?
|
||||
|
||||
public init(engine: TelegramEngine, account: Account, locationManager: DeviceLocationManager, inForeground: Signal<Bool, NoError>) {
|
||||
self.account = account
|
||||
public init(engine: TelegramEngine, locationManager: DeviceLocationManager, inForeground: Signal<Bool, NoError>) {
|
||||
self.engine = engine
|
||||
self.locationManager = locationManager
|
||||
|
||||
self.summaryManagerImpl = LiveLocationSummaryManagerImpl(queue: self.queue, engine: engine, postbox: account.postbox, accountPeerId: account.peerId, viewTracker: account.viewTracker)
|
||||
|
||||
let viewKey: PostboxViewKey = .localMessageTag(.OutgoingLiveLocation)
|
||||
self.messagesDisposable = (account.postbox.combinedView(keys: [viewKey])
|
||||
|> deliverOn(self.queue)).start(next: { [weak self] view in
|
||||
self.summaryManagerImpl = LiveLocationSummaryManagerImpl(queue: self.queue, engine: engine, accountPeerId: engine.account.peerId)
|
||||
|
||||
self.messagesDisposable = (self.engine.messages.activeLiveLocationMessages()
|
||||
|> deliverOn(self.queue)).start(next: { [weak self] message in
|
||||
if let strongSelf = self {
|
||||
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
||||
|
||||
var broadcastToMessageIds: [MessageId: Int32] = [:]
|
||||
var stopMessageIds = Set<MessageId>()
|
||||
|
||||
if let view = view.views[viewKey] as? LocalMessageTagsView {
|
||||
for message in view.messages.values {
|
||||
if !message.flags.contains(.Incoming) {
|
||||
if message.flags.intersection([.Failed, .Unsent]).isEmpty {
|
||||
var activeLiveBroadcastingTimeout: Int32?
|
||||
for media in message.media {
|
||||
if let telegramMap = media as? TelegramMediaMap {
|
||||
if let liveBroadcastingTimeout = telegramMap.liveBroadcastingTimeout {
|
||||
if message.timestamp + liveBroadcastingTimeout > timestamp {
|
||||
activeLiveBroadcastingTimeout = liveBroadcastingTimeout
|
||||
}
|
||||
var broadcastToMessageIds: [EngineMessage.Id: Int32] = [:]
|
||||
var stopMessageIds = Set<EngineMessage.Id>()
|
||||
|
||||
for message in message {
|
||||
if !message.flags.contains(.Incoming) {
|
||||
if message.flags.intersection([.Failed, .Unsent]).isEmpty {
|
||||
var activeLiveBroadcastingTimeout: Int32?
|
||||
for media in message.media {
|
||||
if let telegramMap = media as? TelegramMediaMap {
|
||||
if let liveBroadcastingTimeout = telegramMap.liveBroadcastingTimeout {
|
||||
if message.timestamp + liveBroadcastingTimeout > timestamp {
|
||||
activeLiveBroadcastingTimeout = liveBroadcastingTimeout
|
||||
}
|
||||
}
|
||||
}
|
||||
if let activeLiveBroadcastingTimeout = activeLiveBroadcastingTimeout {
|
||||
broadcastToMessageIds[message.id] = message.timestamp + activeLiveBroadcastingTimeout
|
||||
} else {
|
||||
stopMessageIds.insert(message.id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assertionFailure()
|
||||
if let activeLiveBroadcastingTimeout = activeLiveBroadcastingTimeout {
|
||||
broadcastToMessageIds[message.id] = message.timestamp + activeLiveBroadcastingTimeout
|
||||
} else {
|
||||
stopMessageIds.insert(message.id)
|
||||
}
|
||||
}
|
||||
} else {
|
||||
assertionFailure()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -139,7 +135,7 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||
self.invalidationTimer?.0.invalidate()
|
||||
}
|
||||
|
||||
private func update(broadcastToMessageIds: [MessageId: Int32], stopMessageIds: Set<MessageId>) {
|
||||
private func update(broadcastToMessageIds: [EngineMessage.Id: Int32], stopMessageIds: Set<EngineMessage.Id>) {
|
||||
assert(self.queue.isCurrent())
|
||||
|
||||
if self.broadcastToMessageIds == broadcastToMessageIds && self.stopMessageIds == stopMessageIds {
|
||||
|
|
@ -170,7 +166,7 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||
let addedStopped = stopMessageIds.subtracting(self.stopMessageIds)
|
||||
self.stopMessageIds = stopMessageIds
|
||||
for id in addedStopped {
|
||||
self.editMessageDisposables.set((TelegramEngine(account: self.account).messages.requestEditLiveLocation(messageId: id, stop: true, coordinate: nil, heading: nil, proximityNotificationRadius: nil)
|
||||
self.editMessageDisposables.set((self.engine.messages.requestEditLiveLocation(messageId: id, stop: true, coordinate: nil, heading: nil, proximityNotificationRadius: nil)
|
||||
|> deliverOn(self.queue)).start(completed: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.editMessageDisposables.set(nil, forKey: id)
|
||||
|
|
@ -187,7 +183,7 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||
var updatedBroadcastToMessageIds = self.broadcastToMessageIds
|
||||
var updatedStopMessageIds = self.stopMessageIds
|
||||
|
||||
var earliestCancelIdAndTimestamp: (MessageId, Int32)?
|
||||
var earliestCancelIdAndTimestamp: (EngineMessage.Id, Int32)?
|
||||
for (id, timestamp) in self.broadcastToMessageIds {
|
||||
if currentTimestamp >= timestamp {
|
||||
updatedBroadcastToMessageIds.removeValue(forKey: id)
|
||||
|
|
@ -223,9 +219,9 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||
assert(self.queue.isCurrent())
|
||||
|
||||
let ids = self.broadcastToMessageIds
|
||||
let remainingIds = Atomic<Set<MessageId>>(value: Set(ids.keys))
|
||||
let remainingIds = Atomic<Set<EngineMessage.Id>>(value: Set(ids.keys))
|
||||
for id in ids.keys {
|
||||
self.editMessageDisposables.set((TelegramEngine(account: self.account).messages.requestEditLiveLocation(messageId: id, stop: false, coordinate: (latitude: coordinate.latitude, longitude: coordinate.longitude, accuracyRadius: Int32(accuracyRadius)), heading: heading.flatMap { Int32($0) }, proximityNotificationRadius: nil)
|
||||
self.editMessageDisposables.set((self.engine.messages.requestEditLiveLocation(messageId: id, stop: false, coordinate: (latitude: coordinate.latitude, longitude: coordinate.longitude, accuracyRadius: Int32(accuracyRadius)), heading: heading.flatMap { Int32($0) }, proximityNotificationRadius: nil)
|
||||
|> deliverOn(self.queue)).start(completed: { [weak self] in
|
||||
if let strongSelf = self {
|
||||
strongSelf.editMessageDisposables.set(nil, forKey: id)
|
||||
|
|
@ -243,29 +239,12 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||
}
|
||||
}
|
||||
|
||||
public func cancelLiveLocation(peerId: PeerId) {
|
||||
public func cancelLiveLocation(peerId: EnginePeer.Id) {
|
||||
assert(self.queue.isCurrent())
|
||||
|
||||
let ids = self.broadcastToMessageIds.keys.filter({ $0.peerId == peerId })
|
||||
if !ids.isEmpty {
|
||||
let _ = self.account.postbox.transaction({ transaction -> Void in
|
||||
for id in ids {
|
||||
transaction.updateMessage(id, update: { currentMessage in
|
||||
var storeForwardInfo: StoreMessageForwardInfo?
|
||||
if let forwardInfo = currentMessage.forwardInfo {
|
||||
storeForwardInfo = StoreMessageForwardInfo(authorId: forwardInfo.author?.id, sourceId: forwardInfo.source?.id, sourceMessageId: forwardInfo.sourceMessageId, date: forwardInfo.date, authorSignature: forwardInfo.authorSignature, psaType: forwardInfo.psaType, flags: forwardInfo.flags)
|
||||
}
|
||||
var updatedMedia = currentMessage.media
|
||||
let timestamp = Int32(CFAbsoluteTimeGetCurrent() + kCFAbsoluteTimeIntervalSince1970)
|
||||
for i in 0 ..< updatedMedia.count {
|
||||
if let media = updatedMedia[i] as? TelegramMediaMap, let _ = media.liveBroadcastingTimeout {
|
||||
updatedMedia[i] = TelegramMediaMap(latitude: media.latitude, longitude: media.longitude, heading: media.heading, accuracyRadius: media.accuracyRadius, geoPlace: media.geoPlace, venue: media.venue, liveBroadcastingTimeout: max(0, timestamp - currentMessage.timestamp - 1), liveProximityNotificationRadius: nil)
|
||||
}
|
||||
}
|
||||
return .update(StoreMessage(id: currentMessage.id, globallyUniqueId: currentMessage.globallyUniqueId, groupingKey: currentMessage.groupingKey, threadId: currentMessage.threadId, timestamp: currentMessage.timestamp, flags: StoreMessageFlags(currentMessage.flags), tags: currentMessage.tags, globalTags: currentMessage.globalTags, localTags: currentMessage.localTags, forwardInfo: storeForwardInfo, authorId: currentMessage.author?.id, text: currentMessage.text, attributes: currentMessage.attributes, media: updatedMedia))
|
||||
})
|
||||
}
|
||||
}).start()
|
||||
let _ = self.engine.messages.requestCancelLiveLocation(ids: ids).start()
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -275,7 +254,7 @@ public final class LiveLocationManagerImpl: LiveLocationManager {
|
|||
}
|
||||
}
|
||||
|
||||
public func internalMessageForPeerId(_ peerId: PeerId) -> MessageId? {
|
||||
public func internalMessageForPeerId(_ peerId: EnginePeer.Id) -> EngineMessage.Id? {
|
||||
for id in self.broadcastToMessageIds.keys {
|
||||
if id.peerId == peerId {
|
||||
return id
|
||||
|
|
|
|||
|
|
@ -1,15 +1,14 @@
|
|||
import Foundation
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import SwiftSignalKit
|
||||
import AccountContext
|
||||
|
||||
private final class LiveLocationSummaryContext {
|
||||
private let queue: Queue
|
||||
private let postbox: Postbox
|
||||
private var subscribers = Bag<([MessageId: Message]) -> Void>()
|
||||
private let engine: TelegramEngine
|
||||
private var subscribers = Bag<([EngineMessage.Id: EngineMessage]) -> Void>()
|
||||
|
||||
var messageIds = Set<MessageId>() {
|
||||
var messageIds = Set<EngineMessage.Id>() {
|
||||
didSet {
|
||||
assert(self.queue.isCurrent())
|
||||
|
||||
|
|
@ -18,10 +17,12 @@ private final class LiveLocationSummaryContext {
|
|||
self.disposable.set(nil)
|
||||
self.messages = [:]
|
||||
} else {
|
||||
let key = PostboxViewKey.messages(self.messageIds)
|
||||
self.disposable.set((self.postbox.combinedView(keys: [key]) |> deliverOn(self.queue)).start(next: { [weak self] view in
|
||||
self.disposable.set((self.engine.data.subscribe(
|
||||
TelegramEngine.EngineData.Item.Messages.Messages(ids: self.messageIds)
|
||||
)
|
||||
|> deliverOn(self.queue)).start(next: { [weak self] messages in
|
||||
if let strongSelf = self {
|
||||
strongSelf.messages = (view.views[key] as? MessagesView)?.messages ?? [:]
|
||||
strongSelf.messages = messages
|
||||
}
|
||||
}))
|
||||
}
|
||||
|
|
@ -29,7 +30,7 @@ private final class LiveLocationSummaryContext {
|
|||
}
|
||||
}
|
||||
|
||||
private var messages: [MessageId: Message] = [:] {
|
||||
private var messages: [EngineMessage.Id: EngineMessage] = [:] {
|
||||
didSet {
|
||||
assert(self.queue.isCurrent())
|
||||
|
||||
|
|
@ -41,16 +42,16 @@ private final class LiveLocationSummaryContext {
|
|||
|
||||
private let disposable = MetaDisposable()
|
||||
|
||||
init(queue: Queue, postbox: Postbox) {
|
||||
init(queue: Queue, engine: TelegramEngine) {
|
||||
self.queue = queue
|
||||
self.postbox = postbox
|
||||
self.engine = engine
|
||||
}
|
||||
|
||||
deinit {
|
||||
self.disposable.dispose()
|
||||
}
|
||||
|
||||
func subscribe() -> Signal<[MessageId: Message], NoError> {
|
||||
func subscribe() -> Signal<[EngineMessage.Id: EngineMessage], NoError> {
|
||||
let queue = self.queue
|
||||
return Signal { [weak self] subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
|
@ -79,12 +80,11 @@ private final class LiveLocationSummaryContext {
|
|||
private final class LiveLocationPeerSummaryContext {
|
||||
private let queue: Queue
|
||||
private let engine: TelegramEngine
|
||||
private let accountPeerId: PeerId
|
||||
private let viewTracker: AccountViewTracker
|
||||
private let peerId: PeerId
|
||||
private let accountPeerId: EnginePeer.Id
|
||||
private let peerId: EnginePeer.Id
|
||||
private let becameEmpty: () -> Void
|
||||
|
||||
private var peersAndMessages: [(Peer, Message)]? = nil {
|
||||
private var peersAndMessages: [(EnginePeer, EngineMessage)]? = nil {
|
||||
didSet {
|
||||
assert(self.queue.isCurrent())
|
||||
|
||||
|
|
@ -108,7 +108,7 @@ private final class LiveLocationPeerSummaryContext {
|
|||
}
|
||||
}
|
||||
}
|
||||
private var subscribers = Bag<([(Peer, Message)]?) -> Void>()
|
||||
private var subscribers = Bag<([(EnginePeer, EngineMessage)]?) -> Void>()
|
||||
|
||||
var isEmpty: Bool {
|
||||
return !self.isActive && self.subscribers.isEmpty
|
||||
|
|
@ -116,11 +116,10 @@ private final class LiveLocationPeerSummaryContext {
|
|||
|
||||
private let peerDisposable = MetaDisposable()
|
||||
|
||||
init(queue: Queue, engine: TelegramEngine, accountPeerId: PeerId, viewTracker: AccountViewTracker, peerId: PeerId, becameEmpty: @escaping () -> Void) {
|
||||
init(queue: Queue, engine: TelegramEngine, accountPeerId: EnginePeer.Id, peerId: EnginePeer.Id, becameEmpty: @escaping () -> Void) {
|
||||
self.queue = queue
|
||||
self.engine = engine
|
||||
self.accountPeerId = accountPeerId
|
||||
self.viewTracker = viewTracker
|
||||
self.peerId = peerId
|
||||
self.becameEmpty = becameEmpty
|
||||
}
|
||||
|
|
@ -129,7 +128,7 @@ private final class LiveLocationPeerSummaryContext {
|
|||
self.peerDisposable.dispose()
|
||||
}
|
||||
|
||||
func subscribe(_ f: @escaping ([(Peer, Message)]?) -> Void) -> Disposable {
|
||||
func subscribe(_ f: @escaping ([(EnginePeer, EngineMessage)]?) -> Void) -> Disposable {
|
||||
let wasEmpty = self.subscribers.isEmpty
|
||||
let index = self.subscribers.add({ next in
|
||||
f(next)
|
||||
|
|
@ -164,11 +163,11 @@ private final class LiveLocationPeerSummaryContext {
|
|||
self.peerDisposable.set((self.engine.messages.topPeerActiveLiveLocationMessages(peerId: self.peerId)
|
||||
|> deliverOn(self.queue)).start(next: { [weak self] accountPeer, messages in
|
||||
if let strongSelf = self {
|
||||
var peersAndMessages: [(Peer, Message)] = []
|
||||
var peersAndMessages: [(EnginePeer, EngineMessage)] = []
|
||||
for message in messages {
|
||||
if let author = message.author {
|
||||
if author.id != strongSelf.accountPeerId && message.flags.contains(.Incoming) {
|
||||
peersAndMessages.append((author, message))
|
||||
peersAndMessages.append((EnginePeer(author), EngineMessage(message)))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -189,33 +188,29 @@ private final class LiveLocationPeerSummaryContext {
|
|||
public final class LiveLocationSummaryManagerImpl: LiveLocationSummaryManager {
|
||||
private let queue: Queue
|
||||
private let engine: TelegramEngine
|
||||
private let postbox: Postbox
|
||||
private let accountPeerId: PeerId
|
||||
private let viewTracker: AccountViewTracker
|
||||
private let accountPeerId: EnginePeer.Id
|
||||
|
||||
private let globalContext: LiveLocationSummaryContext
|
||||
private var peerContexts: [PeerId: LiveLocationPeerSummaryContext] = [:]
|
||||
private var peerContexts: [EnginePeer.Id: LiveLocationPeerSummaryContext] = [:]
|
||||
|
||||
init(queue: Queue, engine: TelegramEngine, postbox: Postbox, accountPeerId: PeerId, viewTracker: AccountViewTracker) {
|
||||
init(queue: Queue, engine: TelegramEngine, accountPeerId: EnginePeer.Id) {
|
||||
assert(queue.isCurrent())
|
||||
self.queue = queue
|
||||
self.engine = engine
|
||||
self.postbox = postbox
|
||||
self.accountPeerId = accountPeerId
|
||||
self.viewTracker = viewTracker
|
||||
|
||||
self.globalContext = LiveLocationSummaryContext(queue: queue, postbox: postbox)
|
||||
self.globalContext = LiveLocationSummaryContext(queue: queue, engine: engine)
|
||||
}
|
||||
|
||||
func update(messageIds: Set<MessageId>) {
|
||||
var peerIds = Set<PeerId>()
|
||||
func update(messageIds: Set<EngineMessage.Id>) {
|
||||
var peerIds = Set<EnginePeer.Id>()
|
||||
for id in messageIds {
|
||||
peerIds.insert(id.peerId)
|
||||
}
|
||||
|
||||
for peerId in peerIds {
|
||||
if self.peerContexts[peerId] == nil {
|
||||
let context = LiveLocationPeerSummaryContext(queue: self.queue, engine: self.engine, accountPeerId: self.accountPeerId, viewTracker: self.viewTracker, peerId: peerId, becameEmpty: { [weak self] in
|
||||
let context = LiveLocationPeerSummaryContext(queue: self.queue, engine: self.engine, accountPeerId: self.accountPeerId, peerId: peerId, becameEmpty: { [weak self] in
|
||||
if let strongSelf = self, let context = strongSelf.peerContexts[peerId], context.isEmpty {
|
||||
strongSelf.peerContexts.removeValue(forKey: peerId)
|
||||
}
|
||||
|
|
@ -231,11 +226,11 @@ public final class LiveLocationSummaryManagerImpl: LiveLocationSummaryManager {
|
|||
self.globalContext.messageIds = messageIds
|
||||
}
|
||||
|
||||
public func broadcastingToMessages() -> Signal<[MessageId: Message], NoError> {
|
||||
public func broadcastingToMessages() -> Signal<[EngineMessage.Id: EngineMessage], NoError> {
|
||||
return self.globalContext.subscribe()
|
||||
}
|
||||
|
||||
public func peersBroadcastingTo(peerId: PeerId) -> Signal<[(Peer, Message)]?, NoError> {
|
||||
public func peersBroadcastingTo(peerId: EnginePeer.Id) -> Signal<[(EnginePeer, EngineMessage)]?, NoError> {
|
||||
let queue = self.queue
|
||||
return Signal { [weak self] subscriber in
|
||||
let disposable = MetaDisposable()
|
||||
|
|
@ -245,7 +240,7 @@ public final class LiveLocationSummaryManagerImpl: LiveLocationSummaryManager {
|
|||
if let current = strongSelf.peerContexts[peerId] {
|
||||
context = current
|
||||
} else {
|
||||
context = LiveLocationPeerSummaryContext(queue: strongSelf.queue, engine: strongSelf.engine, accountPeerId: strongSelf.accountPeerId, viewTracker: strongSelf.viewTracker, peerId: peerId, becameEmpty: {
|
||||
context = LiveLocationPeerSummaryContext(queue: strongSelf.queue, engine: strongSelf.engine, accountPeerId: strongSelf.accountPeerId, peerId: peerId, becameEmpty: {
|
||||
if let strongSelf = self, let context = strongSelf.peerContexts[peerId], context.isEmpty {
|
||||
strongSelf.peerContexts.removeValue(forKey: peerId)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -12,7 +12,6 @@ swift_library(
|
|||
deps = [
|
||||
"//submodules/AsyncDisplayKit:AsyncDisplayKit",
|
||||
"//submodules/Display:Display",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/AvatarNode:AvatarNode",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ swift_library(
|
|||
],
|
||||
deps = [
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramPresentationData:TelegramPresentationData",
|
||||
"//submodules/TelegramUIPreferences:TelegramUIPreferences",
|
||||
"//submodules/PhoneNumberFormat:PhoneNumberFormat",
|
||||
|
|
|
|||
|
|
@ -1,14 +1,13 @@
|
|||
import Foundation
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import TelegramUIPreferences
|
||||
import PhoneNumberFormat
|
||||
|
||||
public extension Peer {
|
||||
public extension EnginePeer {
|
||||
var compactDisplayTitle: String {
|
||||
switch self {
|
||||
case let user as TelegramUser:
|
||||
case let .user(user):
|
||||
if let firstName = user.firstName, !firstName.isEmpty {
|
||||
return firstName
|
||||
} else if let lastName = user.lastName, !lastName.isEmpty {
|
||||
|
|
@ -18,18 +17,18 @@ public extension Peer {
|
|||
} else {
|
||||
return ""
|
||||
}
|
||||
case let group as TelegramGroup:
|
||||
case let .legacyGroup(group):
|
||||
return group.title
|
||||
case let channel as TelegramChannel:
|
||||
case let .channel(channel):
|
||||
return channel.title
|
||||
default:
|
||||
case .secretChat:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
func displayTitle(strings: PresentationStrings, displayOrder: PresentationPersonNameOrder) -> String {
|
||||
switch self {
|
||||
case let user as TelegramUser:
|
||||
case let .user(user):
|
||||
if user.id.isReplies {
|
||||
return strings.DialogList_Replies
|
||||
}
|
||||
|
|
@ -51,22 +50,12 @@ public extension Peer {
|
|||
} else {
|
||||
return strings.User_DeletedAccount
|
||||
}
|
||||
case let group as TelegramGroup:
|
||||
case let .legacyGroup(group):
|
||||
return group.title
|
||||
case let channel as TelegramChannel:
|
||||
case let .channel(channel):
|
||||
return channel.title
|
||||
default:
|
||||
case .secretChat:
|
||||
return ""
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public extension EnginePeer {
|
||||
var compactDisplayTitle: String {
|
||||
return self._asPeer().compactDisplayTitle
|
||||
}
|
||||
|
||||
func displayTitle(strings: PresentationStrings, displayOrder: PresentationPersonNameOrder) -> String {
|
||||
return self._asPeer().displayTitle(strings: strings, displayOrder: displayOrder)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -159,7 +159,7 @@ final class LocationLiveListItemNode: ListViewItemNode {
|
|||
|
||||
var title: String = ""
|
||||
if let author = item.message.author {
|
||||
title = author.displayTitle(strings: item.presentationData.strings, displayOrder: item.nameDisplayOrder)
|
||||
title = EnginePeer(author).displayTitle(strings: item.presentationData.strings, displayOrder: item.nameDisplayOrder)
|
||||
}
|
||||
let titleAttributedString = NSAttributedString(string: title, font: titleFont, textColor: item.presentationData.theme.list.itemPrimaryTextColor)
|
||||
let (titleLayout, titleApply) = makeTitleLayout(TextNodeLayoutArguments(attributedString: titleAttributedString, backgroundColor: nil, maximumNumberOfLines: 1, truncationType: .end, constrainedSize: CGSize(width: params.width - leftInset - rightInset - 54.0, height: CGFloat.greatestFiniteMagnitude), alignment: .natural, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
|
|
|||
|
|
@ -126,7 +126,7 @@ public final class LocationPickerController: ViewController {
|
|||
let controller = ActionSheetController(presentationData: strongSelf.presentationData)
|
||||
var title = strongSelf.presentationData.strings.Map_LiveLocationGroupDescription
|
||||
if case let .share(peer, _, _) = strongSelf.mode, let receiver = peer as? TelegramUser {
|
||||
title = strongSelf.presentationData.strings.Map_LiveLocationPrivateDescription(receiver.compactDisplayTitle).string
|
||||
title = strongSelf.presentationData.strings.Map_LiveLocationPrivateDescription(EnginePeer(receiver).compactDisplayTitle).string
|
||||
}
|
||||
controller.setItemGroups([
|
||||
ActionSheetItemGroup(items: [
|
||||
|
|
|
|||
|
|
@ -240,7 +240,7 @@ public final class LocationViewController: ViewController {
|
|||
|
||||
var compactDisplayTitle: String?
|
||||
if let peer = peer as? TelegramUser {
|
||||
compactDisplayTitle = peer.compactDisplayTitle
|
||||
compactDisplayTitle = EnginePeer(peer).compactDisplayTitle
|
||||
}
|
||||
|
||||
let controller = LocationDistancePickerScreen(context: context, style: .default, compactDisplayTitle: compactDisplayTitle, distances: strongSelf.controllerNode.headerNode.mapNode.distancesToAllAnnotations, updated: { [weak self] distance in
|
||||
|
|
@ -345,7 +345,7 @@ public final class LocationViewController: ViewController {
|
|||
|
||||
var compactDisplayTitle: String?
|
||||
if let peer = peer as? TelegramUser {
|
||||
compactDisplayTitle = peer.compactDisplayTitle
|
||||
compactDisplayTitle = EnginePeer(peer).compactDisplayTitle
|
||||
}
|
||||
|
||||
var text: String
|
||||
|
|
@ -379,7 +379,7 @@ public final class LocationViewController: ViewController {
|
|||
let controller = ActionSheetController(presentationData: strongSelf.presentationData)
|
||||
var title = strongSelf.presentationData.strings.Map_LiveLocationGroupDescription
|
||||
if let user = peer as? TelegramUser {
|
||||
title = strongSelf.presentationData.strings.Map_LiveLocationPrivateDescription(user.compactDisplayTitle).string
|
||||
title = strongSelf.presentationData.strings.Map_LiveLocationPrivateDescription(EnginePeer(user).compactDisplayTitle).string
|
||||
}
|
||||
|
||||
let sendLiveLocationImpl: (Int32) -> Void = { [weak controller] period in
|
||||
|
|
|
|||
|
|
@ -720,7 +720,7 @@ final class LocationViewControllerNode: ViewControllerTracingNode, CLLocationMan
|
|||
|
||||
var text: String = strongSelf.presentationData.strings.Location_ProximityGroupTip
|
||||
if peer.id.namespace == Namespaces.Peer.CloudUser {
|
||||
text = strongSelf.presentationData.strings.Location_ProximityTip(peer.compactDisplayTitle).string
|
||||
text = strongSelf.presentationData.strings.Location_ProximityTip(EnginePeer(peer).compactDisplayTitle).string
|
||||
}
|
||||
|
||||
strongSelf.interaction.present(TooltipScreen(account: strongSelf.context.account, text: text, icon: nil, location: .point(location.offsetBy(dx: -9.0, dy: 0.0), .right), displayDuration: .custom(3.0), shouldDismissOnTouch: { _ in
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import TelegramCore
|
||||
import Postbox
|
||||
import TelegramPresentationData
|
||||
import TelegramStringFormatting
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import SwiftSignalKit
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
import AVFoundation
|
||||
import TelegramPresentationData
|
||||
|
|
|
|||
|
|
@ -57,13 +57,13 @@ final class SecureIdAuthFormContentNode: ASDisplayNode, SecureIdAuthContentNode,
|
|||
let privacyPolicyAttributes = MarkdownAttributeSet(font: infoFont, textColor: theme.list.freeTextColor)
|
||||
let privacyPolicyLinkAttributes = MarkdownAttributeSet(font: infoFont, textColor: theme.list.itemAccentColor, additionalAttributes: [NSAttributedString.Key.underlineStyle.rawValue: NSUnderlineStyle.single.rawValue as NSNumber, TelegramTextAttributes.URL: privacyPolicyUrl])
|
||||
|
||||
text = parseMarkdownIntoAttributedString(strings.Passport_PrivacyPolicy(peer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), (peer.addressName ?? "")).string.replacingOccurrences(of: "]", with: "]()"), attributes: MarkdownAttributes(body: privacyPolicyAttributes, bold: privacyPolicyAttributes, link: privacyPolicyLinkAttributes, linkAttribute: { _ in
|
||||
text = parseMarkdownIntoAttributedString(strings.Passport_PrivacyPolicy(EnginePeer(peer).displayTitle(strings: strings, displayOrder: nameDisplayOrder), (EnginePeer(peer).addressName ?? "")).string.replacingOccurrences(of: "]", with: "]()"), attributes: MarkdownAttributes(body: privacyPolicyAttributes, bold: privacyPolicyAttributes, link: privacyPolicyLinkAttributes, linkAttribute: { _ in
|
||||
return nil
|
||||
}), textAlignment: .center)
|
||||
|
||||
|
||||
} else {
|
||||
text = NSAttributedString(string: strings.Passport_AcceptHelp(peer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), (peer.addressName ?? "")).string, font: infoFont, textColor: theme.list.freeTextColor, paragraphAlignment: .left)
|
||||
text = NSAttributedString(string: strings.Passport_AcceptHelp(EnginePeer(peer).displayTitle(strings: strings, displayOrder: nameDisplayOrder), (peer.addressName ?? "")).string, font: infoFont, textColor: theme.list.freeTextColor, paragraphAlignment: .left)
|
||||
}
|
||||
self.textNode.attributedText = text
|
||||
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@ final class SecureIdAuthHeaderNode: ASDisplayNode {
|
|||
func updateState(formData: SecureIdEncryptedFormData?, verificationState: SecureIdAuthControllerVerificationState) {
|
||||
if let formData = formData {
|
||||
self.serviceAvatarNode.setPeer(context: self.context, theme: self.theme, peer: EnginePeer(formData.servicePeer))
|
||||
let titleData = self.strings.Passport_RequestHeader(formData.servicePeer.displayTitle(strings: self.strings, displayOrder: self.nameDisplayOrder))
|
||||
let titleData = self.strings.Passport_RequestHeader(EnginePeer(formData.servicePeer).displayTitle(strings: self.strings, displayOrder: self.nameDisplayOrder))
|
||||
|
||||
let titleString = NSMutableAttributedString()
|
||||
titleString.append(NSAttributedString(string: titleData.string, font: textFont, textColor: self.theme.list.freeTextColor))
|
||||
|
|
|
|||
|
|
@ -107,7 +107,7 @@ final class AvatarGalleryItemFooterContentNode: GalleryFooterContentNode {
|
|||
var buttonText: String?
|
||||
switch entry {
|
||||
case let .image(_, _, _, videoRepresentations, peer, date, _, _, _, _):
|
||||
nameText = peer?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""
|
||||
nameText = peer.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""
|
||||
if let date = date {
|
||||
dateText = humanReadableStringForTimestamp(strings: self.strings, dateTimeFormat: self.dateTimeFormat, timestamp: date).string
|
||||
}
|
||||
|
|
|
|||
|
|
@ -286,7 +286,7 @@ private enum ChannelAdminEntry: ItemListNodeEntry {
|
|||
let arguments = arguments as! ChannelAdminControllerArguments
|
||||
switch self {
|
||||
case let .info(_, _, dateTimeFormat, peer, presence):
|
||||
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .generic, peer: peer, presence: presence, cachedData: nil, state: ItemListAvatarAndNameInfoItemState(), sectionId: self.section, style: .blocks(withTopInset: true, withExtendedBottomInset: false), editingNameUpdated: { _ in
|
||||
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .generic, peer: EnginePeer(peer), presence: presence.flatMap(EnginePeer.Presence.init), memberCount: nil, state: ItemListAvatarAndNameInfoItemState(), sectionId: self.section, style: .blocks(withTopInset: true, withExtendedBottomInset: false), editingNameUpdated: { _ in
|
||||
}, avatarTapped: {
|
||||
})
|
||||
case let .rankTitle(_, text, count, limit):
|
||||
|
|
@ -987,9 +987,9 @@ public func channelAdminController(context: AccountContext, updatedPresentationD
|
|||
if let admin = adminView.peers[adminView.peerId] {
|
||||
switch channel.info {
|
||||
case .broadcast:
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToChannelError(admin.compactDisplayTitle, admin.compactDisplayTitle).string
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToChannelError(EnginePeer(admin).compactDisplayTitle, EnginePeer(admin).compactDisplayTitle).string
|
||||
case .group:
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(admin.compactDisplayTitle, admin.compactDisplayTitle).string
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(EnginePeer(admin).compactDisplayTitle, EnginePeer(admin).compactDisplayTitle).string
|
||||
}
|
||||
}
|
||||
case .notMutualContact:
|
||||
|
|
@ -1071,9 +1071,9 @@ public func channelAdminController(context: AccountContext, updatedPresentationD
|
|||
case .restricted:
|
||||
switch channel.info {
|
||||
case .broadcast:
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToChannelError(admin.compactDisplayTitle, admin.compactDisplayTitle).string
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToChannelError(EnginePeer(admin).compactDisplayTitle, EnginePeer(admin).compactDisplayTitle).string
|
||||
case .group:
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(admin.compactDisplayTitle, admin.compactDisplayTitle).string
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(EnginePeer(admin).compactDisplayTitle, EnginePeer(admin).compactDisplayTitle).string
|
||||
}
|
||||
case .notMutualContact:
|
||||
if case .broadcast = channel.info {
|
||||
|
|
@ -1132,7 +1132,7 @@ public func channelAdminController(context: AccountContext, updatedPresentationD
|
|||
updateRightsDisposable.set((context.engine.peers.addGroupAdmin(peerId: peerId, adminId: adminId)
|
||||
|> deliverOnMainQueue).start(error: { error in
|
||||
if case let .addMemberError(error) = error, case .privacy = error, let admin = adminView.peers[adminView.peerId] {
|
||||
presentControllerImpl?(textAlertController(context: context, updatedPresentationData: updatedPresentationData, title: nil, text: presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(admin.compactDisplayTitle, admin.compactDisplayTitle).string, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
presentControllerImpl?(textAlertController(context: context, updatedPresentationData: updatedPresentationData, title: nil, text: presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(EnginePeer(admin).compactDisplayTitle, EnginePeer(admin).compactDisplayTitle).string, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
} else if case .adminsTooMuch = error {
|
||||
presentControllerImpl?(textAlertController(context: context, updatedPresentationData: updatedPresentationData, title: nil, text: presentationData.strings.Group_ErrorAdminsTooMuch, actions: [TextAlertAction(type: .defaultAction, title: presentationData.strings.Common_OK, action: {})]), nil)
|
||||
}
|
||||
|
|
@ -1192,7 +1192,7 @@ public func channelAdminController(context: AccountContext, updatedPresentationD
|
|||
if case let .addMemberError(error) = error {
|
||||
var text = presentationData.strings.Login_UnknownError
|
||||
if case .restricted = error, let admin = adminView.peers[adminView.peerId] {
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(admin.compactDisplayTitle, admin.compactDisplayTitle).string
|
||||
text = presentationData.strings.Privacy_GroupsAndChannels_InviteToGroupError(EnginePeer(admin).compactDisplayTitle, EnginePeer(admin).compactDisplayTitle).string
|
||||
} else if case .tooMuchJoined = error {
|
||||
text = presentationData.strings.Invite_ChannelsTooMuch
|
||||
}
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ private enum ChannelAdminsEntry: ItemListNodeEntry {
|
|||
if peer.id == participant.peer.id {
|
||||
peerText = strings.Channel_Management_LabelAdministrator
|
||||
} else {
|
||||
peerText = strings.Channel_Management_PromotedBy(peer.displayTitle(strings: strings, displayOrder: nameDisplayOrder)).string
|
||||
peerText = strings.Channel_Management_PromotedBy(EnginePeer(peer).displayTitle(strings: strings, displayOrder: nameDisplayOrder)).string
|
||||
}
|
||||
} else {
|
||||
peerText = ""
|
||||
|
|
@ -209,7 +209,7 @@ private enum ChannelAdminsEntry: ItemListNodeEntry {
|
|||
arguments.openAdmin(participant.participant)
|
||||
}
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: participant.peer, presence: nil, text: .text(peerText, .secondary), label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: action, setPeerIdWithRevealedOptions: { previousId, id in
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(participant.peer), presence: nil, text: .text(peerText, .secondary), label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: action, setPeerIdWithRevealedOptions: { previousId, id in
|
||||
arguments.setPeerIdWithRevealedOptions(previousId, id)
|
||||
}, removePeer: { peerId in
|
||||
arguments.removeAdmin(peerId)
|
||||
|
|
@ -516,7 +516,7 @@ public func channelAdminsController(context: AccountContext, updatedPresentation
|
|||
guard let peer = peer, let user = user else {
|
||||
return
|
||||
}
|
||||
presentControllerImpl?(UndoOverlayController(presentationData: context.sharedContext.currentPresentationData.with { $0 }, content: .succeed(text: presentationData.strings.Channel_OwnershipTransfer_TransferCompleted(user.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string), elevatedLayout: false, action: { _ in return false }), nil)
|
||||
presentControllerImpl?(UndoOverlayController(presentationData: context.sharedContext.currentPresentationData.with { $0 }, content: .succeed(text: presentationData.strings.Channel_OwnershipTransfer_TransferCompleted(EnginePeer(user).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string), elevatedLayout: false, action: { _ in return false }), nil)
|
||||
})
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -207,7 +207,7 @@ private enum ChannelBannedMemberEntry: ItemListNodeEntry {
|
|||
let arguments = arguments as! ChannelBannedMemberControllerArguments
|
||||
switch self {
|
||||
case let .info(_, _, dateTimeFormat, peer, presence):
|
||||
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .generic, peer: peer, presence: presence, cachedData: nil, state: ItemListAvatarAndNameInfoItemState(), sectionId: self.section, style: .blocks(withTopInset: true, withExtendedBottomInset: false), editingNameUpdated: { _ in
|
||||
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .generic, peer: EnginePeer(peer), presence: presence.flatMap(EnginePeer.Presence.init), memberCount: nil, state: ItemListAvatarAndNameInfoItemState(), sectionId: self.section, style: .blocks(withTopInset: true, withExtendedBottomInset: false), editingNameUpdated: { _ in
|
||||
}, avatarTapped: {
|
||||
})
|
||||
case let .rightsHeader(_, text):
|
||||
|
|
@ -300,7 +300,7 @@ private func channelBannedMemberControllerEntries(presentationData: Presentation
|
|||
entries.append(.timeout(presentationData.theme, presentationData.strings.GroupPermission_Duration, currentTimeoutString))
|
||||
|
||||
if let initialParticipant = initialParticipant, case let .member(_, _, _, banInfo?, _) = initialParticipant, let initialBannedBy = initialBannedBy {
|
||||
entries.append(.exceptionInfo(presentationData.theme, presentationData.strings.GroupPermission_AddedInfo(initialBannedBy.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), stringForRelativeSymbolicTimestamp(strings: presentationData.strings, relativeTimestamp: banInfo.timestamp, relativeTo: state.referenceTimestamp, dateTimeFormat: presentationData.dateTimeFormat)).string))
|
||||
entries.append(.exceptionInfo(presentationData.theme, presentationData.strings.GroupPermission_AddedInfo(EnginePeer(initialBannedBy).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), stringForRelativeSymbolicTimestamp(strings: presentationData.strings, relativeTimestamp: banInfo.timestamp, relativeTo: state.referenceTimestamp, dateTimeFormat: presentationData.dateTimeFormat)).string))
|
||||
entries.append(.delete(presentationData.theme, presentationData.strings.GroupPermission_Delete))
|
||||
}
|
||||
} else if let group = channelView.peers[channelView.peerId] as? TelegramGroup, let member = memberView.peers[memberView.peerId] {
|
||||
|
|
@ -346,7 +346,7 @@ private func channelBannedMemberControllerEntries(presentationData: Presentation
|
|||
entries.append(.timeout(presentationData.theme, presentationData.strings.GroupPermission_Duration, currentTimeoutString))
|
||||
|
||||
if let initialParticipant = initialParticipant, case let .member(_, _, _, banInfo?, _) = initialParticipant, let initialBannedBy = initialBannedBy {
|
||||
entries.append(.exceptionInfo(presentationData.theme, presentationData.strings.GroupPermission_AddedInfo(initialBannedBy.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), stringForRelativeSymbolicTimestamp(strings: presentationData.strings, relativeTimestamp: banInfo.timestamp, relativeTo: state.referenceTimestamp, dateTimeFormat: presentationData.dateTimeFormat)).string))
|
||||
entries.append(.exceptionInfo(presentationData.theme, presentationData.strings.GroupPermission_AddedInfo(EnginePeer(initialBannedBy).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), stringForRelativeSymbolicTimestamp(strings: presentationData.strings, relativeTimestamp: banInfo.timestamp, relativeTo: state.referenceTimestamp, dateTimeFormat: presentationData.dateTimeFormat)).string))
|
||||
entries.append(.delete(presentationData.theme, presentationData.strings.GroupPermission_Delete))
|
||||
}
|
||||
}
|
||||
|
|
@ -695,7 +695,7 @@ public func channelBannedMemberController(context: AccountContext, updatedPresen
|
|||
let presentationData = updatedPresentationData?.initial ?? context.sharedContext.currentPresentationData.with { $0 }
|
||||
let actionSheet = ActionSheetController(presentationData: presentationData)
|
||||
var items: [ActionSheetItem] = []
|
||||
items.append(ActionSheetTextItem(title: presentationData.strings.GroupPermission_ApplyAlertText(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string))
|
||||
items.append(ActionSheetTextItem(title: presentationData.strings.GroupPermission_ApplyAlertText(EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string))
|
||||
items.append(ActionSheetButtonItem(title: presentationData.strings.GroupPermission_ApplyAlertAction, color: .accent, font: .default, enabled: true, action: { [weak actionSheet] in
|
||||
actionSheet?.dismissAnimated()
|
||||
applyRights()
|
||||
|
|
|
|||
|
|
@ -163,12 +163,12 @@ private enum ChannelBlacklistEntry: ItemListNodeEntry {
|
|||
switch participant.participant {
|
||||
case let .member(_, _, _, banInfo, _):
|
||||
if let banInfo = banInfo, let peer = participant.peers[banInfo.restrictedBy] {
|
||||
text = .text(strings.Channel_Management_RemovedBy(peer.displayTitle(strings: strings, displayOrder: nameDisplayOrder)).string, .secondary)
|
||||
text = .text(strings.Channel_Management_RemovedBy(EnginePeer(peer).displayTitle(strings: strings, displayOrder: nameDisplayOrder)).string, .secondary)
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: participant.peer, presence: nil, text: text, label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(participant.peer), presence: nil, text: text, label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: {
|
||||
arguments.openPeer(participant)
|
||||
}, setPeerIdWithRevealedOptions: { previousId, id in
|
||||
arguments.setPeerIdWithRevealedOptions(previousId, id)
|
||||
|
|
@ -356,8 +356,8 @@ public func channelBlacklistController(context: AccountContext, updatedPresentat
|
|||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
let actionSheet = ActionSheetController(presentationData: presentationData)
|
||||
var items: [ActionSheetItem] = []
|
||||
if !participant.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder).isEmpty {
|
||||
items.append(ActionSheetTextItem(title: participant.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)))
|
||||
if !EnginePeer(participant.peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder).isEmpty {
|
||||
items.append(ActionSheetTextItem(title: EnginePeer(participant.peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)))
|
||||
}
|
||||
let viewInfoTitle: String
|
||||
if participant.peer is TelegramChannel {
|
||||
|
|
|
|||
|
|
@ -70,9 +70,9 @@ private final class ChannelDiscussionGroupActionSheetItemNode: ActionSheetItemNo
|
|||
|
||||
let text: PresentationStrings.FormattedString
|
||||
if let channelPeer = channelPeer as? TelegramChannel, let addressName = channelPeer.addressName, !addressName.isEmpty {
|
||||
text = strings.Channel_DiscussionGroup_PublicChannelLink(groupPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), channelPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder))
|
||||
text = strings.Channel_DiscussionGroup_PublicChannelLink(EnginePeer(groupPeer).displayTitle(strings: strings, displayOrder: nameDisplayOrder), EnginePeer(channelPeer).displayTitle(strings: strings, displayOrder: nameDisplayOrder))
|
||||
} else {
|
||||
text = strings.Channel_DiscussionGroup_PrivateChannelLink(groupPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder), channelPeer.displayTitle(strings: strings, displayOrder: nameDisplayOrder))
|
||||
text = strings.Channel_DiscussionGroup_PrivateChannelLink(EnginePeer(groupPeer).displayTitle(strings: strings, displayOrder: nameDisplayOrder), EnginePeer(channelPeer).displayTitle(strings: strings, displayOrder: nameDisplayOrder))
|
||||
}
|
||||
|
||||
let textFont = Font.regular(floor(theme.baseFontSize * 14.0 / 17.0))
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ private final class ChannelDiscussionGroupSearchEntry: Comparable, Identifiable
|
|||
func item(context: AccountContext, presentationData: PresentationData, interaction: ChannelDiscussionGroupSearchInteraction) -> ListViewItem {
|
||||
switch self.content {
|
||||
case let .peer(peer):
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: .firstLast, displayOrder: .firstLast, context: context, peerMode: .peer, peer: .peer(peer: peer, chatPeer: peer), status: .none, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: nil, action: { _ in
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: .firstLast, displayOrder: .firstLast, context: context, peerMode: .peer, peer: .peer(peer: EnginePeer(peer), chatPeer: EnginePeer(peer)), status: .none, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: nil, action: { _ in
|
||||
interaction.peerSelected(peer)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,7 +156,7 @@ private enum ChannelDiscussionGroupSetupControllerEntry: ItemListNodeEntry {
|
|||
} else {
|
||||
text = strings.Channel_DiscussionGroup_PrivateChannel
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: nameOrder, context: arguments.context, peer: peer, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .text(text, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: nameOrder, context: arguments.context, peer: EnginePeer(peer), aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .text(text, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
arguments.selectGroup(peer.id)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in }, removePeer: { _ in })
|
||||
case let .groupsInfo(_, title):
|
||||
|
|
@ -181,9 +181,9 @@ private func channelDiscussionGroupSetupControllerEntries(presentationData: Pres
|
|||
if case let .known(maybeLinkedDiscussionPeerId) = cachedData.linkedDiscussionPeerId, let linkedDiscussionPeerId = maybeLinkedDiscussionPeerId {
|
||||
if let group = view.peers[linkedDiscussionPeerId] {
|
||||
if case .group = peer.info {
|
||||
entries.append(.header(presentationData.theme, presentationData.strings, group.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), true, presentationData.strings.Channel_DiscussionGroup_HeaderLabel))
|
||||
entries.append(.header(presentationData.theme, presentationData.strings, EnginePeer(group).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), true, presentationData.strings.Channel_DiscussionGroup_HeaderLabel))
|
||||
} else {
|
||||
entries.append(.header(presentationData.theme, presentationData.strings, group.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), false, presentationData.strings.Channel_DiscussionGroup_HeaderLabel))
|
||||
entries.append(.header(presentationData.theme, presentationData.strings, EnginePeer(group).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), false, presentationData.strings.Channel_DiscussionGroup_HeaderLabel))
|
||||
}
|
||||
|
||||
entries.append(.group(0, presentationData.theme, presentationData.strings, group, presentationData.nameDisplayOrder))
|
||||
|
|
@ -258,7 +258,7 @@ public func channelDiscussionGroupSetupController(context: AccountContext, updat
|
|||
return
|
||||
}
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
pushControllerImpl?(context.sharedContext.makeCreateGroupController(context: context, peerIds: [], initialTitle: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) + " Chat", mode: .supergroup, completion: { groupId, dismiss in
|
||||
pushControllerImpl?(context.sharedContext.makeCreateGroupController(context: context, peerIds: [], initialTitle: EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder) + " Chat", mode: .supergroup, completion: { groupId, dismiss in
|
||||
var applySignal = context.engine.peers.updateGroupDiscussionForChannel(channelId: peerId, groupId: groupId)
|
||||
var cancelImpl: (() -> Void)?
|
||||
let progressSignal = Signal<Never, NoError> { subscriber in
|
||||
|
|
|
|||
|
|
@ -327,7 +327,7 @@ private enum ChannelInfoEntry: ItemListNodeEntry {
|
|||
let arguments = arguments as! ChannelInfoControllerArguments
|
||||
switch self {
|
||||
case let .info(_, _, dateTimeFormat, peer, cachedData, state, updatingAvatar):
|
||||
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .generic, peer: peer, presence: nil, cachedData: cachedData, state: state, sectionId: self.section, style: .plain, editingNameUpdated: { editingName in
|
||||
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .generic, peer: peer.flatMap(EnginePeer.init), presence: nil, memberCount: (cachedData as? CachedChannelData)?.participantsSummary.memberCount.flatMap(Int.init), state: state, sectionId: self.section, style: .plain, editingNameUpdated: { editingName in
|
||||
arguments.updateEditingName(editingName)
|
||||
}, avatarTapped: {
|
||||
arguments.tapAvatarAction()
|
||||
|
|
@ -500,7 +500,7 @@ private func channelInfoEntries(account: Account, presentationData: Presentation
|
|||
if let addressName = peer.addressName, !addressName.isEmpty {
|
||||
discussionGroupTitle = "@\(addressName)"
|
||||
} else {
|
||||
discussionGroupTitle = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
discussionGroupTitle = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
}
|
||||
} else {
|
||||
discussionGroupTitle = presentationData.strings.Channel_DiscussionGroupAdd
|
||||
|
|
@ -535,7 +535,7 @@ private func channelInfoEntries(account: Account, presentationData: Presentation
|
|||
if let addressName = peer.addressName, !addressName.isEmpty {
|
||||
discussionGroupTitle = "@\(addressName)"
|
||||
} else {
|
||||
discussionGroupTitle = peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
discussionGroupTitle = EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
}
|
||||
} else if canEditChannel {
|
||||
discussionGroupTitle = presentationData.strings.Channel_DiscussionGroupAdd
|
||||
|
|
@ -756,7 +756,7 @@ public func channelInfoController(context: AccountContext, peerId: PeerId) -> Vi
|
|||
let mixin = TGMediaAvatarMenuMixin(context: legacyController.context, parentController: emptyController, hasSearchButton: true, hasDeleteButton: hasPhotos, hasViewButton: false, personalPhoto: false, isVideo: false, saveEditedPhotos: false, saveCapturedMedia: false, signup: true)!
|
||||
let _ = currentAvatarMixin.swap(mixin)
|
||||
mixin.requestSearchController = { assetsController in
|
||||
let controller = WebSearchController(context: context, peer: peer, chatLocation: nil, configuration: searchBotsConfiguration, mode: .avatar(initialQuery: peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), completion: { result in
|
||||
let controller = WebSearchController(context: context, peer: peer, chatLocation: nil, configuration: searchBotsConfiguration, mode: .avatar(initialQuery: peer.flatMap(EnginePeer.init)?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), completion: { result in
|
||||
assetsController?.dismiss()
|
||||
completedImpl(result)
|
||||
}))
|
||||
|
|
@ -1027,7 +1027,7 @@ public func channelInfoController(context: AccountContext, peerId: PeerId) -> Vi
|
|||
text = about
|
||||
}
|
||||
updateState { state in
|
||||
return state.withUpdatedEditingState(ChannelInfoEditingState(editingName: ItemListAvatarAndNameInfoItemName(channel), editingDescriptionText: text))
|
||||
return state.withUpdatedEditingState(ChannelInfoEditingState(editingName: ItemListAvatarAndNameInfoItemName(EnginePeer(channel)), editingDescriptionText: text))
|
||||
}
|
||||
}
|
||||
})
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ private enum ChannelMembersEntry: ItemListNodeEntry {
|
|||
} else {
|
||||
text = .presence
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: participant.peer, presence: participant.presences[participant.peer.id], text: text, label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: participant.peer.id != arguments.context.account.peerId, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(participant.peer), presence: participant.presences[participant.peer.id].flatMap(EnginePeer.Presence.init), text: text, label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: participant.peer.id != arguments.context.account.peerId, sectionId: self.section, action: {
|
||||
arguments.openPeer(participant.peer)
|
||||
}, setPeerIdWithRevealedOptions: { previousId, id in
|
||||
arguments.setPeerIdWithRevealedOptions(previousId, id)
|
||||
|
|
|
|||
|
|
@ -153,7 +153,7 @@ private final class ChannelMembersSearchEntry: Comparable, Identifiable {
|
|||
func item(context: AccountContext, presentationData: PresentationData, nameSortOrder: PresentationPersonNameOrder, nameDisplayOrder: PresentationPersonNameOrder, interaction: ChannelMembersSearchContainerInteraction) -> ListViewItem {
|
||||
switch self.content {
|
||||
case let .peer(peer):
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: peer, chatPeer: peer), status: .none, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: self.section.chatListHeaderType.flatMap({ ChatListSearchItemHeader(type: $0, theme: presentationData.theme, strings: presentationData.strings, actionTitle: nil, action: nil) }), action: { _ in
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: EnginePeer(peer), chatPeer: EnginePeer(peer)), status: .none, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: self.section.chatListHeaderType.flatMap({ ChatListSearchItemHeader(type: $0, theme: presentationData.theme, strings: presentationData.strings, actionTitle: nil, action: nil) }), action: { _ in
|
||||
interaction.peerSelected(peer, nil)
|
||||
})
|
||||
case let .participant(participant, label, revealActions, revealed, enabled):
|
||||
|
|
@ -161,7 +161,7 @@ private final class ChannelMembersSearchEntry: Comparable, Identifiable {
|
|||
if let label = label {
|
||||
status = .custom(string: label, multiline: false)
|
||||
} else if let presence = participant.presences[participant.peer.id], self.addIcon {
|
||||
status = .presence(presence, dateTimeFormat)
|
||||
status = .presence(EnginePeer.Presence(presence), dateTimeFormat)
|
||||
} else {
|
||||
status = .none
|
||||
}
|
||||
|
|
@ -187,7 +187,7 @@ private final class ChannelMembersSearchEntry: Comparable, Identifiable {
|
|||
actionIcon = .add
|
||||
}
|
||||
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: participant.peer, chatPeer: participant.peer), status: status, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: revealed), options: options, actionIcon: actionIcon, index: nil, header: self.section.chatListHeaderType.flatMap({ ChatListSearchItemHeader(type: $0, theme: presentationData.theme, strings: presentationData.strings, actionTitle: nil, action: nil) }), action: { _ in
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: EnginePeer(participant.peer), chatPeer: EnginePeer(participant.peer)), status: status, enabled: enabled, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: revealed), options: options, actionIcon: actionIcon, index: nil, header: self.section.chatListHeaderType.flatMap({ ChatListSearchItemHeader(type: $0, theme: presentationData.theme, strings: presentationData.strings, actionTitle: nil, action: nil) }), action: { _ in
|
||||
interaction.peerSelected(participant.peer, participant)
|
||||
}, setPeerIdWithRevealedOptions: { peerId, fromPeerId in
|
||||
interaction.setPeerIdWithRevealedOptions(RevealedPeerId(peerId: participant.peer.id, section: self.section), fromPeerId.flatMap({ RevealedPeerId(peerId: $0, section: self.section) }))
|
||||
|
|
@ -816,7 +816,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||
if peer.id == participant.peer.id {
|
||||
label = presentationData.strings.Channel_Management_LabelAdministrator
|
||||
} else {
|
||||
label = presentationData.strings.Channel_Management_PromotedBy(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
label = presentationData.strings.Channel_Management_PromotedBy(EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -843,7 +843,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||
switch participant.participant {
|
||||
case let .member(_, _, _, banInfo, _):
|
||||
if let banInfo = banInfo, let peer = participant.peers[banInfo.restrictedBy] {
|
||||
label = presentationData.strings.Channel_Management_RemovedBy(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
label = presentationData.strings.Channel_Management_RemovedBy(EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
}
|
||||
default:
|
||||
break
|
||||
|
|
@ -1076,7 +1076,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||
if peer.id == participant.peer.id {
|
||||
label = presentationData.strings.Channel_Management_LabelAdministrator
|
||||
} else {
|
||||
label = presentationData.strings.Channel_Management_PromotedBy(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
label = presentationData.strings.Channel_Management_PromotedBy(EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -1103,7 +1103,7 @@ public final class ChannelMembersSearchContainerNode: SearchDisplayControllerCon
|
|||
switch participant.participant {
|
||||
case let .member(_, _, _, banInfo, _):
|
||||
if let banInfo = banInfo, let peer = participant.peers[banInfo.restrictedBy] {
|
||||
label = presentationData.strings.Channel_Management_RemovedBy(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
label = presentationData.strings.Channel_Management_RemovedBy(EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
}
|
||||
default:
|
||||
break
|
||||
|
|
|
|||
|
|
@ -133,23 +133,23 @@ private enum ChannelMembersSearchEntry: Comparable, Identifiable {
|
|||
status = .custom(string: label, multiline: false)
|
||||
} else if participant.peer.id != context.account.peerId {
|
||||
let presence = participant.presences[participant.peer.id] ?? TelegramUserPresence(status: .none, lastActivity: 0)
|
||||
status = .presence(presence, presentationData.dateTimeFormat)
|
||||
status = .presence(EnginePeer.Presence(presence), presentationData.dateTimeFormat)
|
||||
} else {
|
||||
status = .none
|
||||
}
|
||||
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: participant.peer, chatPeer: nil), status: status, enabled: enabled, selection: .none, editing: editing, index: nil, header: ChatListSearchItemHeader(type: .groupMembers, theme: presentationData.theme, strings: presentationData.strings), action: { _ in
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: EnginePeer(participant.peer), chatPeer: nil), status: status, enabled: enabled, selection: .none, editing: editing, index: nil, header: ChatListSearchItemHeader(type: .groupMembers, theme: presentationData.theme, strings: presentationData.strings), action: { _ in
|
||||
interaction.openPeer(participant.peer, participant)
|
||||
})
|
||||
case let .contact(_, peer, presence):
|
||||
let status: ContactsPeerItemStatus
|
||||
if peer.id != context.account.peerId, let presence = presence {
|
||||
status = .presence(presence, presentationData.dateTimeFormat)
|
||||
status = .presence(EnginePeer.Presence(presence), presentationData.dateTimeFormat)
|
||||
} else {
|
||||
status = .none
|
||||
}
|
||||
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: peer, chatPeer: nil), status: status, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: ChatListSearchItemHeader(type: .contacts, theme: presentationData.theme, strings: presentationData.strings), action: { _ in
|
||||
return ContactsPeerItem(presentationData: ItemListPresentationData(presentationData), sortOrder: nameSortOrder, displayOrder: nameDisplayOrder, context: context, peerMode: .peer, peer: .peer(peer: EnginePeer(peer), chatPeer: nil), status: status, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), index: nil, header: ChatListSearchItemHeader(type: .contacts, theme: presentationData.theme, strings: presentationData.strings), action: { _ in
|
||||
interaction.openPeer(peer, nil)
|
||||
})
|
||||
}
|
||||
|
|
|
|||
|
|
@ -541,10 +541,10 @@ private func confirmChannelOwnershipTransferController(context: AccountContext,
|
|||
var text: String
|
||||
if isGroup {
|
||||
title = presentationData.strings.Group_OwnershipTransfer_Title
|
||||
text = presentationData.strings.Group_OwnershipTransfer_DescriptionInfo(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), member.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
text = presentationData.strings.Group_OwnershipTransfer_DescriptionInfo(EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), EnginePeer(member).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
} else {
|
||||
title = presentationData.strings.Channel_OwnershipTransfer_Title
|
||||
text = presentationData.strings.Channel_OwnershipTransfer_DescriptionInfo(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), member.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
text = presentationData.strings.Channel_OwnershipTransfer_DescriptionInfo(EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), EnginePeer(member).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)).string
|
||||
}
|
||||
|
||||
let attributedTitle = NSAttributedString(string: title, font: Font.medium(17.0), textColor: theme.primaryColor, paragraphAlignment: .center)
|
||||
|
|
|
|||
|
|
@ -315,7 +315,7 @@ private enum ChannelPermissionsEntry: ItemListNodeEntry {
|
|||
default:
|
||||
break
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: participant.peer, presence: nil, text: text, label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: canOpen ? {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(participant.peer), presence: nil, text: text, label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: canOpen ? {
|
||||
arguments.openPeer(participant.participant)
|
||||
} : {
|
||||
arguments.openPeerInfo(participant.peer)
|
||||
|
|
|
|||
|
|
@ -350,7 +350,7 @@ private enum ChannelVisibilityEntry: ItemListNodeEntry {
|
|||
if let addressName = peer.addressName {
|
||||
label = "t.me/" + addressName
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer, presence: nil, text: .text(label, .secondary), label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: nil, setPeerIdWithRevealedOptions: { previousId, id in
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(peer), presence: nil, text: .text(label, .secondary), label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: nil, setPeerIdWithRevealedOptions: { previousId, id in
|
||||
arguments.setPeerIdWithRevealedOptions(previousId, id)
|
||||
}, removePeer: { peerId in
|
||||
arguments.revokePeerId(peerId)
|
||||
|
|
|
|||
|
|
@ -396,7 +396,7 @@ private enum DeviceContactInfoEntry: ItemListNodeEntry {
|
|||
let arguments = arguments as! DeviceContactInfoControllerArguments
|
||||
switch self {
|
||||
case let .info(_, _, _, dateTimeFormat, peer, state, jobSummary, _):
|
||||
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .contact, peer: peer, presence: nil, label: jobSummary, cachedData: nil, state: state, sectionId: self.section, style: arguments.isPlain ? .plain : .blocks(withTopInset: false, withExtendedBottomInset: true), editingNameUpdated: { editingName in
|
||||
return ItemListAvatarAndNameInfoItem(accountContext: arguments.context, presentationData: presentationData, dateTimeFormat: dateTimeFormat, mode: .contact, peer: EnginePeer(peer), presence: nil, label: jobSummary, memberCount: nil, state: state, sectionId: self.section, style: arguments.isPlain ? .plain : .blocks(withTopInset: false, withExtendedBottomInset: true), editingNameUpdated: { editingName in
|
||||
arguments.updateEditingName(editingName)
|
||||
}, avatarTapped: {
|
||||
}, context: nil, call: nil)
|
||||
|
|
@ -685,7 +685,7 @@ private func deviceContactInfoEntries(account: Account, presentationData: Presen
|
|||
} else if !personName.1.isEmpty {
|
||||
personCompactName = personName.1
|
||||
} else {
|
||||
personCompactName = peer.compactDisplayTitle
|
||||
personCompactName = EnginePeer(peer).compactDisplayTitle
|
||||
}
|
||||
|
||||
if contactData.basicData.phoneNumbers.isEmpty {
|
||||
|
|
|
|||
|
|
@ -172,7 +172,7 @@ private enum OldChannelsEntry: ItemListNodeEntry {
|
|||
case let .peersHeader(title):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: title, sectionId: self.section)
|
||||
case let .peer(_, peer, selected):
|
||||
return ContactsPeerItem(presentationData: presentationData, style: .blocks, sectionId: self.section, sortOrder: .firstLast, displayOrder: .firstLast, context: arguments.context, peerMode: .peer, peer: .peer(peer: peer.peer, chatPeer: peer.peer), status: .custom(string: localizedOldChannelDate(peer: peer, strings: presentationData.strings), multiline: false), badge: nil, enabled: true, selection: ContactsPeerItemSelection.selectable(selected: selected), editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), options: [], actionIcon: .none, index: nil, header: nil, action: { _ in
|
||||
return ContactsPeerItem(presentationData: presentationData, style: .blocks, sectionId: self.section, sortOrder: .firstLast, displayOrder: .firstLast, context: arguments.context, peerMode: .peer, peer: .peer(peer: EnginePeer(peer.peer), chatPeer: EnginePeer(peer.peer)), status: .custom(string: localizedOldChannelDate(peer: peer, strings: presentationData.strings), multiline: false), badge: nil, enabled: true, selection: ContactsPeerItemSelection.selectable(selected: selected), editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), options: [], actionIcon: .none, index: nil, header: nil, action: { _ in
|
||||
arguments.togglePeer(peer.peer.id, true)
|
||||
}, setPeerIdWithRevealedOptions: nil, deletePeer: nil, itemHighlighting: nil, contextAction: nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ private enum OldChannelsSearchEntry: Comparable, Identifiable {
|
|||
func item(context: AccountContext, presentationData: ItemListPresentationData, interaction: OldChannelsSearchInteraction) -> ListViewItem {
|
||||
switch self {
|
||||
case let .peer(_, peer, selected):
|
||||
return ContactsPeerItem(presentationData: presentationData, style: .plain, sortOrder: .firstLast, displayOrder: .firstLast, context: context, peerMode: .peer, peer: .peer(peer: peer.peer, chatPeer: peer.peer), status: .custom(string: localizedOldChannelDate(peer: peer, strings: presentationData.strings), multiline: false), badge: nil, enabled: true, selection: ContactsPeerItemSelection.selectable(selected: selected), editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), options: [], actionIcon: .none, index: nil, header: nil, action: { _ in
|
||||
return ContactsPeerItem(presentationData: presentationData, style: .plain, sortOrder: .firstLast, displayOrder: .firstLast, context: context, peerMode: .peer, peer: .peer(peer: EnginePeer(peer.peer), chatPeer: EnginePeer(peer.peer)), status: .custom(string: localizedOldChannelDate(peer: peer, strings: presentationData.strings), multiline: false), badge: nil, enabled: true, selection: ContactsPeerItemSelection.selectable(selected: selected), editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), options: [], actionIcon: .none, index: nil, header: nil, action: { _ in
|
||||
interaction.togglePeer(peer.peer.id)
|
||||
}, setPeerIdWithRevealedOptions: nil, deletePeer: nil, itemHighlighting: nil, contextAction: nil)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -118,7 +118,7 @@ final class SecretChatKeyControllerNode: ViewControllerTracingNode {
|
|||
|
||||
let (keyTextLayout, keyTextApply) = makeKeyTextLayout(TextNodeLayoutArguments(attributedString: NSAttributedString(string: text, font: Font.semiboldMonospace(15.0), textColor: self.presentationData.theme.list.itemPrimaryTextColor), backgroundColor: nil, maximumNumberOfLines: 0, truncationType: .end, constrainedSize: CGSize(width: layout.size.width - sideInset * 2.0, height: CGFloat.greatestFiniteMagnitude), alignment: .left, lineSpacing: 0.0, cutout: nil, insets: UIEdgeInsets()))
|
||||
|
||||
let infoString = self.presentationData.strings.EncryptionKey_Description(self.peer.compactDisplayTitle, self.peer.compactDisplayTitle)
|
||||
let infoString = self.presentationData.strings.EncryptionKey_Description(EnginePeer(self.peer).compactDisplayTitle, EnginePeer(self.peer).compactDisplayTitle)
|
||||
let infoText = NSMutableAttributedString(string: infoString.string, attributes: [.font: Font.regular(14.0), .foregroundColor: self.presentationData.theme.list.itemPrimaryTextColor])
|
||||
|
||||
for range in infoString.ranges {
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ public func openAddPersonContactImpl(context: AccountContext, updatedPresentatio
|
|||
}
|
||||
|
||||
let presentationData = context.sharedContext.currentPresentationData.with { $0 }
|
||||
present(OverlayStatusController(theme: presentationData.theme, type: .genericSuccess(presentationData.strings.AddContact_StatusSuccess(peer.compactDisplayTitle).string, true)), nil)
|
||||
present(OverlayStatusController(theme: presentationData.theme, type: .genericSuccess(presentationData.strings.AddContact_StatusSuccess(EnginePeer(peer).compactDisplayTitle).string, true)), nil)
|
||||
}
|
||||
}), completed: nil, cancelled: nil))
|
||||
})
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ swift_library(
|
|||
],
|
||||
deps = [
|
||||
"//submodules/SSignalKit/SwiftSignalKit:SwiftSignalKit",
|
||||
"//submodules/Postbox:Postbox",
|
||||
"//submodules/TelegramCore:TelegramCore",
|
||||
],
|
||||
visibility = [
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@ import Foundation
|
|||
import SwiftSignalKit
|
||||
import TelegramCore
|
||||
|
||||
private func suggestedUserPresenceStringRefreshTimeout(_ presence: TelegramUserPresence, relativeTo timestamp: Int32, isOnline: Bool?) -> Double {
|
||||
private func suggestedUserPresenceStringRefreshTimeout(_ presence: EnginePeer.Presence, relativeTo timestamp: Int32, isOnline: Bool?) -> Double {
|
||||
switch presence.status {
|
||||
case let .present(statusTimestamp):
|
||||
if statusTimestamp >= timestamp {
|
||||
|
|
@ -28,7 +28,7 @@ private func suggestedUserPresenceStringRefreshTimeout(_ presence: TelegramUserP
|
|||
} else {
|
||||
return Double.infinity
|
||||
}
|
||||
case .none, .lastWeek, .lastMonth:
|
||||
case .longTimeAgo, .lastWeek, .lastMonth:
|
||||
return Double.infinity
|
||||
}
|
||||
}
|
||||
|
|
@ -45,7 +45,7 @@ public final class PeerPresenceStatusManager {
|
|||
self.timer?.invalidate()
|
||||
}
|
||||
|
||||
public func reset(presence: TelegramUserPresence, isOnline: Bool? = nil) {
|
||||
public func reset(presence: EnginePeer.Presence, isOnline: Bool? = nil) {
|
||||
self.timer?.invalidate()
|
||||
self.timer = nil
|
||||
|
||||
|
|
|
|||
|
|
@ -230,7 +230,7 @@ private enum PeersNearbyEntry: ItemListNodeEntry {
|
|||
if isSelfPeer {
|
||||
text = strings.PeopleNearby_VisibleUntil(humanReadableStringForTimestamp(strings: strings, dateTimeFormat: dateTimeFormat, timestamp: peer.expires).string).string
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer.peer.0, aliasHandling: .standard, nameColor: .primary, nameStyle: .distinctBold, presence: nil, text: .text(text, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: !isSelfPeer, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(peer.peer.0), aliasHandling: .standard, nameColor: .primary, nameStyle: .distinctBold, presence: nil, text: .text(text, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, selectable: !isSelfPeer, sectionId: self.section, action: {
|
||||
if !isSelfPeer {
|
||||
arguments.openProfile(peer.peer.0, peer.distance)
|
||||
}
|
||||
|
|
@ -254,7 +254,7 @@ private enum PeersNearbyEntry: ItemListNodeEntry {
|
|||
} else {
|
||||
text = .text(strings.Map_DistanceAway(shortStringForDistance(strings: strings, distance: peer.distance)).string, .secondary)
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer.peer.0, aliasHandling: .standard, nameColor: .primary, nameStyle: .distinctBold, presence: nil, text: text, label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, highlighted: highlighted, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(peer.peer.0), aliasHandling: .standard, nameColor: .primary, nameStyle: .distinctBold, presence: nil, text: text, label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, highlighted: highlighted, selectable: true, sectionId: self.section, action: {
|
||||
arguments.openChat(peer.peer.0)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in }, removePeer: { _ in }, toggleUpdated: nil, contextAction: { node, gesture in
|
||||
arguments.contextAction(peer.peer.0, node, gesture)
|
||||
|
|
@ -268,7 +268,7 @@ private enum PeersNearbyEntry: ItemListNodeEntry {
|
|||
} else {
|
||||
text = .text(strings.Map_DistanceAway(shortStringForDistance(strings: strings, distance: peer.distance)).string, .secondary)
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer.peer.0, aliasHandling: .standard, nameColor: .primary, nameStyle: .distinctBold, presence: nil, text: text, label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, highlighted: highlighted, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(peer.peer.0), aliasHandling: .standard, nameColor: .primary, nameStyle: .distinctBold, presence: nil, text: text, label: .none, editing: ItemListPeerItemEditing(editable: false, editing: false, revealed: false), revealOptions: nil, switchValue: nil, enabled: true, highlighted: highlighted, selectable: true, sectionId: self.section, action: {
|
||||
arguments.openChat(peer.peer.0)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in }, removePeer: { _ in }, toggleUpdated: nil, contextAction: { node, gesture in
|
||||
arguments.contextAction(peer.peer.0, node, gesture)
|
||||
|
|
|
|||
|
|
@ -88,7 +88,6 @@ swift_library(
|
|||
"//submodules/OpenInExternalAppUI:OpenInExternalAppUI",
|
||||
"//submodules/AccountUtils:AccountUtils",
|
||||
"//submodules/AuthTransferUI:AuthTransferUI",
|
||||
"//submodules/WidgetSetupScreen:WidgetSetupScreen",
|
||||
"//submodules/UIKitRuntimeUtils:UIKitRuntimeUtils",
|
||||
"//submodules/DebugSettingsUI:DebugSettingsUI",
|
||||
"//submodules/WallpaperBackgroundNode:WallpaperBackgroundNode",
|
||||
|
|
|
|||
|
|
@ -11,7 +11,6 @@ import ItemListUI
|
|||
import PresentationDataUtils
|
||||
import AccountContext
|
||||
import OpenInExternalAppUI
|
||||
import WidgetSetupScreen
|
||||
|
||||
private final class DataAndStorageControllerArguments {
|
||||
let openStorageUsage: () -> Void
|
||||
|
|
@ -27,10 +26,9 @@ private final class DataAndStorageControllerArguments {
|
|||
let toggleDownloadInBackground: (Bool) -> Void
|
||||
let openBrowserSelection: () -> Void
|
||||
let openIntents: () -> Void
|
||||
let openWidgetSettings: () -> Void
|
||||
let toggleEnableSensitiveContent: (Bool) -> Void
|
||||
|
||||
init(openStorageUsage: @escaping () -> Void, openNetworkUsage: @escaping () -> Void, openProxy: @escaping () -> Void, openAutomaticDownloadConnectionType: @escaping (AutomaticDownloadConnectionType) -> Void, resetAutomaticDownload: @escaping () -> Void, openVoiceUseLessData: @escaping () -> Void, openSaveIncomingPhotos: @escaping () -> Void, toggleSaveEditedPhotos: @escaping (Bool) -> Void, toggleAutoplayGifs: @escaping (Bool) -> Void, toggleAutoplayVideos: @escaping (Bool) -> Void, toggleDownloadInBackground: @escaping (Bool) -> Void, openBrowserSelection: @escaping () -> Void, openIntents: @escaping () -> Void, openWidgetSettings: @escaping () -> Void, toggleEnableSensitiveContent: @escaping (Bool) -> Void) {
|
||||
init(openStorageUsage: @escaping () -> Void, openNetworkUsage: @escaping () -> Void, openProxy: @escaping () -> Void, openAutomaticDownloadConnectionType: @escaping (AutomaticDownloadConnectionType) -> Void, resetAutomaticDownload: @escaping () -> Void, openVoiceUseLessData: @escaping () -> Void, openSaveIncomingPhotos: @escaping () -> Void, toggleSaveEditedPhotos: @escaping (Bool) -> Void, toggleAutoplayGifs: @escaping (Bool) -> Void, toggleAutoplayVideos: @escaping (Bool) -> Void, toggleDownloadInBackground: @escaping (Bool) -> Void, openBrowserSelection: @escaping () -> Void, openIntents: @escaping () -> Void, toggleEnableSensitiveContent: @escaping (Bool) -> Void) {
|
||||
self.openStorageUsage = openStorageUsage
|
||||
self.openNetworkUsage = openNetworkUsage
|
||||
self.openProxy = openProxy
|
||||
|
|
@ -44,7 +42,6 @@ private final class DataAndStorageControllerArguments {
|
|||
self.toggleDownloadInBackground = toggleDownloadInBackground
|
||||
self.openBrowserSelection = openBrowserSelection
|
||||
self.openIntents = openIntents
|
||||
self.openWidgetSettings = openWidgetSettings
|
||||
self.toggleEnableSensitiveContent = toggleEnableSensitiveContent
|
||||
}
|
||||
}
|
||||
|
|
@ -89,7 +86,6 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||
case useLessVoiceData(PresentationTheme, String, String)
|
||||
case otherHeader(PresentationTheme, String)
|
||||
case shareSheet(PresentationTheme, String)
|
||||
case widgetSettings(String)
|
||||
case saveIncomingPhotos(PresentationTheme, String)
|
||||
case saveEditedPhotos(PresentationTheme, String, Bool)
|
||||
case openLinksIn(PresentationTheme, String, String)
|
||||
|
|
@ -109,7 +105,7 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||
return DataAndStorageSection.autoPlay.rawValue
|
||||
case .voiceCallsHeader, .useLessVoiceData:
|
||||
return DataAndStorageSection.voiceCalls.rawValue
|
||||
case .otherHeader, .shareSheet, .widgetSettings, .saveIncomingPhotos, .saveEditedPhotos, .openLinksIn, .downloadInBackground, .downloadInBackgroundInfo:
|
||||
case .otherHeader, .shareSheet, .saveIncomingPhotos, .saveEditedPhotos, .openLinksIn, .downloadInBackground, .downloadInBackgroundInfo:
|
||||
return DataAndStorageSection.other.rawValue
|
||||
case .connectionHeader, .connectionProxy:
|
||||
return DataAndStorageSection.connection.rawValue
|
||||
|
|
@ -146,8 +142,6 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||
return 11
|
||||
case .shareSheet:
|
||||
return 12
|
||||
case .widgetSettings:
|
||||
return 13
|
||||
case .saveIncomingPhotos:
|
||||
return 14
|
||||
case .saveEditedPhotos:
|
||||
|
|
@ -247,12 +241,6 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||
} else {
|
||||
return false
|
||||
}
|
||||
case let .widgetSettings(text):
|
||||
if case .widgetSettings(text) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .saveIncomingPhotos(lhsTheme, lhsText):
|
||||
if case let .saveIncomingPhotos(rhsTheme, rhsText) = rhs, lhsTheme === rhsTheme, lhsText == rhsText {
|
||||
return true
|
||||
|
|
@ -357,10 +345,6 @@ private enum DataAndStorageEntry: ItemListNodeEntry {
|
|||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: "", sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openIntents()
|
||||
})
|
||||
case let .widgetSettings(text):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: "", sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openWidgetSettings()
|
||||
})
|
||||
case let .saveIncomingPhotos(_, text):
|
||||
return ItemListDisclosureItem(presentationData: presentationData, title: text, label: "", sectionId: self.section, style: .blocks, action: {
|
||||
arguments.openSaveIncomingPhotos()
|
||||
|
|
@ -504,9 +488,6 @@ private func dataAndStorageControllerEntries(state: DataAndStorageControllerStat
|
|||
if #available(iOSApplicationExtension 13.2, iOS 13.2, *) {
|
||||
entries.append(.shareSheet(presentationData.theme, presentationData.strings.ChatSettings_IntentsSettings))
|
||||
}
|
||||
/*if #available(iOSApplicationExtension 14.0, iOS 14.0, *) {
|
||||
entries.append(.widgetSettings(presentationData.strings.ChatSettings_WidgetSettings))
|
||||
}*/
|
||||
entries.append(.saveIncomingPhotos(presentationData.theme, presentationData.strings.Settings_SaveIncomingPhotos))
|
||||
entries.append(.saveEditedPhotos(presentationData.theme, presentationData.strings.Settings_SaveEditedPhotos, data.generatedMediaStoreSettings.storeEditedPhotos))
|
||||
entries.append(.openLinksIn(presentationData.theme, presentationData.strings.ChatSettings_OpenLinksIn, defaultWebBrowser))
|
||||
|
|
@ -659,9 +640,6 @@ public func dataAndStorageController(context: AccountContext, focusOnItemTag: Da
|
|||
}, openIntents: {
|
||||
let controller = intentsSettingsController(context: context)
|
||||
pushControllerImpl?(controller)
|
||||
}, openWidgetSettings: {
|
||||
let controller = widgetSetupScreen(context: context)
|
||||
pushControllerImpl?(controller)
|
||||
}, toggleEnableSensitiveContent: { value in
|
||||
let _ = (contentSettingsConfiguration.get()
|
||||
|> take(1)
|
||||
|
|
|
|||
|
|
@ -187,7 +187,7 @@ private enum IntentsSettingsControllerEntry: ItemListNodeEntry {
|
|||
case let .accountHeader(_, text):
|
||||
return ItemListSectionHeaderItem(presentationData: presentationData, text: text, sectionId: self.section)
|
||||
case let .account(_, peer, selected, _):
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context.sharedContext.makeTempAccountContext(account: arguments.context.account), peer: peer, height: .generic, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: false), revealOptions: nil, switchValue: ItemListPeerItemSwitch(value: selected, style: .check), enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: PresentationDateTimeFormat(), nameDisplayOrder: .firstLast, context: arguments.context.sharedContext.makeTempAccountContext(account: arguments.context.account), peer: EnginePeer(peer), height: .generic, aliasHandling: .standard, nameStyle: .plain, presence: nil, text: .none, label: .none, editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: false), revealOptions: nil, switchValue: ItemListPeerItemSwitch(value: selected, style: .check), enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
arguments.updateSettings { $0.withUpdatedAccount(peer.id) }
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in}, removePeer: { _ in })
|
||||
case let .accountInfo(_, text):
|
||||
|
|
|
|||
|
|
@ -264,7 +264,7 @@ private enum StorageUsageEntry: ItemListNodeEntry {
|
|||
let options: [ItemListPeerItemRevealOption] = [ItemListPeerItemRevealOption(type: .destructive, title: strings.ClearCache_Clear, action: {
|
||||
arguments.clearPeerMedia(peer.id)
|
||||
})]
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer, aliasHandling: .threatSelfAsSaved, nameColor: chatPeer == nil ? .primary : .secret, presence: nil, text: .none, label: .disclosure(value), editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: revealed), revealOptions: ItemListPeerItemRevealOptions(options: options), switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(peer), aliasHandling: .threatSelfAsSaved, nameColor: chatPeer == nil ? .primary : .secret, presence: nil, text: .none, label: .disclosure(value), editing: ItemListPeerItemEditing(editable: true, editing: false, revealed: revealed), revealOptions: ItemListPeerItemRevealOptions(options: options), switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
let resolvedPeer = chatPeer ?? peer
|
||||
arguments.openPeerMedia(resolvedPeer.id)
|
||||
}, setPeerIdWithRevealedOptions: { peerId, fromPeerId in
|
||||
|
|
|
|||
|
|
@ -299,13 +299,13 @@ private func notificationsExceptionEntries(presentationData: PresentationData, s
|
|||
var index: Int = 0
|
||||
for (_, value) in state.mode.settings.filter({ (_, value) in
|
||||
if let query = query, !query.isEmpty {
|
||||
return !value.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder).lowercased().components(separatedBy: " ").filter { $0.hasPrefix(query.lowercased())}.isEmpty
|
||||
return !EnginePeer(value.peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder).lowercased().components(separatedBy: " ").filter { $0.hasPrefix(query.lowercased())}.isEmpty
|
||||
} else {
|
||||
return true
|
||||
}
|
||||
}).sorted(by: { lhs, rhs in
|
||||
let lhsName = lhs.value.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let rhsName = rhs.value.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let lhsName = EnginePeer(lhs.value.peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let rhsName = EnginePeer(rhs.value.peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
|
||||
if let lhsDate = lhs.value.date, let rhsDate = rhs.value.date {
|
||||
return lhsDate > rhsDate
|
||||
|
|
@ -530,7 +530,7 @@ private enum NotificationExceptionEntry : ItemListNodeEntry {
|
|||
arguments.selectPeer()
|
||||
})
|
||||
case let .peer(_, peer, _, _, dateTimeFormat, nameDisplayOrder, value, _, revealed, editing, isSearching):
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer, presence: nil, text: .text(value, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: true, editing: editing, revealed: revealed), switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(peer), presence: nil, text: .text(value, .secondary), label: .none, editing: ItemListPeerItemEditing(editable: true, editing: editing, revealed: revealed), switchValue: nil, enabled: true, selectable: true, sectionId: self.section, action: {
|
||||
arguments.openPeer(peer)
|
||||
}, setPeerIdWithRevealedOptions: { peerId, fromPeerId in
|
||||
arguments.updateRevealedPeerId(peerId)
|
||||
|
|
@ -538,7 +538,7 @@ private enum NotificationExceptionEntry : ItemListNodeEntry {
|
|||
arguments.deletePeer(peer)
|
||||
}, hasTopStripe: false, hasTopGroupInset: false, noInsets: isSearching)
|
||||
case let .addPeer(_, peer, theme, strings, _, nameDisplayOrder):
|
||||
return ContactsPeerItem(presentationData: presentationData, sortOrder: nameDisplayOrder, displayOrder: nameDisplayOrder, context: arguments.context, peerMode: .peer, peer: .peer(peer: peer, chatPeer: peer), status: .none, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), options: [], actionIcon: .add, index: nil, header: ChatListSearchItemHeader(type: .addToExceptions, theme: theme, strings: strings, actionTitle: nil, action: nil), action: { _ in
|
||||
return ContactsPeerItem(presentationData: presentationData, sortOrder: nameDisplayOrder, displayOrder: nameDisplayOrder, context: arguments.context, peerMode: .peer, peer: .peer(peer: EnginePeer(peer), chatPeer: EnginePeer(peer)), status: .none, enabled: true, selection: .none, editing: ContactsPeerItemEditing(editable: false, editing: false, revealed: false), options: [], actionIcon: .add, index: nil, header: ChatListSearchItemHeader(type: .addToExceptions, theme: theme, strings: strings, actionTitle: nil, action: nil), action: { _ in
|
||||
arguments.openPeer(peer)
|
||||
}, setPeerIdWithRevealedOptions: { _, _ in
|
||||
})
|
||||
|
|
|
|||
|
|
@ -375,7 +375,7 @@ public func notificationPeerExceptionController(context: AccountContext, updated
|
|||
arguments.complete()
|
||||
})
|
||||
|
||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back))
|
||||
let controllerState = ItemListControllerState(presentationData: ItemListPresentationData(presentationData), title: .text(EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)), leftNavigationButton: leftNavigationButton, rightNavigationButton: rightNavigationButton, backNavigationButton: ItemListBackButton(title: presentationData.strings.Common_Back))
|
||||
let listState = ItemListNodeState(presentationData: ItemListPresentationData(presentationData), entries: notificationPeerExceptionEntries(presentationData: presentationData, state: state), style: .blocks, animateChanges: false)
|
||||
|
||||
return (controllerState, (listState, arguments))
|
||||
|
|
|
|||
|
|
@ -132,7 +132,7 @@ private enum BlockedPeersEntry: ItemListNodeEntry {
|
|||
arguments.removePeer(peer.id)
|
||||
})])
|
||||
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer, presence: nil, text: .none, label: .none, editing: editing, revealOptions: revealOptions, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(peer), presence: nil, text: .none, label: .none, editing: editing, revealOptions: revealOptions, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: {
|
||||
arguments.openPeer(peer)
|
||||
}, setPeerIdWithRevealedOptions: { previousId, id in
|
||||
arguments.setPeerIdWithRevealedOptions(previousId, id)
|
||||
|
|
|
|||
|
|
@ -195,7 +195,7 @@ class ItemListWebsiteItemNode: ItemListRevealOptionsItemNode {
|
|||
let rightInset: CGFloat = params.rightInset
|
||||
|
||||
if let user = item.peer as? TelegramUser {
|
||||
titleAttributedString = NSAttributedString(string: user.displayTitle(strings: item.strings, displayOrder: item.nameDisplayOrder), font: titleFont, textColor: item.theme.list.itemPrimaryTextColor)
|
||||
titleAttributedString = NSAttributedString(string: EnginePeer(user).displayTitle(strings: item.strings, displayOrder: item.nameDisplayOrder), font: titleFont, textColor: item.theme.list.itemPrimaryTextColor)
|
||||
}
|
||||
|
||||
var appString = ""
|
||||
|
|
|
|||
|
|
@ -938,8 +938,7 @@ func selectivePrivacySettingsController(context: AccountContext, kind: Selective
|
|||
|
||||
let signal = combineLatest(context.sharedContext.presentationData, statePromise.get(), peer) |> deliverOnMainQueue
|
||||
|> map { presentationData, state, peer -> (ItemListControllerState, (ItemListNodeState, Any)) in
|
||||
|
||||
let peerName = peer?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
let peerName = peer.flatMap(EnginePeer.init)?.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder)
|
||||
|
||||
let title: String
|
||||
switch kind {
|
||||
|
|
|
|||
|
|
@ -140,7 +140,7 @@ private enum SelectivePrivacyPeersEntry: ItemListNodeEntry {
|
|||
}
|
||||
}
|
||||
}
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: peer.peer, presence: nil, text: text, label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: {
|
||||
return ItemListPeerItem(presentationData: presentationData, dateTimeFormat: dateTimeFormat, nameDisplayOrder: nameDisplayOrder, context: arguments.context, peer: EnginePeer(peer.peer), presence: nil, text: text, label: .none, editing: editing, switchValue: nil, enabled: enabled, selectable: true, sectionId: self.section, action: {
|
||||
arguments.openPeer(peer.peer.id)
|
||||
}, setPeerIdWithRevealedOptions: { previousId, id in
|
||||
arguments.setPeerIdWithRevealedOptions(previousId, id)
|
||||
|
|
|
|||
|
|
@ -131,7 +131,7 @@ private final class SwitchAccountItemNode: ASDisplayNode, AbstractSwitchAccountI
|
|||
|
||||
self.titleNode = ImmediateTextNode()
|
||||
self.titleNode.maximumNumberOfLines = 1
|
||||
self.titleNode.attributedText = NSAttributedString(string: peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), font: Font.regular(17.0), textColor: presentationData.theme.actionSheet.primaryTextColor)
|
||||
self.titleNode.attributedText = NSAttributedString(string: EnginePeer(peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), font: Font.regular(17.0), textColor: presentationData.theme.actionSheet.primaryTextColor)
|
||||
|
||||
self.checkNode = ASImageNode()
|
||||
self.checkNode.image = generateItemListCheckIcon(color: presentationData.theme.actionSheet.primaryTextColor)
|
||||
|
|
|
|||
|
|
@ -2,11 +2,12 @@ import Foundation
|
|||
import UIKit
|
||||
import Display
|
||||
import Postbox
|
||||
import TelegramCore
|
||||
|
||||
public protocol ShareContentContainerNode: AnyObject {
|
||||
func activate()
|
||||
func deactivate()
|
||||
func setEnsurePeerVisibleOnLayout(_ peerId: PeerId?)
|
||||
func setEnsurePeerVisibleOnLayout(_ peerId: EnginePeer.Id?)
|
||||
func setContentOffsetUpdated(_ f: ((CGFloat, ContainedViewLayoutTransition) -> Void)?)
|
||||
func updateLayout(size: CGSize, bottomInset: CGFloat, transition: ContainedViewLayoutTransition)
|
||||
func updateSelectedPeers()
|
||||
|
|
|
|||
|
|
@ -119,7 +119,7 @@ private func collectExternalShareItems(strings: PresentationStrings, dateTimeFor
|
|||
authorsPromise.set(postbox.transaction { transaction in
|
||||
var result: [PeerId: String] = [:]
|
||||
for peerId in authorsPeerIds {
|
||||
if let title = transaction.getPeer(peerId)?.displayTitle(strings: strings, displayOrder: nameOrder) {
|
||||
if let title = transaction.getPeer(peerId).flatMap(EnginePeer.init)?.displayTitle(strings: strings, displayOrder: nameOrder) {
|
||||
result[peerId] = title
|
||||
}
|
||||
}
|
||||
|
|
@ -629,7 +629,7 @@ public final class ShareController: ViewController {
|
|||
}
|
||||
if !displayedError, case .slowmodeActive = error {
|
||||
displayedError = true
|
||||
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: peer.displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder), text: strongSelf.presentationData.strings.Chat_SlowmodeSendError, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
strongSelf.present(standardTextAlertController(theme: AlertControllerTheme(presentationData: strongSelf.presentationData), title: EnginePeer(peer).displayTitle(strings: strongSelf.presentationData.strings, displayOrder: strongSelf.presentationData.nameDisplayOrder), text: strongSelf.presentationData.strings.Chat_SlowmodeSendError, actions: [TextAlertAction(type: .defaultAction, title: strongSelf.presentationData.strings.Common_OK, action: {})]), in: .window(.root))
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
@ -789,7 +789,7 @@ public final class ShareController: ViewController {
|
|||
}
|
||||
var items: [ActionSheetItem] = []
|
||||
for info in strongSelf.switchableAccounts {
|
||||
items.append(ActionSheetPeerItem(context: strongSelf.sharedContext.makeTempAccountContext(account: info.account), peer: EnginePeer(info.peer), title: info.peer.displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), isSelected: info.account.id == strongSelf.currentAccount.id, strings: presentationData.strings, theme: presentationData.theme, action: { [weak self] in
|
||||
items.append(ActionSheetPeerItem(context: strongSelf.sharedContext.makeTempAccountContext(account: info.account), peer: EnginePeer(info.peer), title: EnginePeer(info.peer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), isSelected: info.account.id == strongSelf.currentAccount.id, strings: presentationData.strings, theme: presentationData.theme, action: { [weak self] in
|
||||
dismissAction()
|
||||
self?.switchToAccount(account: info.account, animateIn: true)
|
||||
}))
|
||||
|
|
|
|||
|
|
@ -221,7 +221,7 @@ final class ShareControllerPeerGridItemNode: GridItemNode {
|
|||
self.currentState = (context, theme, strings, peer, search, presence)
|
||||
self.setNeedsLayout()
|
||||
if let presence = presence as? TelegramUserPresence {
|
||||
self.presenceManager?.reset(presence: presence)
|
||||
self.presenceManager?.reset(presence: EnginePeer.Presence(presence))
|
||||
}
|
||||
}
|
||||
self.updateSelection(animated: false)
|
||||
|
|
|
|||
|
|
@ -422,7 +422,7 @@ final class SharePeersContainerNode: ASDisplayNode, ShareContentContainerNode {
|
|||
if peer.peerId == self.accountPeer.id {
|
||||
text = self.strings.DialogList_SavedMessages
|
||||
} else {
|
||||
text = peer.chatMainPeer?.displayTitle(strings: self.strings, displayOrder: self.nameDisplayOrder) ?? ""
|
||||
text = peer.chatMainPeer.flatMap(EnginePeer.init)?.displayTitle(strings: self.strings, displayOrder: self.nameDisplayOrder) ?? ""
|
||||
}
|
||||
|
||||
if !string.isEmpty {
|
||||
|
|
|
|||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue