mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-10-09 03:20:48 +00:00
Topic improvements
This commit is contained in:
parent
7d335e817a
commit
f1864a43b9
@ -519,7 +519,7 @@ func chatForumTopicMenuItems(context: AccountContext, peerId: PeerId, threadId:
|
||||
items.append(.action(ContextMenuActionItem(text: isPinned ? presentationData.strings.ChatList_Context_Unpin : presentationData.strings.ChatList_Context_Pin, icon: { theme in generateTintedImage(image: UIImage(bundleImageName: isPinned ? "Chat/Context Menu/Unpin": "Chat/Context Menu/Pin"), color: theme.contextMenu.primaryColor) }, action: { _, f in
|
||||
f(.default)
|
||||
|
||||
let _ = context.engine.peers.setForumChannelTopicPinned(id: peerId, threadId: threadId, isPinned: !isPinned).start()
|
||||
let _ = context.engine.peers.toggleForumChannelTopicPinned(id: peerId, threadId: threadId).start()
|
||||
})))
|
||||
}
|
||||
|
||||
|
@ -3851,7 +3851,7 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController
|
||||
}
|
||||
|
||||
private func setPeerThreadPinned(peerId: EnginePeer.Id, threadId: Int64, isPinned: Bool) {
|
||||
self.actionDisposables.add(self.context.engine.peers.setForumChannelTopicPinned(id: peerId, threadId: threadId, isPinned: isPinned).start())
|
||||
self.actionDisposables.add(self.context.engine.peers.toggleForumChannelTopicPinned(id: peerId, threadId: threadId).start())
|
||||
}
|
||||
|
||||
public func maybeAskForPeerChatRemoval(peer: EngineRenderedPeer, joined: Bool = false, deleteGloballyIfPossible: Bool = false, completion: @escaping (Bool) -> Void, removed: @escaping () -> Void) {
|
||||
|
@ -268,7 +268,7 @@ private final class ChatListViewSpaceState {
|
||||
}
|
||||
postboxLog("allIndices not unique, repeated: \(debugRepeatedIndices)")
|
||||
|
||||
assert(false)
|
||||
//assert(false)
|
||||
//preconditionFailure()
|
||||
}
|
||||
if Set(allEntityIds).count != allEntityIds.count {
|
||||
|
@ -778,7 +778,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
|
||||
dict[-761649164] = { return Api.Update.parse_updateChannelMessageForwards($0) }
|
||||
dict[-232346616] = { return Api.Update.parse_updateChannelMessageViews($0) }
|
||||
dict[-1738720581] = { return Api.Update.parse_updateChannelParticipant($0) }
|
||||
dict[-158027602] = { return Api.Update.parse_updateChannelPinnedTopic($0) }
|
||||
dict[422509539] = { return Api.Update.parse_updateChannelPinnedTopic($0) }
|
||||
dict[-31881726] = { return Api.Update.parse_updateChannelPinnedTopics($0) }
|
||||
dict[-366410403] = { return Api.Update.parse_updateChannelReadMessagesContents($0) }
|
||||
dict[277713951] = { return Api.Update.parse_updateChannelTooLong($0) }
|
||||
dict[-1937192669] = { return Api.Update.parse_updateChannelUserTyping($0) }
|
||||
|
@ -671,7 +671,8 @@ public extension Api {
|
||||
case updateChannelMessageForwards(channelId: Int64, id: Int32, forwards: Int32)
|
||||
case updateChannelMessageViews(channelId: Int64, id: Int32, views: Int32)
|
||||
case updateChannelParticipant(flags: Int32, channelId: Int64, date: Int32, actorId: Int64, userId: Int64, prevParticipant: Api.ChannelParticipant?, newParticipant: Api.ChannelParticipant?, invite: Api.ExportedChatInvite?, qts: Int32)
|
||||
case updateChannelPinnedTopic(flags: Int32, channelId: Int64, topicId: Int32?)
|
||||
case updateChannelPinnedTopic(flags: Int32, channelId: Int64, topicId: Int32)
|
||||
case updateChannelPinnedTopics(flags: Int32, channelId: Int64, order: [Int32]?)
|
||||
case updateChannelReadMessagesContents(flags: Int32, channelId: Int64, topMsgId: Int32?, messages: [Int32])
|
||||
case updateChannelTooLong(flags: Int32, channelId: Int64, pts: Int32?)
|
||||
case updateChannelUserTyping(flags: Int32, channelId: Int64, topMsgId: Int32?, fromId: Api.Peer, action: Api.SendMessageAction)
|
||||
@ -927,11 +928,23 @@ public extension Api {
|
||||
break
|
||||
case .updateChannelPinnedTopic(let flags, let channelId, let topicId):
|
||||
if boxed {
|
||||
buffer.appendInt32(-158027602)
|
||||
buffer.appendInt32(422509539)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(channelId, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {serializeInt32(topicId!, buffer: buffer, boxed: false)}
|
||||
serializeInt32(topicId, buffer: buffer, boxed: false)
|
||||
break
|
||||
case .updateChannelPinnedTopics(let flags, let channelId, let order):
|
||||
if boxed {
|
||||
buffer.appendInt32(-31881726)
|
||||
}
|
||||
serializeInt32(flags, buffer: buffer, boxed: false)
|
||||
serializeInt64(channelId, buffer: buffer, boxed: false)
|
||||
if Int(flags) & Int(1 << 0) != 0 {buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(order!.count))
|
||||
for item in order! {
|
||||
serializeInt32(item, buffer: buffer, boxed: false)
|
||||
}}
|
||||
break
|
||||
case .updateChannelReadMessagesContents(let flags, let channelId, let topMsgId, let messages):
|
||||
if boxed {
|
||||
@ -1741,6 +1754,8 @@ public extension Api {
|
||||
return ("updateChannelParticipant", [("flags", String(describing: flags)), ("channelId", String(describing: channelId)), ("date", String(describing: date)), ("actorId", String(describing: actorId)), ("userId", String(describing: userId)), ("prevParticipant", String(describing: prevParticipant)), ("newParticipant", String(describing: newParticipant)), ("invite", String(describing: invite)), ("qts", String(describing: qts))])
|
||||
case .updateChannelPinnedTopic(let flags, let channelId, let topicId):
|
||||
return ("updateChannelPinnedTopic", [("flags", String(describing: flags)), ("channelId", String(describing: channelId)), ("topicId", String(describing: topicId))])
|
||||
case .updateChannelPinnedTopics(let flags, let channelId, let order):
|
||||
return ("updateChannelPinnedTopics", [("flags", String(describing: flags)), ("channelId", String(describing: channelId)), ("order", String(describing: order))])
|
||||
case .updateChannelReadMessagesContents(let flags, let channelId, let topMsgId, let messages):
|
||||
return ("updateChannelReadMessagesContents", [("flags", String(describing: flags)), ("channelId", String(describing: channelId)), ("topMsgId", String(describing: topMsgId)), ("messages", String(describing: messages))])
|
||||
case .updateChannelTooLong(let flags, let channelId, let pts):
|
||||
@ -2307,12 +2322,31 @@ public extension Api {
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: Int32?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {_3 = reader.readInt32() }
|
||||
_3 = reader.readInt32()
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.Update.updateChannelPinnedTopic(flags: _1!, channelId: _2!, topicId: _3!)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
}
|
||||
}
|
||||
public static func parse_updateChannelPinnedTopics(_ reader: BufferReader) -> Update? {
|
||||
var _1: Int32?
|
||||
_1 = reader.readInt32()
|
||||
var _2: Int64?
|
||||
_2 = reader.readInt64()
|
||||
var _3: [Int32]?
|
||||
if Int(_1!) & Int(1 << 0) != 0 {if let _ = reader.readInt32() {
|
||||
_3 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
|
||||
} }
|
||||
let _c1 = _1 != nil
|
||||
let _c2 = _2 != nil
|
||||
let _c3 = (Int(_1!) & Int(1 << 0) == 0) || _3 != nil
|
||||
if _c1 && _c2 && _c3 {
|
||||
return Api.Update.updateChannelPinnedTopic(flags: _1!, channelId: _2!, topicId: _3)
|
||||
return Api.Update.updateChannelPinnedTopics(flags: _1!, channelId: _2!, order: _3)
|
||||
}
|
||||
else {
|
||||
return nil
|
||||
|
@ -2443,6 +2443,26 @@ public extension Api.functions.channels {
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.channels {
|
||||
static func reorderPinnedForumTopics(channel: Api.InputChannel, order: [Int32]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Updates>) {
|
||||
let buffer = Buffer()
|
||||
buffer.appendInt32(-529811367)
|
||||
channel.serialize(buffer, true)
|
||||
buffer.appendInt32(481674261)
|
||||
buffer.appendInt32(Int32(order.count))
|
||||
for item in order {
|
||||
serializeInt32(item, buffer: buffer, boxed: false)
|
||||
}
|
||||
return (FunctionDescription(name: "channels.reorderPinnedForumTopics", parameters: [("channel", String(describing: channel)), ("order", String(describing: order))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Updates? in
|
||||
let reader = BufferReader(buffer)
|
||||
var result: Api.Updates?
|
||||
if let signature = reader.readInt32() {
|
||||
result = Api.parse(reader, signature: signature) as? Api.Updates
|
||||
}
|
||||
return result
|
||||
})
|
||||
}
|
||||
}
|
||||
public extension Api.functions.channels {
|
||||
static func reorderUsernames(channel: Api.InputChannel, order: [String]) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
|
||||
let buffer = Buffer()
|
||||
|
@ -93,7 +93,8 @@ enum AccountStateMutationOperation {
|
||||
case ReadSecretOutbox(peerId: PeerId, maxTimestamp: Int32, actionTimestamp: Int32)
|
||||
case AddPeerInputActivity(chatPeerId: PeerActivitySpace, peerId: PeerId?, activity: PeerInputActivity?)
|
||||
case UpdatePinnedItemIds(PeerGroupId, AccountStateUpdatePinnedItemIdsOperation)
|
||||
case UpdatePinnedTopic(peerId: PeerId, threadId: Int64?)
|
||||
case UpdatePinnedTopic(peerId: PeerId, threadId: Int64, isPinned: Bool)
|
||||
case UpdatePinnedTopicOrder(peerId: PeerId, threadIds: [Int64])
|
||||
case ReadMessageContents((PeerId?, [Int32]))
|
||||
case UpdateMessageImpressionCount(MessageId, Int32)
|
||||
case UpdateMessageForwardsCount(MessageId, Int32)
|
||||
@ -475,8 +476,12 @@ struct AccountMutableState {
|
||||
self.addOperation(.UpdatePinnedItemIds(groupId, operation))
|
||||
}
|
||||
|
||||
mutating func addUpdatePinnedTopic(peerId: PeerId, threadId: Int64?) {
|
||||
self.addOperation(.UpdatePinnedTopic(peerId: peerId, threadId: threadId))
|
||||
mutating func addUpdatePinnedTopic(peerId: PeerId, threadId: Int64, isPinned: Bool) {
|
||||
self.addOperation(.UpdatePinnedTopic(peerId: peerId, threadId: threadId, isPinned: isPinned))
|
||||
}
|
||||
|
||||
mutating func addUpdatePinnedTopicOrder(peerId: PeerId, threadIds: [Int64]) {
|
||||
self.addOperation(.UpdatePinnedTopicOrder(peerId: peerId, threadIds: threadIds))
|
||||
}
|
||||
|
||||
mutating func addReadMessagesContents(_ peerIdsAndMessageIds: (PeerId?, [Int32])) {
|
||||
@ -545,7 +550,7 @@ struct AccountMutableState {
|
||||
|
||||
mutating func addOperation(_ operation: AccountStateMutationOperation) {
|
||||
switch operation {
|
||||
case .DeleteMessages, .DeleteMessagesWithGlobalIds, .EditMessage, .UpdateMessagePoll, .UpdateMessageReactions, .UpdateMedia, .ReadOutbox, .ReadGroupFeedInbox, .MergePeerPresences, .UpdateSecretChat, .AddSecretMessages, .ReadSecretOutbox, .AddPeerInputActivity, .UpdateCachedPeerData, .UpdatePinnedItemIds, .UpdatePinnedTopic, .ReadMessageContents, .UpdateMessageImpressionCount, .UpdateMessageForwardsCount, .UpdateInstalledStickerPacks, .UpdateRecentGifs, .UpdateChatInputState, .UpdateCall, .AddCallSignalingData, .UpdateLangPack, .UpdateMinAvailableMessage, .UpdatePeerChatUnreadMark, .UpdateIsContact, .UpdatePeerChatInclusion, .UpdatePeersNearby, .UpdateTheme, .SyncChatListFilters, .UpdateChatListFilterOrder, .UpdateChatListFilter, .UpdateReadThread, .UpdateGroupCallParticipants, .UpdateGroupCall, .UpdateMessagesPinned, .UpdateAutoremoveTimeout, .UpdateAttachMenuBots, .UpdateAudioTranscription, .UpdateConfig, .UpdateExtendedMedia, .ResetForumTopic:
|
||||
case .DeleteMessages, .DeleteMessagesWithGlobalIds, .EditMessage, .UpdateMessagePoll, .UpdateMessageReactions, .UpdateMedia, .ReadOutbox, .ReadGroupFeedInbox, .MergePeerPresences, .UpdateSecretChat, .AddSecretMessages, .ReadSecretOutbox, .AddPeerInputActivity, .UpdateCachedPeerData, .UpdatePinnedItemIds, .UpdatePinnedTopic, .UpdatePinnedTopicOrder, .ReadMessageContents, .UpdateMessageImpressionCount, .UpdateMessageForwardsCount, .UpdateInstalledStickerPacks, .UpdateRecentGifs, .UpdateChatInputState, .UpdateCall, .AddCallSignalingData, .UpdateLangPack, .UpdateMinAvailableMessage, .UpdatePeerChatUnreadMark, .UpdateIsContact, .UpdatePeerChatInclusion, .UpdatePeersNearby, .UpdateTheme, .SyncChatListFilters, .UpdateChatListFilterOrder, .UpdateChatListFilter, .UpdateReadThread, .UpdateGroupCallParticipants, .UpdateGroupCall, .UpdateMessagesPinned, .UpdateAutoremoveTimeout, .UpdateAttachMenuBots, .UpdateAudioTranscription, .UpdateConfig, .UpdateExtendedMedia, .ResetForumTopic:
|
||||
break
|
||||
case let .AddMessages(messages, location):
|
||||
for message in messages {
|
||||
|
@ -367,21 +367,16 @@ func _internal_setForumChannelTopicClosed(account: Account, id: EnginePeer.Id, t
|
||||
|
||||
public enum SetForumChannelTopicPinnedError {
|
||||
case generic
|
||||
case limitReached(Int)
|
||||
}
|
||||
|
||||
func _internal_setForumChannelTopicPinned(account: Account, id: EnginePeer.Id, threadId: Int64, isPinned: Bool) -> Signal<Never, SetForumChannelTopicPinnedError> {
|
||||
func _internal_setForumChannelPinnedTopics(account: Account, id: EnginePeer.Id, threadIds: [Int64]) -> Signal<Never, SetForumChannelTopicPinnedError> {
|
||||
return account.postbox.transaction { transaction -> Api.InputChannel? in
|
||||
guard let inputChannel = transaction.getPeer(id).flatMap(apiInputChannel) else {
|
||||
return nil
|
||||
}
|
||||
|
||||
if isPinned {
|
||||
transaction.setPeerPinnedThreads(peerId: id, threadIds: [threadId])
|
||||
} else {
|
||||
if transaction.getPeerPinnedThreads(peerId: id).contains(threadId) {
|
||||
transaction.setPeerPinnedThreads(peerId: id, threadIds: [])
|
||||
}
|
||||
}
|
||||
transaction.setPeerPinnedThreads(peerId: id, threadIds: threadIds)
|
||||
|
||||
return inputChannel
|
||||
}
|
||||
@ -390,13 +385,10 @@ func _internal_setForumChannelTopicPinned(account: Account, id: EnginePeer.Id, t
|
||||
guard let inputChannel = inputChannel else {
|
||||
return .fail(.generic)
|
||||
}
|
||||
var flags: Int32 = 0
|
||||
flags |= (1 << 2)
|
||||
|
||||
return account.network.request(Api.functions.channels.updatePinnedForumTopic(
|
||||
return account.network.request(Api.functions.channels.reorderPinnedForumTopics(
|
||||
channel: inputChannel,
|
||||
topicId: Int32(clamping: threadId),
|
||||
pinned: isPinned ? .boolTrue : .boolFalse
|
||||
order: threadIds.map(Int32.init(clamping:))
|
||||
))
|
||||
|> mapError { _ -> SetForumChannelTopicPinnedError in
|
||||
return .generic
|
||||
|
@ -114,6 +114,11 @@ private func peerIdsRequiringLocalChatStateFromUpdates(_ updates: [Api.Update])
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
peerIds.insert(peerId)
|
||||
case let .updateChannelPinnedTopics(_, channelId, order):
|
||||
if order == nil {
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
peerIds.insert(peerId)
|
||||
}
|
||||
case let .updateFolderPeers(folderPeers, _, _):
|
||||
for peer in folderPeers {
|
||||
switch peer {
|
||||
@ -337,11 +342,16 @@ private func peerIdsRequiringLocalChatStateFromDifference(_ difference: Api.upda
|
||||
peerIds.insert(messageId.peerId)
|
||||
}
|
||||
switch update {
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
peerIds.insert(peerId)
|
||||
case let .updateChannelPinnedTopics(_, channelId, order):
|
||||
if order == nil {
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
peerIds.insert(peerId)
|
||||
default:
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
case .differenceEmpty:
|
||||
@ -359,11 +369,16 @@ private func peerIdsRequiringLocalChatStateFromDifference(_ difference: Api.upda
|
||||
peerIds.insert(messageId.peerId)
|
||||
}
|
||||
switch update {
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
case let .updateChannelTooLong(_, channelId, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
peerIds.insert(peerId)
|
||||
case let .updateChannelPinnedTopics(_, channelId, order):
|
||||
if order == nil {
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
peerIds.insert(peerId)
|
||||
default:
|
||||
break
|
||||
}
|
||||
default:
|
||||
break
|
||||
}
|
||||
}
|
||||
case .differenceTooLong:
|
||||
@ -725,6 +740,20 @@ private func sortedUpdates(_ updates: [Api.Update]) -> [Api.Update] {
|
||||
} else {
|
||||
updatesByChannel[peerId]!.append(update)
|
||||
}
|
||||
case let .updateChannelPinnedTopic(_, channelId, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
if updatesByChannel[peerId] == nil {
|
||||
updatesByChannel[peerId] = [update]
|
||||
} else {
|
||||
updatesByChannel[peerId]!.append(update)
|
||||
}
|
||||
case let .updateChannelPinnedTopics(_, channelId, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
if updatesByChannel[peerId] == nil {
|
||||
updatesByChannel[peerId] = [update]
|
||||
} else {
|
||||
updatesByChannel[peerId]!.append(update)
|
||||
}
|
||||
case let .updateDeleteChannelMessages(channelId, _, _, _):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
if updatesByChannel[peerId] == nil {
|
||||
@ -860,6 +889,15 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
|
||||
channelsToPoll.insert(peerId)
|
||||
}
|
||||
}
|
||||
case let .updateChannelPinnedTopics(_, channelId, order):
|
||||
if let order = order {
|
||||
updatedState.addUpdatePinnedTopicOrder(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadIds: order.map(Int64.init))
|
||||
} else {
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
if !channelsToPoll.contains(peerId) {
|
||||
channelsToPoll.insert(peerId)
|
||||
}
|
||||
}
|
||||
case let .updateDeleteChannelMessages(channelId, messages, pts: pts, ptsCount):
|
||||
let peerId = PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId))
|
||||
if let previousState = updatedState.channelStates[peerId] {
|
||||
@ -1375,8 +1413,9 @@ private func finalStateWithUpdatesAndServerTime(accountPeerId: PeerId, postbox:
|
||||
} else {
|
||||
updatedState.addUpdatePinnedItemIds(groupId: groupId, operation: .sync)
|
||||
}
|
||||
case let .updateChannelPinnedTopic(_, channelId, topicId):
|
||||
updatedState.addUpdatePinnedTopic(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: topicId.flatMap(Int64.init))
|
||||
case let .updateChannelPinnedTopic(flags, channelId, topicId):
|
||||
let isPinned = (flags & (1 << 0)) != 0
|
||||
updatedState.addUpdatePinnedTopic(peerId: PeerId(namespace: Namespaces.Peer.CloudChannel, id: PeerId.Id._internalFromInt64Value(channelId)), threadId: Int64(topicId), isPinned: isPinned)
|
||||
case let .updateReadMessagesContents(messages, _, _):
|
||||
updatedState.addReadMessagesContents((nil, messages))
|
||||
case let .updateChannelReadMessagesContents(_, channelId, topMsgId, messages):
|
||||
@ -2847,7 +2886,7 @@ private func optimizedOperations(_ operations: [AccountStateMutationOperation])
|
||||
var currentAddScheduledMessages: OptimizeAddMessagesState?
|
||||
for operation in operations {
|
||||
switch operation {
|
||||
case .DeleteMessages, .DeleteMessagesWithGlobalIds, .EditMessage, .UpdateMessagePoll, .UpdateMessageReactions, .UpdateMedia, .MergeApiChats, .MergeApiUsers, .MergePeerPresences, .UpdatePeer, .ReadInbox, .ReadOutbox, .ReadGroupFeedInbox, .ResetReadState, .ResetIncomingReadState, .UpdatePeerChatUnreadMark, .ResetMessageTagSummary, .UpdateNotificationSettings, .UpdateGlobalNotificationSettings, .UpdateSecretChat, .AddSecretMessages, .ReadSecretOutbox, .AddPeerInputActivity, .UpdateCachedPeerData, .UpdatePinnedItemIds, .UpdatePinnedTopic, .ReadMessageContents, .UpdateMessageImpressionCount, .UpdateMessageForwardsCount, .UpdateInstalledStickerPacks, .UpdateRecentGifs, .UpdateChatInputState, .UpdateCall, .AddCallSignalingData, .UpdateLangPack, .UpdateMinAvailableMessage, .UpdateIsContact, .UpdatePeerChatInclusion, .UpdatePeersNearby, .UpdateTheme, .SyncChatListFilters, .UpdateChatListFilter, .UpdateChatListFilterOrder, .UpdateReadThread, .UpdateMessagesPinned, .UpdateGroupCallParticipants, .UpdateGroupCall, .UpdateAutoremoveTimeout, .UpdateAttachMenuBots, .UpdateAudioTranscription, .UpdateConfig, .UpdateExtendedMedia, .ResetForumTopic:
|
||||
case .DeleteMessages, .DeleteMessagesWithGlobalIds, .EditMessage, .UpdateMessagePoll, .UpdateMessageReactions, .UpdateMedia, .MergeApiChats, .MergeApiUsers, .MergePeerPresences, .UpdatePeer, .ReadInbox, .ReadOutbox, .ReadGroupFeedInbox, .ResetReadState, .ResetIncomingReadState, .UpdatePeerChatUnreadMark, .ResetMessageTagSummary, .UpdateNotificationSettings, .UpdateGlobalNotificationSettings, .UpdateSecretChat, .AddSecretMessages, .ReadSecretOutbox, .AddPeerInputActivity, .UpdateCachedPeerData, .UpdatePinnedItemIds, .UpdatePinnedTopic, .UpdatePinnedTopicOrder, .ReadMessageContents, .UpdateMessageImpressionCount, .UpdateMessageForwardsCount, .UpdateInstalledStickerPacks, .UpdateRecentGifs, .UpdateChatInputState, .UpdateCall, .AddCallSignalingData, .UpdateLangPack, .UpdateMinAvailableMessage, .UpdateIsContact, .UpdatePeerChatInclusion, .UpdatePeersNearby, .UpdateTheme, .SyncChatListFilters, .UpdateChatListFilter, .UpdateChatListFilterOrder, .UpdateReadThread, .UpdateMessagesPinned, .UpdateGroupCallParticipants, .UpdateGroupCall, .UpdateAutoremoveTimeout, .UpdateAttachMenuBots, .UpdateAudioTranscription, .UpdateConfig, .UpdateExtendedMedia, .ResetForumTopic:
|
||||
if let currentAddMessages = currentAddMessages, !currentAddMessages.messages.isEmpty {
|
||||
result.append(.AddMessages(currentAddMessages.messages, currentAddMessages.location))
|
||||
}
|
||||
@ -3757,12 +3796,18 @@ func replayFinalState(
|
||||
case .sync:
|
||||
addSynchronizePinnedChatsOperation(transaction: transaction, groupId: groupId)
|
||||
}
|
||||
case let .UpdatePinnedTopic(peerId, threadId):
|
||||
if let threadId = threadId {
|
||||
transaction.setPeerPinnedThreads(peerId: peerId, threadIds: [threadId])
|
||||
case let .UpdatePinnedTopic(peerId, threadId, isPinned):
|
||||
var currentThreadIds = transaction.getPeerPinnedThreads(peerId: peerId)
|
||||
if isPinned {
|
||||
if !currentThreadIds.contains(threadId) {
|
||||
currentThreadIds.insert(threadId, at: 0)
|
||||
}
|
||||
} else {
|
||||
transaction.setPeerPinnedThreads(peerId: peerId, threadIds: [])
|
||||
currentThreadIds.removeAll(where: { $0 == threadId })
|
||||
}
|
||||
transaction.setPeerPinnedThreads(peerId: peerId, threadIds: currentThreadIds)
|
||||
case let .UpdatePinnedTopicOrder(peerId, threadIds):
|
||||
transaction.setPeerPinnedThreads(peerId: peerId, threadIds: threadIds)
|
||||
case let .ReadMessageContents(peerIdAndMessageIds):
|
||||
let (peerId, messageIds) = peerIdAndMessageIds
|
||||
|
||||
|
@ -210,7 +210,7 @@ public class BoxedMessage: NSObject {
|
||||
|
||||
public class Serialization: NSObject, MTSerialization {
|
||||
public func currentLayer() -> UInt {
|
||||
return 148
|
||||
return 149
|
||||
}
|
||||
|
||||
public func parseMessage(_ data: Data!) -> Any! {
|
||||
|
@ -858,8 +858,28 @@ public extension TelegramEngine {
|
||||
|> ignoreValues
|
||||
}
|
||||
|
||||
public func setForumChannelTopicPinned(id: EnginePeer.Id, threadId: Int64, isPinned: Bool) -> Signal<Never, SetForumChannelTopicPinnedError> {
|
||||
return _internal_setForumChannelTopicPinned(account: self.account, id: id, threadId: threadId, isPinned: isPinned)
|
||||
public func toggleForumChannelTopicPinned(id: EnginePeer.Id, threadId: Int64) -> Signal<Never, SetForumChannelTopicPinnedError> {
|
||||
return self.account.postbox.transaction { transaction -> [Int64] in
|
||||
return transaction.getPeerPinnedThreads(peerId: id)
|
||||
}
|
||||
|> castError(SetForumChannelTopicPinnedError.self)
|
||||
|> mapToSignal { threadIds -> Signal<Never, SetForumChannelTopicPinnedError> in
|
||||
var threadIds = threadIds
|
||||
if threadIds.contains(threadId) {
|
||||
threadIds.removeAll(where: { $0 == threadId })
|
||||
} else {
|
||||
if threadIds.count + 1 > 5 {
|
||||
return .fail(.limitReached(5))
|
||||
}
|
||||
threadIds.insert(threadId, at: 0)
|
||||
}
|
||||
|
||||
return _internal_setForumChannelPinnedTopics(account: self.account, id: id, threadIds: threadIds)
|
||||
}
|
||||
}
|
||||
|
||||
public func setForumChannelPinnedTopics(id: EnginePeer.Id, threadIds: [Int64]) -> Signal<Never, SetForumChannelTopicPinnedError> {
|
||||
return _internal_setForumChannelPinnedTopics(account: self.account, id: id, threadIds: threadIds)
|
||||
}
|
||||
|
||||
public func forumChannelTopicNotificationExceptions(id: EnginePeer.Id) -> Signal<[EngineMessageHistoryThread.NotificationException], NoError> {
|
||||
|
@ -181,17 +181,6 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
if chatPresentationInterfaceState.interfaceState.replyMessageId == nil {
|
||||
if let currentPanel = (currentPanel as? ChatRestrictedInputPanelNode) ?? (currentSecondaryPanel as? ChatRestrictedInputPanelNode) {
|
||||
return (currentPanel, nil)
|
||||
} else {
|
||||
let panel = ChatRestrictedInputPanelNode()
|
||||
panel.context = context
|
||||
panel.interfaceInteraction = interfaceInteraction
|
||||
return (panel, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -248,6 +237,22 @@ func inputPanelForChatPresentationIntefaceState(_ chatPresentationInterfaceState
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if channel.flags.contains(.isForum) {
|
||||
if let _ = chatPresentationInterfaceState.threadData {
|
||||
} else {
|
||||
if chatPresentationInterfaceState.interfaceState.replyMessageId == nil {
|
||||
if let currentPanel = (currentPanel as? ChatRestrictedInputPanelNode) ?? (currentSecondaryPanel as? ChatRestrictedInputPanelNode) {
|
||||
return (currentPanel, nil)
|
||||
} else {
|
||||
let panel = ChatRestrictedInputPanelNode()
|
||||
panel.context = context
|
||||
panel.interfaceInteraction = interfaceInteraction
|
||||
return (panel, nil)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else if let group = peer as? TelegramGroup {
|
||||
switch group.membership {
|
||||
case .Removed, .Left:
|
||||
|
@ -621,6 +621,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
||||
if let components = URLComponents(string: "/?" + query) {
|
||||
var channelId: Int64?
|
||||
var postId: Int32?
|
||||
var threadId: Int64?
|
||||
if let queryItems = components.queryItems {
|
||||
for queryItem in queryItems {
|
||||
if let value = queryItem.value {
|
||||
@ -628,12 +629,22 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
||||
channelId = Int64(value)
|
||||
} else if queryItem.name == "post" {
|
||||
postId = Int32(value)
|
||||
} else if queryItem.name == "thread" {
|
||||
threadId = Int64(value)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if let channelId = channelId, let postId = postId {
|
||||
convertedUrl = "https://t.me/c/\(channelId)/\(postId)"
|
||||
if let channelId = channelId {
|
||||
if let postId = postId {
|
||||
if let threadId = threadId {
|
||||
convertedUrl = "https://t.me/c/\(channelId)/\(threadId)/\(postId)"
|
||||
} else {
|
||||
convertedUrl = "https://t.me/c/\(channelId)/\(postId)"
|
||||
}
|
||||
} else if let threadId = threadId {
|
||||
convertedUrl = "https://t.me/c/\(channelId)/\(threadId)"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -652,6 +663,7 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
||||
var attach: String?
|
||||
var startAttach: String?
|
||||
var choose: String?
|
||||
var threadId: Int64?
|
||||
if let queryItems = components.queryItems {
|
||||
for queryItem in queryItems {
|
||||
if let value = queryItem.value {
|
||||
@ -677,6 +689,8 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
||||
startAttach = value
|
||||
} else if queryItem.name == "choose" {
|
||||
choose = value
|
||||
} else if queryItem.name == "thread" {
|
||||
threadId = Int64(value)
|
||||
}
|
||||
} else if ["voicechat", "videochat", "livestream"].contains(queryItem.name) {
|
||||
voiceChat = ""
|
||||
@ -694,8 +708,15 @@ func openExternalUrlImpl(context: AccountContext, urlContext: OpenURLContext, ur
|
||||
convertedUrl = "https://t.me/+\(phone)"
|
||||
} else if let domain = domain {
|
||||
var result = "https://t.me/\(domain)"
|
||||
if let post = post, let postValue = Int(post) {
|
||||
result += "/\(postValue)"
|
||||
if let threadId = threadId {
|
||||
result += "/\(threadId)"
|
||||
if let post = post, let postValue = Int(post) {
|
||||
result += "/\(postValue)"
|
||||
}
|
||||
} else {
|
||||
if let post = post, let postValue = Int(post) {
|
||||
result += "/\(postValue)"
|
||||
}
|
||||
}
|
||||
if let start = start {
|
||||
result += "?start=\(start)"
|
||||
|
Loading…
x
Reference in New Issue
Block a user