diff --git a/submodules/ChatInterfaceState/Sources/ChatInterfaceState.swift b/submodules/ChatInterfaceState/Sources/ChatInterfaceState.swift index bcc798afd9..830419853e 100644 --- a/submodules/ChatInterfaceState/Sources/ChatInterfaceState.swift +++ b/submodules/ChatInterfaceState/Sources/ChatInterfaceState.swift @@ -93,25 +93,28 @@ public struct ChatEditMessageState: PostboxCoding, Equatable { public struct ChatInterfaceMessageActionsState: PostboxCoding, Equatable { public var closedButtonKeyboardMessageId: MessageId? + public var dismissedButtonKeyboardMessageId: MessageId? public var processedSetupReplyMessageId: MessageId? public var closedPinnedMessageId: MessageId? public var closedPeerSpecificPackSetup: Bool = false public var dismissedAddContactPhoneNumber: String? public var isEmpty: Bool { - return self.closedButtonKeyboardMessageId == nil && self.processedSetupReplyMessageId == nil && self.closedPinnedMessageId == nil && self.closedPeerSpecificPackSetup == false && self.dismissedAddContactPhoneNumber == nil + return self.closedButtonKeyboardMessageId == nil && self.dismissedButtonKeyboardMessageId == nil && self.processedSetupReplyMessageId == nil && self.closedPinnedMessageId == nil && self.closedPeerSpecificPackSetup == false && self.dismissedAddContactPhoneNumber == nil } public init() { self.closedButtonKeyboardMessageId = nil + self.dismissedButtonKeyboardMessageId = nil self.processedSetupReplyMessageId = nil self.closedPinnedMessageId = nil self.closedPeerSpecificPackSetup = false self.dismissedAddContactPhoneNumber = nil } - public init(closedButtonKeyboardMessageId: MessageId?, processedSetupReplyMessageId: MessageId?, closedPinnedMessageId: MessageId?, closedPeerSpecificPackSetup: Bool, dismissedAddContactPhoneNumber: String?) { + public init(closedButtonKeyboardMessageId: MessageId?, dismissedButtonKeyboardMessageId: MessageId?, processedSetupReplyMessageId: MessageId?, closedPinnedMessageId: MessageId?, closedPeerSpecificPackSetup: Bool, dismissedAddContactPhoneNumber: String?) { self.closedButtonKeyboardMessageId = closedButtonKeyboardMessageId + self.dismissedButtonKeyboardMessageId = dismissedButtonKeyboardMessageId self.processedSetupReplyMessageId = processedSetupReplyMessageId self.closedPinnedMessageId = closedPinnedMessageId self.closedPeerSpecificPackSetup = closedPeerSpecificPackSetup @@ -124,6 +127,12 @@ public struct ChatInterfaceMessageActionsState: PostboxCoding, Equatable { } else { self.closedButtonKeyboardMessageId = nil } + + if let messageIdPeerId = decoder.decodeOptionalInt64ForKey("dismissedbuttons.p"), let messageIdNamespace = decoder.decodeOptionalInt32ForKey("dismissedbuttons.n"), let messageIdId = decoder.decodeOptionalInt32ForKey("dismissedbuttons.i") { + self.dismissedButtonKeyboardMessageId = MessageId(peerId: PeerId(messageIdPeerId), namespace: messageIdNamespace, id: messageIdId) + } else { + self.dismissedButtonKeyboardMessageId = nil + } if let processedMessageIdPeerId = decoder.decodeOptionalInt64ForKey("pb.p"), let processedMessageIdNamespace = decoder.decodeOptionalInt32ForKey("pb.n"), let processedMessageIdId = decoder.decodeOptionalInt32ForKey("pb.i") { self.processedSetupReplyMessageId = MessageId(peerId: PeerId(processedMessageIdPeerId), namespace: processedMessageIdNamespace, id: processedMessageIdId) @@ -150,6 +159,16 @@ public struct ChatInterfaceMessageActionsState: PostboxCoding, Equatable { encoder.encodeNil(forKey: "cb.n") encoder.encodeNil(forKey: "cb.i") } + + if let dismissedButtonKeyboardMessageId = self.dismissedButtonKeyboardMessageId { + encoder.encodeInt64(dismissedButtonKeyboardMessageId.peerId.toInt64(), forKey: "dismissedbuttons.p") + encoder.encodeInt32(dismissedButtonKeyboardMessageId.namespace, forKey: "dismissedbuttons.n") + encoder.encodeInt32(dismissedButtonKeyboardMessageId.id, forKey: "dismissedbuttons.i") + } else { + encoder.encodeNil(forKey: "dismissedbuttons.p") + encoder.encodeNil(forKey: "dismissedbuttons.n") + encoder.encodeNil(forKey: "dismissedbuttons.i") + } if let processedSetupReplyMessageId = self.processedSetupReplyMessageId { encoder.encodeInt64(processedSetupReplyMessageId.peerId.toInt64(), forKey: "pb.p") diff --git a/submodules/SyncCore/Sources/ReplyMarkupMessageAttribute.swift b/submodules/SyncCore/Sources/ReplyMarkupMessageAttribute.swift index d1eb42c27c..33e8c4db04 100644 --- a/submodules/SyncCore/Sources/ReplyMarkupMessageAttribute.swift +++ b/submodules/SyncCore/Sources/ReplyMarkupMessageAttribute.swift @@ -150,23 +150,31 @@ public struct ReplyMarkupMessageFlags: OptionSet { public class ReplyMarkupMessageAttribute: MessageAttribute, Equatable { public let rows: [ReplyMarkupRow] public let flags: ReplyMarkupMessageFlags + public let placeholder: String? - public init(rows: [ReplyMarkupRow], flags: ReplyMarkupMessageFlags) { + public init(rows: [ReplyMarkupRow], flags: ReplyMarkupMessageFlags, placeholder: String?) { self.rows = rows self.flags = flags + self.placeholder = placeholder } public required init(decoder: PostboxDecoder) { self.rows = decoder.decodeObjectArrayWithDecoderForKey("r") self.flags = ReplyMarkupMessageFlags(rawValue: decoder.decodeInt32ForKey("f", orElse: 0)) + self.placeholder = decoder.decodeOptionalStringForKey("pl") } public func encode(_ encoder: PostboxEncoder) { encoder.encodeObjectArray(self.rows, forKey: "r") encoder.encodeInt32(self.flags.rawValue, forKey: "f") + if let placeholder = self.placeholder { + encoder.encodeString(placeholder, forKey: "pl") + } else { + encoder.encodeNil(forKey: "pl") + } } public static func ==(lhs: ReplyMarkupMessageAttribute, rhs: ReplyMarkupMessageAttribute) -> Bool { - return lhs.flags == rhs.flags && lhs.rows == rhs.rows + return lhs.flags == rhs.flags && lhs.rows == rhs.rows && lhs.placeholder == rhs.placeholder } } diff --git a/submodules/TelegramApi/Sources/Api0.swift b/submodules/TelegramApi/Sources/Api0.swift index e3781907b5..3c9df65cf7 100644 --- a/submodules/TelegramApi/Sources/Api0.swift +++ b/submodules/TelegramApi/Sources/Api0.swift @@ -529,8 +529,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-786326563] = { return Api.InputPrivacyKey.parse_inputPrivacyKeyAddedByPhone($0) } dict[235081943] = { return Api.help.RecentMeUrls.parse_recentMeUrls($0) } dict[-1606526075] = { return Api.ReplyMarkup.parse_replyKeyboardHide($0) } - dict[-200242528] = { return Api.ReplyMarkup.parse_replyKeyboardForceReply($0) } - dict[889353612] = { return Api.ReplyMarkup.parse_replyKeyboardMarkup($0) } + dict[-2035021048] = { return Api.ReplyMarkup.parse_replyKeyboardForceReply($0) } + dict[-2049074735] = { return Api.ReplyMarkup.parse_replyKeyboardMarkup($0) } dict[1218642516] = { return Api.ReplyMarkup.parse_replyInlineMarkup($0) } dict[1556570557] = { return Api.EmojiKeywordsDifference.parse_emojiKeywordsDifference($0) } dict[1493171408] = { return Api.HighScore.parse_highScore($0) } @@ -584,6 +584,13 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = { dict[-58224696] = { return Api.PhoneCallProtocol.parse_phoneCallProtocol($0) } dict[-1237848657] = { return Api.StatsDateRangeDays.parse_statsDateRangeDays($0) } dict[-275956116] = { return Api.messages.AffectedFoundMessages.parse_affectedFoundMessages($0) } + dict[795652779] = { return Api.BotCommandScope.parse_botCommandScopeDefault($0) } + dict[1011811544] = { return Api.BotCommandScope.parse_botCommandScopeUsers($0) } + dict[1877059713] = { return Api.BotCommandScope.parse_botCommandScopeChats($0) } + dict[-1180016534] = { return Api.BotCommandScope.parse_botCommandScopeChatAdmins($0) } + dict[-610432643] = { return Api.BotCommandScope.parse_botCommandScopePeer($0) } + dict[1071145937] = { return Api.BotCommandScope.parse_botCommandScopePeerAdmins($0) } + dict[169026035] = { return Api.BotCommandScope.parse_botCommandScopePeerUser($0) } dict[-1539849235] = { return Api.WallPaper.parse_wallPaper($0) } dict[-528465642] = { return Api.WallPaper.parse_wallPaperNoFile($0) } dict[-1938715001] = { return Api.messages.Messages.parse_messages($0) } @@ -1346,6 +1353,8 @@ public struct Api { _1.serialize(buffer, boxed) case let _1 as Api.messages.AffectedFoundMessages: _1.serialize(buffer, boxed) + case let _1 as Api.BotCommandScope: + _1.serialize(buffer, boxed) case let _1 as Api.WallPaper: _1.serialize(buffer, boxed) case let _1 as Api.messages.Messages: diff --git a/submodules/TelegramApi/Sources/Api2.swift b/submodules/TelegramApi/Sources/Api2.swift index e614bcab02..6c382b818b 100644 --- a/submodules/TelegramApi/Sources/Api2.swift +++ b/submodules/TelegramApi/Sources/Api2.swift @@ -13307,8 +13307,8 @@ public extension Api { } public enum ReplyMarkup: TypeConstructorDescription { case replyKeyboardHide(flags: Int32) - case replyKeyboardForceReply(flags: Int32) - case replyKeyboardMarkup(flags: Int32, rows: [Api.KeyboardButtonRow]) + case replyKeyboardForceReply(flags: Int32, placeholder: String?) + case replyKeyboardMarkup(flags: Int32, rows: [Api.KeyboardButtonRow], placeholder: String?) case replyInlineMarkup(rows: [Api.KeyboardButtonRow]) public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { @@ -13319,15 +13319,16 @@ public extension Api { } serializeInt32(flags, buffer: buffer, boxed: false) break - case .replyKeyboardForceReply(let flags): + case .replyKeyboardForceReply(let flags, let placeholder): if boxed { - buffer.appendInt32(-200242528) + buffer.appendInt32(-2035021048) } serializeInt32(flags, buffer: buffer, boxed: false) + if Int(flags) & Int(1 << 3) != 0 {serializeString(placeholder!, buffer: buffer, boxed: false)} break - case .replyKeyboardMarkup(let flags, let rows): + case .replyKeyboardMarkup(let flags, let rows, let placeholder): if boxed { - buffer.appendInt32(889353612) + buffer.appendInt32(-2049074735) } serializeInt32(flags, buffer: buffer, boxed: false) buffer.appendInt32(481674261) @@ -13335,6 +13336,7 @@ public extension Api { for item in rows { item.serialize(buffer, true) } + if Int(flags) & Int(1 << 3) != 0 {serializeString(placeholder!, buffer: buffer, boxed: false)} break case .replyInlineMarkup(let rows): if boxed { @@ -13353,10 +13355,10 @@ public extension Api { switch self { case .replyKeyboardHide(let flags): return ("replyKeyboardHide", [("flags", flags)]) - case .replyKeyboardForceReply(let flags): - return ("replyKeyboardForceReply", [("flags", flags)]) - case .replyKeyboardMarkup(let flags, let rows): - return ("replyKeyboardMarkup", [("flags", flags), ("rows", rows)]) + case .replyKeyboardForceReply(let flags, let placeholder): + return ("replyKeyboardForceReply", [("flags", flags), ("placeholder", placeholder)]) + case .replyKeyboardMarkup(let flags, let rows, let placeholder): + return ("replyKeyboardMarkup", [("flags", flags), ("rows", rows), ("placeholder", placeholder)]) case .replyInlineMarkup(let rows): return ("replyInlineMarkup", [("rows", rows)]) } @@ -13376,9 +13378,12 @@ public extension Api { public static func parse_replyKeyboardForceReply(_ reader: BufferReader) -> ReplyMarkup? { var _1: Int32? _1 = reader.readInt32() + var _2: String? + if Int(_1!) & Int(1 << 3) != 0 {_2 = parseString(reader) } let _c1 = _1 != nil - if _c1 { - return Api.ReplyMarkup.replyKeyboardForceReply(flags: _1!) + let _c2 = (Int(_1!) & Int(1 << 3) == 0) || _2 != nil + if _c1 && _c2 { + return Api.ReplyMarkup.replyKeyboardForceReply(flags: _1!, placeholder: _2) } else { return nil @@ -13391,10 +13396,13 @@ public extension Api { if let _ = reader.readInt32() { _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.KeyboardButtonRow.self) } + var _3: String? + if Int(_1!) & Int(1 << 3) != 0 {_3 = parseString(reader) } let _c1 = _1 != nil let _c2 = _2 != nil - if _c1 && _c2 { - return Api.ReplyMarkup.replyKeyboardMarkup(flags: _1!, rows: _2!) + let _c3 = (Int(_1!) & Int(1 << 3) == 0) || _3 != nil + if _c1 && _c2 && _c3 { + return Api.ReplyMarkup.replyKeyboardMarkup(flags: _1!, rows: _2!, placeholder: _3) } else { return nil @@ -15070,6 +15078,140 @@ public extension Api { } } + } + public enum BotCommandScope: TypeConstructorDescription { + case botCommandScopeDefault + case botCommandScopeUsers + case botCommandScopeChats + case botCommandScopeChatAdmins + case botCommandScopePeer(peer: Api.InputPeer) + case botCommandScopePeerAdmins(peer: Api.InputPeer) + case botCommandScopePeerUser(peer: Api.InputPeer, userId: Api.InputUser) + + public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { + switch self { + case .botCommandScopeDefault: + if boxed { + buffer.appendInt32(795652779) + } + + break + case .botCommandScopeUsers: + if boxed { + buffer.appendInt32(1011811544) + } + + break + case .botCommandScopeChats: + if boxed { + buffer.appendInt32(1877059713) + } + + break + case .botCommandScopeChatAdmins: + if boxed { + buffer.appendInt32(-1180016534) + } + + break + case .botCommandScopePeer(let peer): + if boxed { + buffer.appendInt32(-610432643) + } + peer.serialize(buffer, true) + break + case .botCommandScopePeerAdmins(let peer): + if boxed { + buffer.appendInt32(1071145937) + } + peer.serialize(buffer, true) + break + case .botCommandScopePeerUser(let peer, let userId): + if boxed { + buffer.appendInt32(169026035) + } + peer.serialize(buffer, true) + userId.serialize(buffer, true) + break + } + } + + public func descriptionFields() -> (String, [(String, Any)]) { + switch self { + case .botCommandScopeDefault: + return ("botCommandScopeDefault", []) + case .botCommandScopeUsers: + return ("botCommandScopeUsers", []) + case .botCommandScopeChats: + return ("botCommandScopeChats", []) + case .botCommandScopeChatAdmins: + return ("botCommandScopeChatAdmins", []) + case .botCommandScopePeer(let peer): + return ("botCommandScopePeer", [("peer", peer)]) + case .botCommandScopePeerAdmins(let peer): + return ("botCommandScopePeerAdmins", [("peer", peer)]) + case .botCommandScopePeerUser(let peer, let userId): + return ("botCommandScopePeerUser", [("peer", peer), ("userId", userId)]) + } + } + + public static func parse_botCommandScopeDefault(_ reader: BufferReader) -> BotCommandScope? { + return Api.BotCommandScope.botCommandScopeDefault + } + public static func parse_botCommandScopeUsers(_ reader: BufferReader) -> BotCommandScope? { + return Api.BotCommandScope.botCommandScopeUsers + } + public static func parse_botCommandScopeChats(_ reader: BufferReader) -> BotCommandScope? { + return Api.BotCommandScope.botCommandScopeChats + } + public static func parse_botCommandScopeChatAdmins(_ reader: BufferReader) -> BotCommandScope? { + return Api.BotCommandScope.botCommandScopeChatAdmins + } + public static func parse_botCommandScopePeer(_ reader: BufferReader) -> BotCommandScope? { + var _1: Api.InputPeer? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.InputPeer + } + let _c1 = _1 != nil + if _c1 { + return Api.BotCommandScope.botCommandScopePeer(peer: _1!) + } + else { + return nil + } + } + public static func parse_botCommandScopePeerAdmins(_ reader: BufferReader) -> BotCommandScope? { + var _1: Api.InputPeer? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.InputPeer + } + let _c1 = _1 != nil + if _c1 { + return Api.BotCommandScope.botCommandScopePeerAdmins(peer: _1!) + } + else { + return nil + } + } + public static func parse_botCommandScopePeerUser(_ reader: BufferReader) -> BotCommandScope? { + var _1: Api.InputPeer? + if let signature = reader.readInt32() { + _1 = Api.parse(reader, signature: signature) as? Api.InputPeer + } + var _2: Api.InputUser? + if let signature = reader.readInt32() { + _2 = Api.parse(reader, signature: signature) as? Api.InputUser + } + let _c1 = _1 != nil + let _c2 = _2 != nil + if _c1 && _c2 { + return Api.BotCommandScope.botCommandScopePeerUser(peer: _1!, userId: _2!) + } + else { + return nil + } + } + } public enum WallPaper: TypeConstructorDescription { case wallPaper(id: Int64, flags: Int32, accessHash: Int64, slug: String, document: Api.Document, settings: Api.WallPaperSettings?) diff --git a/submodules/TelegramApi/Sources/Api4.swift b/submodules/TelegramApi/Sources/Api4.swift index 327121ee77..a10771b704 100644 --- a/submodules/TelegramApi/Sources/Api4.swift +++ b/submodules/TelegramApi/Sources/Api4.swift @@ -5391,15 +5391,17 @@ public extension Api { }) } - public static func setBotCommands(commands: [Api.BotCommand]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func setBotCommands(scope: Api.BotCommandScope, langCode: String, commands: [Api.BotCommand]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-2141370634) + buffer.appendInt32(85399130) + scope.serialize(buffer, true) + serializeString(langCode, buffer: buffer, boxed: false) buffer.appendInt32(481674261) buffer.appendInt32(Int32(commands.count)) for item in commands { item.serialize(buffer, true) } - return (FunctionDescription(name: "bots.setBotCommands", parameters: [("commands", commands)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in + return (FunctionDescription(name: "bots.setBotCommands", parameters: [("scope", scope), ("langCode", langCode), ("commands", commands)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in let reader = BufferReader(buffer) var result: Api.Bool? if let signature = reader.readInt32() { @@ -5408,6 +5410,21 @@ public extension Api { return result }) } + + public static func getBotCommands(scope: Api.BotCommandScope, langCode: String) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.BotCommand]>) { + let buffer = Buffer() + buffer.appendInt32(-481554986) + scope.serialize(buffer, true) + serializeString(langCode, buffer: buffer, boxed: false) + return (FunctionDescription(name: "bots.getBotCommands", parameters: [("scope", scope), ("langCode", langCode)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> [Api.BotCommand]? in + let reader = BufferReader(buffer) + var result: [Api.BotCommand]? + if let _ = reader.readInt32() { + result = Api.parseVector(reader, elementSignature: 0, elementType: Api.BotCommand.self) + } + return result + }) + } } public struct users { public static func getUsers(id: [Api.InputUser]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.User]>) { @@ -6316,9 +6333,9 @@ public extension Api { } } public struct stickers { - public static func createStickerSet(flags: Int32, userId: Api.InputUser, title: String, shortName: String, thumb: Api.InputDocument?, stickers: [Api.InputStickerSetItem]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { + public static func createStickerSet(flags: Int32, userId: Api.InputUser, title: String, shortName: String, thumb: Api.InputDocument?, stickers: [Api.InputStickerSetItem], software: String?) -> (FunctionDescription, Buffer, DeserializeFunctionResponse) { let buffer = Buffer() - buffer.appendInt32(-251435136) + buffer.appendInt32(-1876841625) serializeInt32(flags, buffer: buffer, boxed: false) userId.serialize(buffer, true) serializeString(title, buffer: buffer, boxed: false) @@ -6329,7 +6346,8 @@ public extension Api { for item in stickers { item.serialize(buffer, true) } - return (FunctionDescription(name: "stickers.createStickerSet", parameters: [("flags", flags), ("userId", userId), ("title", title), ("shortName", shortName), ("thumb", thumb), ("stickers", stickers)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.StickerSet? in + if Int(flags) & Int(1 << 3) != 0 {serializeString(software!, buffer: buffer, boxed: false)} + return (FunctionDescription(name: "stickers.createStickerSet", parameters: [("flags", flags), ("userId", userId), ("title", title), ("shortName", shortName), ("thumb", thumb), ("stickers", stickers), ("software", software)]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.StickerSet? in let reader = BufferReader(buffer) var result: Api.messages.StickerSet? if let signature = reader.readInt32() { diff --git a/submodules/TelegramCore/Sources/MessageUtils.swift b/submodules/TelegramCore/Sources/MessageUtils.swift index 80f922b68b..4ac9fb61f0 100644 --- a/submodules/TelegramCore/Sources/MessageUtils.swift +++ b/submodules/TelegramCore/Sources/MessageUtils.swift @@ -25,6 +25,22 @@ public extension Message { } return nil } + + var visibleReplyMarkupPlaceholder: String? { + for attribute in self.attributes { + if let attribute = attribute as? ReplyMarkupMessageAttribute { + if !attribute.flags.contains(.inline) { + if attribute.flags.contains(.personal) { + if !personal { + return nil + } + } + return attribute.placeholder + } + } + } + return nil + } var muted: Bool { for attribute in self.attributes { diff --git a/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift b/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift index 3599c947c6..c664d3e96a 100644 --- a/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift +++ b/submodules/TelegramCore/Sources/PendingMessages/EnqueueMessage.swift @@ -603,7 +603,7 @@ func enqueueMessages(transaction: Transaction, account: Account, peerId: PeerId, } if !rows.isEmpty { - attributes.append(ReplyMarkupMessageAttribute(rows: rows, flags: sourceReplyMarkup.flags)) + attributes.append(ReplyMarkupMessageAttribute(rows: rows, flags: sourceReplyMarkup.flags, placeholder: sourceReplyMarkup.placeholder)) } } diff --git a/submodules/TelegramCore/Sources/ReplyMarkupMessageAttribute.swift b/submodules/TelegramCore/Sources/ReplyMarkupMessageAttribute.swift index 3f42956000..02917a8b14 100644 --- a/submodules/TelegramCore/Sources/ReplyMarkupMessageAttribute.swift +++ b/submodules/TelegramCore/Sources/ReplyMarkupMessageAttribute.swift @@ -56,8 +56,9 @@ extension ReplyMarkupMessageAttribute { convenience init(apiMarkup: Api.ReplyMarkup) { var rows: [ReplyMarkupRow] = [] var flags = ReplyMarkupMessageFlags() + var placeholder: String? switch apiMarkup { - case let .replyKeyboardMarkup(markupFlags, apiRows): + case let .replyKeyboardMarkup(markupFlags, apiRows, apiPlaceholder): rows = apiRows.map { ReplyMarkupRow(apiRow: $0) } if (markupFlags & (1 << 0)) != 0 { flags.insert(.fit) @@ -68,10 +69,11 @@ extension ReplyMarkupMessageAttribute { if (markupFlags & (1 << 2)) != 0 { flags.insert(.personal) } + placeholder = apiPlaceholder case let .replyInlineMarkup(apiRows): rows = apiRows.map { ReplyMarkupRow(apiRow: $0) } flags.insert(.inline) - case let .replyKeyboardForceReply(forceReplyFlags): + case let .replyKeyboardForceReply(forceReplyFlags, apiPlaceholder): if (forceReplyFlags & (1 << 1)) != 0 { flags.insert(.once) } @@ -79,11 +81,12 @@ extension ReplyMarkupMessageAttribute { flags.insert(.personal) } flags.insert(.setupReply) + placeholder = apiPlaceholder case let .replyKeyboardHide(hideFlags): if (hideFlags & (1 << 2)) != 0 { flags.insert(.personal) } } - self.init(rows: rows, flags: flags) + self.init(rows: rows, flags: flags, placeholder: placeholder) } } diff --git a/submodules/TelegramCore/Sources/State/Serialization.swift b/submodules/TelegramCore/Sources/State/Serialization.swift index 0ea3aa0e9f..2d992c7f59 100644 --- a/submodules/TelegramCore/Sources/State/Serialization.swift +++ b/submodules/TelegramCore/Sources/State/Serialization.swift @@ -210,7 +210,7 @@ public class BoxedMessage: NSObject { public class Serialization: NSObject, MTSerialization { public func currentLayer() -> UInt { - return 129 + return 130 } public func parseMessage(_ data: Data!) -> Any! { diff --git a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift index ce3aec5e43..0b46fcd44b 100644 --- a/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift +++ b/submodules/TelegramCore/Sources/TelegramEngine/Stickers/ImportStickers.swift @@ -140,7 +140,7 @@ func _internal_createStickerSet(account: Account, title: String, shortName: Stri flags |= (1 << 2) thumbnailDocument = .inputDocument(id: resource.fileId, accessHash: resource.accessHash, fileReference: Buffer(data: resource.fileReference ?? Data())) } - return account.network.request(Api.functions.stickers.createStickerSet(flags: flags, userId: inputUser, title: title, shortName: shortName, thumb: thumbnailDocument, stickers: inputStickers)) + return account.network.request(Api.functions.stickers.createStickerSet(flags: flags, userId: inputUser, title: title, shortName: shortName, thumb: thumbnailDocument, stickers: inputStickers, software: nil)) |> mapError { error -> CreateStickerSetError in return .generic } diff --git a/submodules/TelegramUI/Sources/ChatController.swift b/submodules/TelegramUI/Sources/ChatController.swift index 8362760391..32fa2aa06f 100644 --- a/submodules/TelegramUI/Sources/ChatController.swift +++ b/submodules/TelegramUI/Sources/ChatController.swift @@ -2527,6 +2527,7 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G $0.withUpdatedMessageActionsState({ value in var value = value value.closedButtonKeyboardMessageId = message.id + value.dismissedButtonKeyboardMessageId = message.id return value }) }) @@ -7519,9 +7520,9 @@ public final class ChatControllerImpl: TelegramBaseController, ChatController, G var completion = externalCompletion var temporaryChatPresentationInterfaceState = f(self.presentationInterfaceState) - if self.presentationInterfaceState.keyboardButtonsMessage?.visibleButtonKeyboardMarkup != temporaryChatPresentationInterfaceState.keyboardButtonsMessage?.visibleButtonKeyboardMarkup { + if self.presentationInterfaceState.keyboardButtonsMessage?.visibleButtonKeyboardMarkup != temporaryChatPresentationInterfaceState.keyboardButtonsMessage?.visibleButtonKeyboardMarkup || self.presentationInterfaceState.keyboardButtonsMessage?.id != temporaryChatPresentationInterfaceState.keyboardButtonsMessage?.id { if let keyboardButtonsMessage = temporaryChatPresentationInterfaceState.keyboardButtonsMessage, let _ = keyboardButtonsMessage.visibleButtonKeyboardMarkup { - if self.presentationInterfaceState.interfaceState.editMessage == nil && self.presentationInterfaceState.interfaceState.composeInputState.inputText.length == 0 && keyboardButtonsMessage.id != temporaryChatPresentationInterfaceState.interfaceState.messageActionsState.closedButtonKeyboardMessageId && temporaryChatPresentationInterfaceState.botStartPayload == nil { + if self.presentationInterfaceState.interfaceState.editMessage == nil && self.presentationInterfaceState.interfaceState.composeInputState.inputText.length == 0 && keyboardButtonsMessage.id != temporaryChatPresentationInterfaceState.interfaceState.messageActionsState.closedButtonKeyboardMessageId && keyboardButtonsMessage.id != temporaryChatPresentationInterfaceState.interfaceState.messageActionsState.dismissedButtonKeyboardMessageId && temporaryChatPresentationInterfaceState.botStartPayload == nil { temporaryChatPresentationInterfaceState = temporaryChatPresentationInterfaceState.updatedInputMode({ _ in return .inputButtons }) diff --git a/submodules/TelegramUI/Sources/ChatInterfaceInputContexts.swift b/submodules/TelegramUI/Sources/ChatInterfaceInputContexts.swift index 7603550bfd..fbe8b8c8fd 100644 --- a/submodules/TelegramUI/Sources/ChatInterfaceInputContexts.swift +++ b/submodules/TelegramUI/Sources/ChatInterfaceInputContexts.swift @@ -319,7 +319,7 @@ func inputTextPanelStateForChatPresentationInterfaceState(_ chatPresentationInte accessoryItems.append(.commands) } accessoryItems.append(.stickers(stickersEnabled)) - if let message = chatPresentationInterfaceState.keyboardButtonsMessage, let _ = message.visibleButtonKeyboardMarkup { + if let message = chatPresentationInterfaceState.keyboardButtonsMessage, let _ = message.visibleButtonKeyboardMarkup, chatPresentationInterfaceState.interfaceState.messageActionsState.dismissedButtonKeyboardMessageId != message.id { accessoryItems.append(.inputButtons) } } diff --git a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift index 20a2dd18a4..a4ad84c455 100644 --- a/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift +++ b/submodules/TelegramUI/Sources/ChatTextInputPanelNode.swift @@ -901,11 +901,14 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { } } } + + let dismissedButtonMessageUpdated = interfaceState.interfaceState.messageActionsState.dismissedButtonKeyboardMessageId != previousState?.interfaceState.messageActionsState.dismissedButtonKeyboardMessageId + let replyMessageUpdated = interfaceState.interfaceState.replyMessageId != previousState?.interfaceState.replyMessageId - if let peer = interfaceState.renderedPeer?.peer, previousState?.renderedPeer?.peer == nil || !peer.isEqual(previousState!.renderedPeer!.peer!) || previousState?.interfaceState.silentPosting != interfaceState.interfaceState.silentPosting || themeUpdated || !self.initializedPlaceholder { + if let peer = interfaceState.renderedPeer?.peer, previousState?.renderedPeer?.peer == nil || !peer.isEqual(previousState!.renderedPeer!.peer!) || previousState?.interfaceState.silentPosting != interfaceState.interfaceState.silentPosting || themeUpdated || !self.initializedPlaceholder || previousState?.keyboardButtonsMessage?.id != interfaceState.keyboardButtonsMessage?.id || previousState?.keyboardButtonsMessage?.visibleReplyMarkupPlaceholder != interfaceState.keyboardButtonsMessage?.visibleReplyMarkupPlaceholder || dismissedButtonMessageUpdated || replyMessageUpdated { self.initializedPlaceholder = true - let placeholder: String + var placeholder: String if let channel = peer as? TelegramChannel, case .broadcast = channel.info { if interfaceState.interfaceState.silentPosting { placeholder = interfaceState.strings.Conversation_InputTextSilentBroadcastPlaceholder @@ -923,6 +926,16 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { } else { placeholder = interfaceState.strings.Conversation_InputTextPlaceholder } + + if let keyboardButtonsMessage = interfaceState.keyboardButtonsMessage, interfaceState.interfaceState.messageActionsState.dismissedButtonKeyboardMessageId != keyboardButtonsMessage.id { + if keyboardButtonsMessage.requestsSetupReply && keyboardButtonsMessage.id != interfaceState.interfaceState.replyMessageId { + } else { + if let placeholderValue = interfaceState.keyboardButtonsMessage?.visibleReplyMarkupPlaceholder, !placeholderValue.isEmpty { + placeholder = placeholderValue + } + } + } + if self.currentPlaceholder != placeholder || themeUpdated { self.currentPlaceholder = placeholder let baseFontSize = max(minInputFontSize, interfaceState.fontSize.baseDisplaySize) @@ -1041,9 +1054,14 @@ class ChatTextInputPanelNode: ChatInputPanelNode, ASEditableTextNodeDelegate { if let textInputNode = self.textInputNode, let attributedText = textInputNode.attributedText, attributedText.length != 0 { inputHasText = true } - - if [.none, .inputButtons].contains(interfaceState.inputMode) && !inputHasText { - menuButtonExpanded = true + + if !inputHasText { + switch interfaceState.inputMode { + case .none, .inputButtons: + menuButtonExpanded = true + default: + break + } } } if mediaRecordingState != nil {