mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-06-16 05:55:20 +00:00
Merge commit '4309eb36af727b245c49c1af39adc9952218d2d5'
This commit is contained in:
commit
313dca7e41
BIN
Telegram/Telegram-iOS/Resources/Devices.tgs
Normal file
BIN
Telegram/Telegram-iOS/Resources/Devices.tgs
Normal file
Binary file not shown.
@ -7090,3 +7090,5 @@ Sorry for the inconvenience.";
|
||||
"AuthSessions.HeaderInfo" = "Link [Telegram Desktop](desktop) or [Telegram Web](web) by scanning a QR code.";
|
||||
"AuthSessions.LinkDesktopDevice" = "Link Desktop Device";
|
||||
"AuthSessions.AddDevice.ScanInstallInfo" = "Go to [getdesktop.telegram.org](desktop) or [web.telegram.org](web) to get the QR code";
|
||||
|
||||
"Channel.AdminLog.MessageSent" = "%@ sent message:";
|
||||
|
@ -240,7 +240,8 @@ public func legacyAttachmentMenu(context: AccountContext, peer: Peer, chatLocati
|
||||
allItems.append(currentItem)
|
||||
}
|
||||
for item in allItems {
|
||||
if let asset = item as? TGMediaAsset, asset.uniformTypeIdentifier.contains("heic") {
|
||||
if item is TGCameraCapturedVideo {
|
||||
} else if let asset = item as? TGMediaAsset, asset.uniformTypeIdentifier.contains("heic") {
|
||||
hasHeic = true
|
||||
break
|
||||
}
|
||||
|
@ -316,7 +316,7 @@ private enum RecentSessionsEntry: ItemListNodeEntry {
|
||||
let arguments = arguments as! RecentSessionsControllerArguments
|
||||
switch self {
|
||||
case let .header(_, text):
|
||||
return RecentSessionsHeaderItem(context: arguments.context, theme: presentationData.theme, text: text, animationName: "Requests", sectionId: self.section, buttonAction: {
|
||||
return RecentSessionsHeaderItem(context: arguments.context, theme: presentationData.theme, text: text, animationName: "Devices", sectionId: self.section, buttonAction: {
|
||||
arguments.addDevice()
|
||||
}, linkAction: { action in
|
||||
if case let .tap(link) = action {
|
||||
|
@ -139,7 +139,7 @@ class RecentSessionsHeaderItemNode: ListViewItemNode {
|
||||
return (layout, { [weak self] in
|
||||
if let strongSelf = self {
|
||||
if strongSelf.item == nil {
|
||||
strongSelf.animationNode.setup(source: AnimatedStickerNodeLocalFileSource(name: item.animationName), width: 192, height: 192, playbackMode: .loop, mode: .direct(cachePathPrefix: nil))
|
||||
strongSelf.animationNode.setup(source: AnimatedStickerNodeLocalFileSource(name: item.animationName), width: 192, height: 192, playbackMode: .once, mode: .direct(cachePathPrefix: nil))
|
||||
strongSelf.animationNode.visibility = true
|
||||
}
|
||||
strongSelf.item = item
|
||||
|
@ -63,7 +63,7 @@ extension StickerPackReference {
|
||||
case .inputStickerSetAnimatedEmojiAnimations:
|
||||
self = .animatedEmojiAnimations
|
||||
case .inputStickerSetAnimatedEmojiReactions:
|
||||
self = .animatedEmojiAnimations
|
||||
self = .animatedEmojiReactions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -682,23 +682,11 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
|
||||
} else {
|
||||
attributes.append(contentsOf: filterMessageAttributesForOutgoingMessage(sourceMessage.attributes))
|
||||
}
|
||||
|
||||
let authorId: PeerId?
|
||||
if let peer = peer as? TelegramChannel {
|
||||
if case .broadcast = peer.info {
|
||||
authorId = peer.id
|
||||
} else if case .group = peer.info, peer.hasPermission(.canBeAnonymous) {
|
||||
authorId = peer.id
|
||||
} else {
|
||||
authorId = account.peerId
|
||||
}
|
||||
} else {
|
||||
authorId = account.peerId
|
||||
}
|
||||
|
||||
|
||||
var messageNamespace = Namespaces.Message.Local
|
||||
var entitiesAttribute: TextEntitiesMessageAttribute?
|
||||
var effectiveTimestamp = timestamp
|
||||
var sendAsPeer: Peer?
|
||||
var threadId: Int64?
|
||||
for attribute in attributes {
|
||||
if let attribute = attribute as? TextEntitiesMessageAttribute {
|
||||
@ -713,9 +701,28 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId,
|
||||
if let threadMessageId = attribute.threadMessageId {
|
||||
threadId = makeMessageThreadId(threadMessageId)
|
||||
}
|
||||
} else if let attribute = attribute as? SendAsMessageAttribute {
|
||||
if let peer = transaction.getPeer(attribute.peerId) {
|
||||
sendAsPeer = peer
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let authorId: PeerId?
|
||||
if let sendAsPeer = sendAsPeer {
|
||||
authorId = sendAsPeer.id
|
||||
} else if let peer = peer as? TelegramChannel {
|
||||
if case .broadcast = peer.info {
|
||||
authorId = peer.id
|
||||
} else if case .group = peer.info, peer.hasPermission(.canBeAnonymous) {
|
||||
authorId = peer.id
|
||||
} else {
|
||||
authorId = account.peerId
|
||||
}
|
||||
} else {
|
||||
authorId = account.peerId
|
||||
}
|
||||
|
||||
if messageNamespace != Namespaces.Message.ScheduledLocal {
|
||||
attributes.removeAll(where: { $0 is OutgoingScheduleInfoMessageAttribute })
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ import SwiftSignalKit
|
||||
extension PeerStatusSettings {
|
||||
init(apiSettings: Api.PeerSettings) {
|
||||
switch apiSettings {
|
||||
case let .peerSettings(flags, geoDistance, _, requestChatDate):
|
||||
case let .peerSettings(flags, geoDistance, requestChatTitle, requestChatDate):
|
||||
var result = PeerStatusSettings.Flags()
|
||||
if (flags & (1 << 1)) != 0 {
|
||||
result.insert(.canAddContact)
|
||||
@ -32,7 +32,7 @@ extension PeerStatusSettings {
|
||||
if (flags & (1 << 8)) != 0 {
|
||||
result.insert(.suggestAddMembers)
|
||||
}
|
||||
self = PeerStatusSettings(flags: result, geoDistance: geoDistance, requestChatPeerId: nil, requestChatDate: requestChatDate)
|
||||
self = PeerStatusSettings(flags: result, geoDistance: geoDistance, requestChatTitle: requestChatTitle, requestChatDate: requestChatDate, requestChatIsChannel: (flags & (1 << 9)) != 0)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -61,7 +61,7 @@ public func addSavedSticker(postbox: Postbox, network: Network, file: TelegramMe
|
||||
if !found {
|
||||
fetchReference = packReference
|
||||
}
|
||||
case .animatedEmoji, .animatedEmojiAnimations, .dice:
|
||||
case .animatedEmoji, .animatedEmojiAnimations, .dice, .animatedEmojiReactions:
|
||||
break
|
||||
}
|
||||
if let fetchReference = fetchReference {
|
||||
|
@ -101,11 +101,7 @@ public final class CachedUserData: CachedPeerData {
|
||||
self.autoremoveTimeout = autoremoveTimeout
|
||||
self.themeEmoticon = themeEmoticon
|
||||
|
||||
var peerIds = Set<PeerId>()
|
||||
if let requestChatPeerId = peerStatusSettings?.requestChatPeerId {
|
||||
peerIds.insert(requestChatPeerId)
|
||||
}
|
||||
self.peerIds = peerIds
|
||||
self.peerIds = Set<PeerId>()
|
||||
|
||||
var messageIds = Set<MessageId>()
|
||||
if let pinnedMessageId = self.pinnedMessageId {
|
||||
@ -139,11 +135,7 @@ public final class CachedUserData: CachedPeerData {
|
||||
self.autoremoveTimeout = decoder.decodeObjectForKey("artv", decoder: CachedPeerAutoremoveTimeout.init(decoder:)) as? CachedPeerAutoremoveTimeout ?? .unknown
|
||||
self.themeEmoticon = decoder.decodeOptionalStringForKey("te")
|
||||
|
||||
var peerIds = Set<PeerId>()
|
||||
if let requestChatPeerId = self.peerStatusSettings?.requestChatPeerId {
|
||||
peerIds.insert(requestChatPeerId)
|
||||
}
|
||||
self.peerIds = peerIds
|
||||
self.peerIds = Set<PeerId>()
|
||||
|
||||
var messageIds = Set<MessageId>()
|
||||
if let pinnedMessageId = self.pinnedMessageId {
|
||||
|
@ -45,6 +45,7 @@ public struct Namespaces {
|
||||
public static let CloudAnimatedEmoji: Int32 = 3
|
||||
public static let CloudDice: Int32 = 4
|
||||
public static let CloudAnimatedEmojiAnimations: Int32 = 5
|
||||
public static let CloudAnimatedEmojiReactions: Int32 = 6
|
||||
}
|
||||
|
||||
public struct OrderedItemList {
|
||||
|
@ -21,28 +21,31 @@ public struct PeerStatusSettings: PostboxCoding, Equatable {
|
||||
|
||||
public var flags: PeerStatusSettings.Flags
|
||||
public var geoDistance: Int32?
|
||||
public var requestChatPeerId: PeerId?
|
||||
public var requestChatTitle: String?
|
||||
public var requestChatDate: Int32?
|
||||
public var requestChatIsChannel: Bool?
|
||||
|
||||
public init() {
|
||||
self.flags = PeerStatusSettings.Flags()
|
||||
self.geoDistance = nil
|
||||
self.requestChatPeerId = nil
|
||||
self.requestChatTitle = nil
|
||||
self.requestChatDate = nil
|
||||
}
|
||||
|
||||
public init(flags: PeerStatusSettings.Flags, geoDistance: Int32? = nil, requestChatPeerId: PeerId? = nil, requestChatDate: Int32? = nil) {
|
||||
public init(flags: PeerStatusSettings.Flags, geoDistance: Int32? = nil, requestChatTitle: String? = nil, requestChatDate: Int32? = nil, requestChatIsChannel: Bool? = nil) {
|
||||
self.flags = flags
|
||||
self.geoDistance = geoDistance
|
||||
self.requestChatPeerId = requestChatPeerId
|
||||
self.requestChatTitle = requestChatTitle
|
||||
self.requestChatDate = requestChatDate
|
||||
self.requestChatIsChannel = requestChatIsChannel
|
||||
}
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
self.flags = Flags(rawValue: decoder.decodeInt32ForKey("flags", orElse: 0))
|
||||
self.geoDistance = decoder.decodeOptionalInt32ForKey("geoDistance")
|
||||
self.requestChatPeerId = decoder.decodeOptionalInt64ForKey("requestChatPeerId").map { PeerId($0) }
|
||||
self.requestChatTitle = decoder.decodeOptionalStringForKey("requestChatTitle")
|
||||
self.requestChatDate = decoder.decodeOptionalInt32ForKey("requestChatDate")
|
||||
self.requestChatIsChannel = decoder.decodeOptionalBoolForKey("requestChatIsChannel")
|
||||
}
|
||||
|
||||
public func encode(_ encoder: PostboxEncoder) {
|
||||
@ -52,16 +55,21 @@ public struct PeerStatusSettings: PostboxCoding, Equatable {
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "geoDistance")
|
||||
}
|
||||
if let requestChatPeerId = self.requestChatPeerId {
|
||||
encoder.encodeInt64(requestChatPeerId.toInt64(), forKey: "requestChatPeerId")
|
||||
if let requestChatTitle = self.requestChatTitle {
|
||||
encoder.encodeString(requestChatTitle, forKey: "requestChatTitle")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "requestPeerId")
|
||||
encoder.encodeNil(forKey: "requestChatTitle")
|
||||
}
|
||||
if let requestChatDate = self.requestChatDate {
|
||||
encoder.encodeInt32(requestChatDate, forKey: "requestChatDate")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "requestChatDate")
|
||||
}
|
||||
if let requestChatIsChannel = self.requestChatIsChannel {
|
||||
encoder.encodeBool(requestChatIsChannel, forKey: "requestChatIsChannel")
|
||||
} else {
|
||||
encoder.encodeNil(forKey: "requestChatIsChannel")
|
||||
}
|
||||
}
|
||||
|
||||
public func contains(_ member: PeerStatusSettings.Flags) -> Bool {
|
||||
|
@ -1,4 +1,4 @@
|
||||
import Foundation
|
||||
import Foundation
|
||||
import Postbox
|
||||
|
||||
private let typeFileName: Int32 = 0
|
||||
@ -17,6 +17,7 @@ public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
|
||||
case animatedEmoji
|
||||
case dice(String)
|
||||
case animatedEmojiAnimations
|
||||
case animatedEmojiReactions
|
||||
|
||||
public init(decoder: PostboxDecoder) {
|
||||
switch decoder.decodeInt32ForKey("r", orElse: 0) {
|
||||
@ -30,6 +31,8 @@ public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
|
||||
self = .dice(decoder.decodeStringForKey("e", orElse: "🎲"))
|
||||
case 4:
|
||||
self = .animatedEmojiAnimations
|
||||
case 5:
|
||||
self = .animatedEmojiReactions
|
||||
default:
|
||||
self = .name("")
|
||||
assertionFailure()
|
||||
@ -52,6 +55,49 @@ public enum StickerPackReference: PostboxCoding, Hashable, Equatable {
|
||||
encoder.encodeString(emoji, forKey: "e")
|
||||
case .animatedEmojiAnimations:
|
||||
encoder.encodeInt32(4, forKey: "r")
|
||||
case .animatedEmojiReactions:
|
||||
encoder.encodeInt32(5, forKey: "r")
|
||||
}
|
||||
}
|
||||
|
||||
public static func ==(lhs: StickerPackReference, rhs: StickerPackReference) -> Bool {
|
||||
switch lhs {
|
||||
case let .id(id, accessHash):
|
||||
if case .id(id, accessHash) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .name(name):
|
||||
if case .name(name) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .animatedEmoji:
|
||||
if case .animatedEmoji = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case let .dice(emoji):
|
||||
if case .dice(emoji) = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .animatedEmojiAnimations:
|
||||
if case .animatedEmojiAnimations = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
case .animatedEmojiReactions:
|
||||
if case .animatedEmojiReactions = rhs {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -66,6 +66,7 @@ public enum AdminLogEventAction {
|
||||
case changeTheme(previous: String?, updated: String?)
|
||||
case participantJoinByRequest(invitation: ExportedInvitation, approvedBy: PeerId)
|
||||
case toggleCopyProtection(Bool)
|
||||
case sendMessage(Message)
|
||||
}
|
||||
|
||||
public enum ChannelAdminLogEventError {
|
||||
@ -256,8 +257,10 @@ func channelAdminLogEvents(postbox: Postbox, network: Network, peerId: PeerId, m
|
||||
action = .participantJoinByRequest(invitation: ExportedInvitation(apiExportedInvite: invite), approvedBy: PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(approvedBy)))
|
||||
case let .channelAdminLogEventActionToggleNoForwards(new):
|
||||
action = .toggleCopyProtection(boolFromApiValue(new))
|
||||
case .channelAdminLogEventActionSendMessage:
|
||||
action = nil
|
||||
case let .channelAdminLogEventActionSendMessage(message):
|
||||
if let message = StoreMessage(apiMessage: message), let rendered = locallyRenderedMessage(message: message, peers: peers) {
|
||||
action = .sendMessage(rendered)
|
||||
}
|
||||
}
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(userId))
|
||||
if let action = action {
|
||||
|
@ -127,6 +127,20 @@ func _internal_cachedStickerPack(postbox: Postbox, network: Network, reference:
|
||||
} else {
|
||||
return (.fetching, true, nil)
|
||||
}
|
||||
case .animatedEmojiReactions:
|
||||
let namespace = Namespaces.ItemCollection.CloudAnimatedEmojiReactions
|
||||
let id: ItemCollectionId.Id = 0
|
||||
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id))))?.get(CachedStickerPack.self), let info = cached.info {
|
||||
previousHash = cached.hash
|
||||
let current: CachedStickerPackResult = .result(info, cached.items, false)
|
||||
if cached.hash != info.hash {
|
||||
return (current, true, previousHash)
|
||||
} else {
|
||||
return (current, false, previousHash)
|
||||
}
|
||||
} else {
|
||||
return (.fetching, true, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
|> mapToSignal { result, loadRemote, previousHash in
|
||||
@ -223,6 +237,18 @@ func cachedStickerPack(transaction: Transaction, reference: StickerPackReference
|
||||
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id))))?.get(CachedStickerPack.self), let info = cached.info {
|
||||
return (info, cached.items, false)
|
||||
}
|
||||
case .animatedEmojiReactions:
|
||||
let namespace = Namespaces.ItemCollection.CloudAnimatedEmojiReactions
|
||||
let id: ItemCollectionId.Id = 0
|
||||
if let currentInfo = transaction.getItemCollectionInfo(collectionId: ItemCollectionId(namespace: namespace, id: id)) as? StickerPackCollectionInfo {
|
||||
let items = transaction.getItemCollectionItems(collectionId: ItemCollectionId(namespace: namespace, id: id))
|
||||
if !items.isEmpty {
|
||||
return (currentInfo, items.compactMap { $0 as? StickerPackItem }, true)
|
||||
}
|
||||
}
|
||||
if let cached = transaction.retrieveItemCacheEntry(id: ItemCacheEntryId(collectionId: Namespaces.CachedItemCollection.cachedStickerPacks, key: CachedStickerPack.cacheKey(ItemCollectionId(namespace: namespace, id: id))))?.get(CachedStickerPack.self), let info = cached.info {
|
||||
return (info, cached.items, false)
|
||||
}
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
@ -20,6 +20,8 @@ extension StickerPackReference {
|
||||
return .inputStickerSetDice(emoticon: emoji)
|
||||
case .animatedEmojiAnimations:
|
||||
return .inputStickerSetAnimatedEmojiAnimations
|
||||
case .animatedEmojiReactions:
|
||||
return .inputStickerSetAnimatedEmojiReactions
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -43,6 +43,9 @@ func _internal_requestStickerSet(postbox: Postbox, network: Network, reference:
|
||||
case .animatedEmojiAnimations:
|
||||
collectionId = nil
|
||||
input = .inputStickerSetAnimatedEmojiAnimations
|
||||
case .animatedEmojiReactions:
|
||||
collectionId = nil
|
||||
input = .inputStickerSetAnimatedEmojiReactions
|
||||
}
|
||||
|
||||
let localSignal: (ItemCollectionId) -> Signal<(ItemCollectionInfo, [ItemCollectionItem])?, NoError> = { collectionId in
|
||||
|
@ -224,8 +224,6 @@ public extension Message {
|
||||
return true
|
||||
} else if let channel = self.peers[self.id.peerId] as? TelegramChannel, case .broadcast = channel.info {
|
||||
return true
|
||||
} else if self.id.peerId.namespace == Namespaces.Peer.CloudChannel, self.author?.id != accountPeerId {
|
||||
return true
|
||||
} else {
|
||||
return false
|
||||
}
|
||||
|
@ -3475,13 +3475,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
var contactStatus: ChatContactStatus?
|
||||
if let peer = peerView.peers[peerView.peerId] {
|
||||
if let cachedData = peerView.cachedData as? CachedUserData {
|
||||
var requestChatPeer: Peer?
|
||||
if let requestChatPeerId = cachedData.peerStatusSettings?.requestChatPeerId {
|
||||
if let peer = peerView.peers[requestChatPeerId] {
|
||||
requestChatPeer = peer
|
||||
}
|
||||
}
|
||||
contactStatus = ChatContactStatus(canAddContact: !peerView.peerIsContact, canReportIrrelevantLocation: false, peerStatusSettings: cachedData.peerStatusSettings, invitedBy: nil, requestChatPeer: requestChatPeer)
|
||||
contactStatus = ChatContactStatus(canAddContact: !peerView.peerIsContact, canReportIrrelevantLocation: false, peerStatusSettings: cachedData.peerStatusSettings, invitedBy: nil)
|
||||
} else if let cachedData = peerView.cachedData as? CachedGroupData {
|
||||
var invitedBy: Peer?
|
||||
if let invitedByPeerId = cachedData.invitedBy {
|
||||
@ -3489,7 +3483,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
invitedBy = peer
|
||||
}
|
||||
}
|
||||
contactStatus = ChatContactStatus(canAddContact: false, canReportIrrelevantLocation: false, peerStatusSettings: cachedData.peerStatusSettings, invitedBy: invitedBy, requestChatPeer: nil)
|
||||
contactStatus = ChatContactStatus(canAddContact: false, canReportIrrelevantLocation: false, peerStatusSettings: cachedData.peerStatusSettings, invitedBy: invitedBy)
|
||||
} else if let cachedData = peerView.cachedData as? CachedChannelData {
|
||||
var canReportIrrelevantLocation = true
|
||||
if let peer = peerView.peers[peerView.peerId] as? TelegramChannel, peer.participationStatus == .member {
|
||||
@ -3504,7 +3498,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
invitedBy = peer
|
||||
}
|
||||
}
|
||||
contactStatus = ChatContactStatus(canAddContact: false, canReportIrrelevantLocation: canReportIrrelevantLocation, peerStatusSettings: cachedData.peerStatusSettings, invitedBy: invitedBy, requestChatPeer: nil)
|
||||
contactStatus = ChatContactStatus(canAddContact: false, canReportIrrelevantLocation: canReportIrrelevantLocation, peerStatusSettings: cachedData.peerStatusSettings, invitedBy: invitedBy)
|
||||
}
|
||||
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
@ -14036,13 +14030,13 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G
|
||||
}
|
||||
|
||||
private func presentChatRequestAdminInfo() {
|
||||
if let requestChatPeer = self.presentationInterfaceState.contactStatus?.requestChatPeer, let requestDate = self.presentationInterfaceState.contactStatus?.peerStatusSettings?.requestChatDate {
|
||||
if let requestChatTitle = self.presentationInterfaceState.contactStatus?.peerStatusSettings?.requestChatTitle, let requestDate = self.presentationInterfaceState.contactStatus?.peerStatusSettings?.requestChatDate {
|
||||
let presentationData = self.context.sharedContext.currentPresentationData.with { $0 }
|
||||
|
||||
let controller = ActionSheetController(presentationData: presentationData)
|
||||
var items: [ActionSheetItem] = []
|
||||
|
||||
let text = presentationData.strings.Conversation_InviteRequestInfo(EnginePeer(requestChatPeer).displayTitle(strings: presentationData.strings, displayOrder: presentationData.nameDisplayOrder), stringForDate(timestamp: requestDate, strings: presentationData.strings))
|
||||
let text = presentationData.strings.Conversation_InviteRequestInfo(requestChatTitle, stringForDate(timestamp: requestDate, strings: presentationData.strings))
|
||||
|
||||
items.append(ActionSheetTextItem(title: text.string))
|
||||
items.append(ActionSheetButtonItem(title: self.presentationData.strings.Conversation_InviteRequestInfoConfirm, color: .accent, action: { [weak self, weak controller] in
|
||||
|
@ -57,6 +57,8 @@ private func canEditMessage(accountPeerId: PeerId, limitsConfiguration: LimitsCo
|
||||
}
|
||||
} else if message.id.peerId.namespace == Namespaces.Peer.SecretChat || message.id.namespace != Namespaces.Message.Cloud {
|
||||
hasEditRights = false
|
||||
} else if let author = message.author, author.id.namespace == Namespaces.Peer.CloudChannel && message.id.peerId.namespace == Namespaces.Peer.CloudChannel, !message.flags.contains(.Incoming) {
|
||||
hasEditRights = true
|
||||
} else if let author = message.author, author.id == accountPeerId, let peer = message.peers[message.id.peerId] {
|
||||
hasEditRights = true
|
||||
if let peer = peer as? TelegramChannel {
|
||||
|
@ -993,7 +993,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
|
||||
var allowAuthor = incoming
|
||||
|
||||
if let author = firstMessage.author, author is TelegramChannel, author.id == firstMessage.id.peerId, !incoming {
|
||||
if let author = firstMessage.author, author is TelegramChannel, !incoming {
|
||||
allowAuthor = true
|
||||
}
|
||||
|
||||
@ -1117,7 +1117,7 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
if allowFullWidth {
|
||||
tmpWidth = baseWidth
|
||||
if needsShareButton || isAd {
|
||||
tmpWidth -= 38.0
|
||||
tmpWidth -= 45.0
|
||||
} else {
|
||||
tmpWidth -= 4.0
|
||||
}
|
||||
@ -2168,14 +2168,19 @@ class ChatMessageBubbleItemNode: ChatMessageItemView, ChatMessagePreviewItemNode
|
||||
|
||||
if let nameNode = nameNodeSizeApply.1() {
|
||||
strongSelf.nameNode = nameNode
|
||||
nameNode.displaysAsynchronously = !item.presentationData.isPreview && !item.presentationData.theme.theme.forceSync
|
||||
|
||||
let previousNameNodeFrame = nameNode.frame
|
||||
let nameNodeFrame = CGRect(origin: CGPoint(x: contentOrigin.x + layoutConstants.text.bubbleInsets.left, y: layoutConstants.bubble.contentInsets.top + nameNodeOriginY), size: nameNodeSizeApply.0)
|
||||
nameNode.frame = nameNodeFrame
|
||||
if nameNode.supernode == nil {
|
||||
if !nameNode.isNodeLoaded {
|
||||
nameNode.isUserInteractionEnabled = false
|
||||
}
|
||||
strongSelf.clippingNode.addSubnode(nameNode)
|
||||
} else {
|
||||
transition.animatePositionAdditive(node: nameNode, offset: CGPoint(x: previousNameNodeFrame.maxX - nameNodeFrame.maxX, y: 0.0))
|
||||
}
|
||||
nameNode.frame = CGRect(origin: CGPoint(x: contentOrigin.x + layoutConstants.text.bubbleInsets.left, y: layoutConstants.bubble.contentInsets.top + nameNodeOriginY), size: nameNodeSizeApply.0)
|
||||
nameNode.displaysAsynchronously = !item.presentationData.isPreview && !item.presentationData.theme.theme.forceSync
|
||||
|
||||
if let credibilityIconImage = currentCredibilityIconImage {
|
||||
let credibilityIconNode: ASImageNode
|
||||
|
@ -198,7 +198,6 @@ struct ChatContactStatus: Equatable {
|
||||
var canReportIrrelevantLocation: Bool
|
||||
var peerStatusSettings: PeerStatusSettings?
|
||||
var invitedBy: Peer?
|
||||
var requestChatPeer: Peer?
|
||||
|
||||
var isEmpty: Bool {
|
||||
guard var peerStatusSettings = self.peerStatusSettings else {
|
||||
@ -226,9 +225,6 @@ struct ChatContactStatus: Equatable {
|
||||
if !arePeersEqual(lhs.invitedBy, rhs.invitedBy) {
|
||||
return false
|
||||
}
|
||||
if !arePeersEqual(lhs.requestChatPeer, rhs.requestChatPeer) {
|
||||
return false
|
||||
}
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
@ -1490,6 +1490,49 @@ struct ChatRecentActionsEntry: Comparable, Identifiable {
|
||||
let action = TelegramMediaActionType.customText(text: text, entities: entities)
|
||||
let message = Message(stableId: self.entry.stableId, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: Int32(bitPattern: self.entry.stableId)), globallyUniqueId: self.entry.event.id, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: self.entry.event.date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: author, text: "", attributes: [], media: [TelegramMediaAction(action: action)], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [])
|
||||
return ChatMessageItem(presentationData: self.presentationData, context: context, chatLocation: .peer(peer.id), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .channel, automaticDownloadNetworkType: .cellular, isRecentActions: true), controllerInteraction: controllerInteraction, content: .message(message: message, read: true, selection: .none, attributes: ChatMessageEntryAttributes(), location: nil))
|
||||
case let .sendMessage(message):
|
||||
switch self.id.contentIndex {
|
||||
case .header:
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var author: Peer?
|
||||
if self.entry.event.peerId == PeerId(namespace: Namespaces.Peer.CloudUser, id: PeerId.Id._internalFromInt64Value(136817688)) {
|
||||
author = message.effectiveAuthor
|
||||
} else if let peer = self.entry.peers[self.entry.event.peerId] {
|
||||
author = peer
|
||||
peers[peer.id] = peer
|
||||
}
|
||||
var text: String = ""
|
||||
var entities: [MessageTextEntity] = []
|
||||
|
||||
let textFormat = self.presentationData.strings.Channel_AdminLog_MessageSent
|
||||
appendAttributedText(text: textFormat(author.flatMap(EnginePeer.init)?.displayTitle(strings: self.presentationData.strings, displayOrder: self.presentationData.nameDisplayOrder) ?? ""), generateEntities: { index in
|
||||
if index == 0, let author = author {
|
||||
return [.TextMention(peerId: author.id)]
|
||||
}
|
||||
return []
|
||||
}, to: &text, entities: &entities)
|
||||
|
||||
let action = TelegramMediaActionType.customText(text: text, entities: entities)
|
||||
let message = Message(stableId: 0, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: 1), globallyUniqueId: self.entry.event.id, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: self.entry.event.date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: author, text: "", attributes: [], media: [TelegramMediaAction(action: action)], peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [])
|
||||
return ChatMessageItem(presentationData: self.presentationData, context: context, chatLocation: .peer(peer.id), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .channel, automaticDownloadNetworkType: .cellular, isRecentActions: true), controllerInteraction: controllerInteraction, content: .message(message: message, read: true, selection: .none, attributes: ChatMessageEntryAttributes(), location: nil))
|
||||
case .content:
|
||||
var peers = SimpleDictionary<PeerId, Peer>()
|
||||
var attributes: [MessageAttribute] = []
|
||||
for attribute in message.attributes {
|
||||
if let attribute = attribute as? TextEntitiesMessageAttribute {
|
||||
attributes.append(attribute)
|
||||
}
|
||||
}
|
||||
for attribute in attributes {
|
||||
for peerId in attribute.associatedPeerIds {
|
||||
if let peer = self.entry.peers[peerId] {
|
||||
peers[peer.id] = peer
|
||||
}
|
||||
}
|
||||
}
|
||||
let message = Message(stableId: self.entry.stableId, stableVersion: 0, id: MessageId(peerId: peer.id, namespace: Namespaces.Message.Cloud, id: Int32(bitPattern: self.entry.stableId)), globallyUniqueId: self.entry.event.id, groupingKey: nil, groupInfo: nil, threadId: nil, timestamp: self.entry.event.date, flags: [.Incoming], tags: [], globalTags: [], localTags: [], forwardInfo: nil, author: message.effectiveAuthor, text: message.text, attributes: attributes, media: message.media, peers: peers, associatedMessages: SimpleDictionary(), associatedMessageIds: [])
|
||||
return ChatMessageItem(presentationData: self.presentationData, context: context, chatLocation: .peer(peer.id), associatedData: ChatMessageItemAssociatedData(automaticDownloadPeerType: .channel, automaticDownloadNetworkType: .cellular, isRecentActions: true), controllerInteraction: controllerInteraction, content: .message(message: message, read: true, selection: .none, attributes: ChatMessageEntryAttributes(), location: nil))
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -446,14 +446,15 @@ final class ChatReportPeerTitlePanelNode: ChatTitleAccessoryPanelNode {
|
||||
}
|
||||
}
|
||||
|
||||
if let requestChatPeer = interfaceState.contactStatus?.requestChatPeer, let renderedPeer = interfaceState.renderedPeer, let peer = renderedPeer.chatMainPeer {
|
||||
if let requestChatTitle = interfaceState.contactStatus?.peerStatusSettings?.requestChatTitle, let requestChatIsChannel = interfaceState.contactStatus?.peerStatusSettings?.requestChatIsChannel, let renderedPeer = interfaceState.renderedPeer, let peer = renderedPeer.chatMainPeer {
|
||||
let text: NSAttributedString
|
||||
let regular = MarkdownAttributeSet(font: Font.regular(15.0), textColor: interfaceState.theme.rootController.navigationBar.primaryTextColor)
|
||||
let bold = MarkdownAttributeSet(font: Font.bold(15.0), textColor: interfaceState.theme.rootController.navigationBar.primaryTextColor)
|
||||
if let requestChatPeer = requestChatPeer as? TelegramChannel, case .broadcast = requestChatPeer.info {
|
||||
text = addAttributesToStringWithRanges(interfaceState.strings.Conversation_InviteRequestAdminChannel(EnginePeer(peer).compactDisplayTitle, EnginePeer(requestChatPeer).displayTitle(strings: interfaceState.strings, displayOrder: interfaceState.nameDisplayOrder))._tuple, body: regular, argumentAttributes: [0: bold, 1: bold])
|
||||
|
||||
if requestChatIsChannel {
|
||||
text = addAttributesToStringWithRanges(interfaceState.strings.Conversation_InviteRequestAdminChannel(EnginePeer(peer).compactDisplayTitle, requestChatTitle)._tuple, body: regular, argumentAttributes: [0: bold, 1: bold])
|
||||
} else {
|
||||
text = addAttributesToStringWithRanges(interfaceState.strings.Conversation_InviteRequestAdminGroup(EnginePeer(peer).compactDisplayTitle, EnginePeer(requestChatPeer).displayTitle(strings: interfaceState.strings, displayOrder: interfaceState.nameDisplayOrder))._tuple, body: regular, argumentAttributes: [0: bold, 1: bold])
|
||||
text = addAttributesToStringWithRanges(interfaceState.strings.Conversation_InviteRequestAdminGroup(EnginePeer(peer).compactDisplayTitle, requestChatTitle)._tuple, body: regular, argumentAttributes: [0: bold, 1: bold])
|
||||
}
|
||||
self.textNode.attributedText = text
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user