Folder colors

This commit is contained in:
Isaac 2024-02-28 23:35:14 +04:00
parent da308668e9
commit c48cadbd78
17 changed files with 704 additions and 538 deletions

View File

@ -80,6 +80,7 @@ public class PeerNameColors: Equatable {
colors: defaultSingleColors, colors: defaultSingleColors,
darkColors: [:], darkColors: [:],
displayOrder: [5, 3, 1, 0, 2, 4, 6], displayOrder: [5, 3, 1, 0, 2, 4, 6],
chatFolderTagDisplayOrder: [5, 3, 1, 0, 2, 4, 6],
profileColors: [:], profileColors: [:],
profileDarkColors: [:], profileDarkColors: [:],
profilePaletteColors: [:], profilePaletteColors: [:],
@ -97,6 +98,8 @@ public class PeerNameColors: Equatable {
public let darkColors: [Int32: Colors] public let darkColors: [Int32: Colors]
public let displayOrder: [Int32] public let displayOrder: [Int32]
public let chatFolderTagDisplayOrder: [Int32]
public let profileColors: [Int32: Colors] public let profileColors: [Int32: Colors]
public let profileDarkColors: [Int32: Colors] public let profileDarkColors: [Int32: Colors]
public let profilePaletteColors: [Int32: Colors] public let profilePaletteColors: [Int32: Colors]
@ -119,6 +122,16 @@ public class PeerNameColors: Equatable {
} }
} }
public func getChatFolderTag(_ color: PeerNameColor, dark: Bool = false) -> Colors {
if dark, let colors = self.darkColors[color.rawValue] {
return colors
} else if let colors = self.colors[color.rawValue] {
return colors
} else {
return PeerNameColors.defaultSingleColors[5]!
}
}
public func getProfile(_ color: PeerNameColor, dark: Bool = false, subject: Subject = .background) -> Colors { public func getProfile(_ color: PeerNameColor, dark: Bool = false, subject: Subject = .background) -> Colors {
switch subject { switch subject {
case .background: case .background:
@ -152,6 +165,7 @@ public class PeerNameColors: Equatable {
colors: [Int32: Colors], colors: [Int32: Colors],
darkColors: [Int32: Colors], darkColors: [Int32: Colors],
displayOrder: [Int32], displayOrder: [Int32],
chatFolderTagDisplayOrder: [Int32],
profileColors: [Int32: Colors], profileColors: [Int32: Colors],
profileDarkColors: [Int32: Colors], profileDarkColors: [Int32: Colors],
profilePaletteColors: [Int32: Colors], profilePaletteColors: [Int32: Colors],
@ -166,6 +180,7 @@ public class PeerNameColors: Equatable {
self.colors = colors self.colors = colors
self.darkColors = darkColors self.darkColors = darkColors
self.displayOrder = displayOrder self.displayOrder = displayOrder
self.chatFolderTagDisplayOrder = chatFolderTagDisplayOrder
self.profileColors = profileColors self.profileColors = profileColors
self.profileDarkColors = profileDarkColors self.profileDarkColors = profileDarkColors
self.profilePaletteColors = profilePaletteColors self.profilePaletteColors = profilePaletteColors
@ -257,6 +272,7 @@ public class PeerNameColors: Equatable {
colors: colors, colors: colors,
darkColors: darkColors, darkColors: darkColors,
displayOrder: displayOrder, displayOrder: displayOrder,
chatFolderTagDisplayOrder: PeerNameColors.defaultValue.chatFolderTagDisplayOrder,
profileColors: profileColors, profileColors: profileColors,
profileDarkColors: profileDarkColors, profileDarkColors: profileDarkColors,
profilePaletteColors: profilePaletteColors, profilePaletteColors: profilePaletteColors,
@ -280,6 +296,9 @@ public class PeerNameColors: Equatable {
if lhs.displayOrder != rhs.displayOrder { if lhs.displayOrder != rhs.displayOrder {
return false return false
} }
if lhs.chatFolderTagDisplayOrder != rhs.chatFolderTagDisplayOrder {
return false
}
if lhs.profileColors != rhs.profileColors { if lhs.profileColors != rhs.profileColors {
return false return false
} }

View File

@ -480,7 +480,7 @@ private enum ChatListFilterPresetEntry: ItemListNodeEntry {
return PeerNameColorItem( return PeerNameColorItem(
theme: presentationData.theme, theme: presentationData.theme,
colors: colors, colors: colors,
isProfile: true, mode: .folderTag,
displayEmptyColor: true, displayEmptyColor: true,
currentColor: isPremium ? color : nil, currentColor: isPremium ? color : nil,
isLocked: !isPremium, isLocked: !isPremium,
@ -643,7 +643,7 @@ private func chatListFilterPresetControllerEntries(context: AccountContext, pres
} }
var resolvedColor: PeerNameColors.Colors? var resolvedColor: PeerNameColors.Colors?
if let tagColor { if let tagColor {
resolvedColor = context.peerNameColors.getProfile(tagColor, dark: presentationData.theme.overallDarkAppearance, subject: .palette) resolvedColor = context.peerNameColors.getChatFolderTag(tagColor, dark: presentationData.theme.overallDarkAppearance)
} }
entries.append(.tagColorHeader(name: state.name, color: resolvedColor, isPremium: isPremium)) entries.append(.tagColorHeader(name: state.name, color: resolvedColor, isPremium: isPremium))

View File

@ -190,7 +190,7 @@ private enum ChatListFilterPresetListEntry: ItemListNodeEntry {
if displayTags, case let .filter(_, _, _, data) = preset { if displayTags, case let .filter(_, _, _, data) = preset {
let tagColor = data.color let tagColor = data.color
if let tagColor { if let tagColor {
resolvedColor = arguments.context.peerNameColors.getProfile(tagColor, dark: presentationData.theme.overallDarkAppearance, subject: .palette).main resolvedColor = arguments.context.peerNameColors.getChatFolderTag(tagColor, dark: presentationData.theme.overallDarkAppearance).main
} }
} }

View File

@ -328,7 +328,7 @@ private final class ChatListItemTagListComponent: Component {
itemId = tag.id itemId = tag.id
let tagColor = PeerNameColor(rawValue: tag.colorId) let tagColor = PeerNameColor(rawValue: tag.colorId)
let resolvedColor = component.context.peerNameColors.getProfile(tagColor, dark: component.theme.overallDarkAppearance, subject: .palette) let resolvedColor = component.context.peerNameColors.getChatFolderTag(tagColor, dark: component.theme.overallDarkAppearance)
itemTitle = tag.title.uppercased() itemTitle = tag.title.uppercased()
itemBackgroundColor = resolvedColor.main.withMultipliedAlpha(0.1) itemBackgroundColor = resolvedColor.main.withMultipliedAlpha(0.1)

View File

@ -350,7 +350,7 @@ public struct ChatListNodeState: Equatable {
} }
} }
private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatListNodeInteraction, location: ChatListControllerLocation, filterData: ChatListItemFilterData?, chatListFilters: [ChatListFilter]?, mode: ChatListNodeMode, isPeerEnabled: ((EnginePeer) -> Bool)?, entries: [ChatListNodeViewTransitionInsertEntry]) -> [ListViewInsertItem] { private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatListNodeInteraction, location: ChatListControllerLocation, isPremium: Bool, filterData: ChatListItemFilterData?, chatListFilters: [ChatListFilter]?, mode: ChatListNodeMode, isPeerEnabled: ((EnginePeer) -> Bool)?, entries: [ChatListNodeViewTransitionInsertEntry]) -> [ListViewInsertItem] {
return entries.map { entry -> ListViewInsertItem in return entries.map { entry -> ListViewInsertItem in
switch entry.entry { switch entry.entry {
case .HeaderEntry: case .HeaderEntry:
@ -433,7 +433,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
}, },
requiresPremiumForMessaging: peerEntry.requiresPremiumForMessaging, requiresPremiumForMessaging: peerEntry.requiresPremiumForMessaging,
displayAsTopicList: peerEntry.displayAsTopicList, displayAsTopicList: peerEntry.displayAsTopicList,
tags: chatListItemTags(location: location, accountPeerId: context.account.peerId, peer: peer.chatMainPeer, isUnread: combinedReadState?.isUnread ?? false, isMuted: isRemovedFromTotalUnreadCount, isContact: isContact, hasUnseenMentions: hasUnseenMentions, chatListFilters: chatListFilters) tags: chatListItemTags(location: location, accountPeerId: context.account.peerId, isPremium: isPremium, peer: peer.chatMainPeer, isUnread: combinedReadState?.isUnread ?? false, isMuted: isRemovedFromTotalUnreadCount, isContact: isContact, hasUnseenMentions: hasUnseenMentions, chatListFilters: chatListFilters)
)), )),
editing: editing, editing: editing,
hasActiveRevealControls: hasActiveRevealControls, hasActiveRevealControls: hasActiveRevealControls,
@ -751,7 +751,7 @@ private func mappedInsertEntries(context: AccountContext, nodeInteraction: ChatL
} }
} }
private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatListNodeInteraction, location: ChatListControllerLocation, filterData: ChatListItemFilterData?, chatListFilters: [ChatListFilter]?, mode: ChatListNodeMode, isPeerEnabled: ((EnginePeer) -> Bool)?, entries: [ChatListNodeViewTransitionUpdateEntry]) -> [ListViewUpdateItem] { private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatListNodeInteraction, location: ChatListControllerLocation, isPremium: Bool, filterData: ChatListItemFilterData?, chatListFilters: [ChatListFilter]?, mode: ChatListNodeMode, isPeerEnabled: ((EnginePeer) -> Bool)?, entries: [ChatListNodeViewTransitionUpdateEntry]) -> [ListViewUpdateItem] {
return entries.map { entry -> ListViewUpdateItem in return entries.map { entry -> ListViewUpdateItem in
switch entry.entry { switch entry.entry {
case let .PeerEntry(peerEntry): case let .PeerEntry(peerEntry):
@ -811,7 +811,7 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
}, },
requiresPremiumForMessaging: peerEntry.requiresPremiumForMessaging, requiresPremiumForMessaging: peerEntry.requiresPremiumForMessaging,
displayAsTopicList: peerEntry.displayAsTopicList, displayAsTopicList: peerEntry.displayAsTopicList,
tags: chatListItemTags(location: location, accountPeerId: context.account.peerId, peer: peer.chatMainPeer, isUnread: combinedReadState?.isUnread ?? false, isMuted: isRemovedFromTotalUnreadCount, isContact: isContact, hasUnseenMentions: hasUnseenMentions, chatListFilters: chatListFilters) tags: chatListItemTags(location: location, accountPeerId: context.account.peerId, isPremium: isPremium, peer: peer.chatMainPeer, isUnread: combinedReadState?.isUnread ?? false, isMuted: isRemovedFromTotalUnreadCount, isContact: isContact, hasUnseenMentions: hasUnseenMentions, chatListFilters: chatListFilters)
)), )),
editing: editing, editing: editing,
hasActiveRevealControls: hasActiveRevealControls, hasActiveRevealControls: hasActiveRevealControls,
@ -1106,8 +1106,8 @@ private func mappedUpdateEntries(context: AccountContext, nodeInteraction: ChatL
} }
} }
private func mappedChatListNodeViewListTransition(context: AccountContext, nodeInteraction: ChatListNodeInteraction, location: ChatListControllerLocation, filterData: ChatListItemFilterData?, chatListFilters: [ChatListFilter]?, mode: ChatListNodeMode, isPeerEnabled: ((EnginePeer) -> Bool)?, transition: ChatListNodeViewTransition) -> ChatListNodeListViewTransition { private func mappedChatListNodeViewListTransition(context: AccountContext, nodeInteraction: ChatListNodeInteraction, location: ChatListControllerLocation, isPremium: Bool, filterData: ChatListItemFilterData?, chatListFilters: [ChatListFilter]?, mode: ChatListNodeMode, isPeerEnabled: ((EnginePeer) -> Bool)?, transition: ChatListNodeViewTransition) -> ChatListNodeListViewTransition {
return ChatListNodeListViewTransition(chatListView: transition.chatListView, deleteItems: transition.deleteItems, insertItems: mappedInsertEntries(context: context, nodeInteraction: nodeInteraction, location: location, filterData: filterData, chatListFilters: chatListFilters, mode: mode, isPeerEnabled: isPeerEnabled, entries: transition.insertEntries), updateItems: mappedUpdateEntries(context: context, nodeInteraction: nodeInteraction, location: location, filterData: filterData, chatListFilters: chatListFilters, mode: mode, isPeerEnabled: isPeerEnabled, entries: transition.updateEntries), options: transition.options, scrollToItem: transition.scrollToItem, stationaryItemRange: transition.stationaryItemRange, adjustScrollToFirstItem: transition.adjustScrollToFirstItem, animateCrossfade: transition.animateCrossfade) return ChatListNodeListViewTransition(chatListView: transition.chatListView, deleteItems: transition.deleteItems, insertItems: mappedInsertEntries(context: context, nodeInteraction: nodeInteraction, location: location, isPremium: isPremium, filterData: filterData, chatListFilters: chatListFilters, mode: mode, isPeerEnabled: isPeerEnabled, entries: transition.insertEntries), updateItems: mappedUpdateEntries(context: context, nodeInteraction: nodeInteraction, location: location, isPremium: isPremium, filterData: filterData, chatListFilters: chatListFilters, mode: mode, isPeerEnabled: isPeerEnabled, entries: transition.updateEntries), options: transition.options, scrollToItem: transition.scrollToItem, stationaryItemRange: transition.stationaryItemRange, adjustScrollToFirstItem: transition.adjustScrollToFirstItem, animateCrossfade: transition.animateCrossfade)
} }
private final class ChatListOpaqueTransactionState { private final class ChatListOpaqueTransactionState {
@ -2114,8 +2114,17 @@ public final class ChatListNode: ListView {
} }
let previousChatListFilters = Atomic<[ChatListFilter]?>(value: nil) let previousChatListFilters = Atomic<[ChatListFilter]?>(value: nil)
let chatListNodeViewTransition = combineLatest( let previousAccountIsPremium = Atomic<Bool?>(value: nil)
queue: viewProcessingQueue,
let accountIsPremium = context.engine.data.subscribe(
TelegramEngine.EngineData.Item.Peer.Peer(id: context.account.peerId)
)
|> map { peer -> Bool in
return peer?.isPremium ?? false
}
|> distinctUntilChanged
let chatListNodeViewTransition = combineLatest(queue: viewProcessingQueue,
hideArchivedFolderByDefault, hideArchivedFolderByDefault,
displayArchiveIntro, displayArchiveIntro,
storageInfo, storageInfo,
@ -2124,9 +2133,10 @@ public final class ChatListNode: ListView {
chatListViewUpdate, chatListViewUpdate,
self.statePromise.get(), self.statePromise.get(),
contacts, contacts,
chatListFilters chatListFilters,
accountIsPremium
) )
|> mapToQueue { (hideArchivedFolderByDefault, displayArchiveIntro, storageInfo, suggestedChatListNotice, savedMessagesPeer, updateAndFilter, state, contacts, chatListFilters) -> Signal<ChatListNodeListViewTransition, NoError> in |> mapToQueue { (hideArchivedFolderByDefault, displayArchiveIntro, storageInfo, suggestedChatListNotice, savedMessagesPeer, updateAndFilter, state, contacts, chatListFilters, accountIsPremium) -> Signal<ChatListNodeListViewTransition, NoError> in
let (update, filter) = updateAndFilter let (update, filter) = updateAndFilter
let previousHideArchivedFolderByDefaultValue = previousHideArchivedFolderByDefault.swap(hideArchivedFolderByDefault) let previousHideArchivedFolderByDefaultValue = previousHideArchivedFolderByDefault.swap(hideArchivedFolderByDefault)
@ -2587,9 +2597,12 @@ public final class ChatListNode: ListView {
if chatListFilters != previousChatListFiltersValue { if chatListFilters != previousChatListFiltersValue {
forceAllUpdated = true forceAllUpdated = true
} }
if accountIsPremium != previousAccountIsPremium.swap(accountIsPremium) {
forceAllUpdated = true
}
return preparedChatListNodeViewTransition(from: previousView, to: processedView, reason: reason, previewing: previewing, disableAnimations: disableAnimations, account: context.account, scrollPosition: updatedScrollPosition, searchMode: searchMode, forceAllUpdated: forceAllUpdated) return preparedChatListNodeViewTransition(from: previousView, to: processedView, reason: reason, previewing: previewing, disableAnimations: disableAnimations, account: context.account, scrollPosition: updatedScrollPosition, searchMode: searchMode, forceAllUpdated: forceAllUpdated)
|> map({ mappedChatListNodeViewListTransition(context: context, nodeInteraction: nodeInteraction, location: location, filterData: filterData, chatListFilters: chatListFilters, mode: mode, isPeerEnabled: isPeerEnabled, transition: $0) }) |> map({ mappedChatListNodeViewListTransition(context: context, nodeInteraction: nodeInteraction, location: location, isPremium: accountIsPremium, filterData: filterData, chatListFilters: chatListFilters, mode: mode, isPeerEnabled: isPeerEnabled, transition: $0) })
|> runOn(prepareOnMainQueue ? Queue.mainQueue() : viewProcessingQueue) |> runOn(prepareOnMainQueue ? Queue.mainQueue() : viewProcessingQueue)
} }
@ -4206,7 +4219,10 @@ func hideChatListContacts(context: AccountContext) {
let _ = ApplicationSpecificNotice.setDisplayChatListContacts(accountManager: context.sharedContext.accountManager).startStandalone() let _ = ApplicationSpecificNotice.setDisplayChatListContacts(accountManager: context.sharedContext.accountManager).startStandalone()
} }
func chatListItemTags(location: ChatListControllerLocation, accountPeerId: EnginePeer.Id, peer: EnginePeer?, isUnread: Bool, isMuted: Bool, isContact: Bool, hasUnseenMentions: Bool, chatListFilters: [ChatListFilter]?) -> [ChatListItemContent.Tag] { func chatListItemTags(location: ChatListControllerLocation, accountPeerId: EnginePeer.Id, isPremium: Bool, peer: EnginePeer?, isUnread: Bool, isMuted: Bool, isContact: Bool, hasUnseenMentions: Bool, chatListFilters: [ChatListFilter]?) -> [ChatListItemContent.Tag] {
if !isPremium {
return []
}
if case .chatList = location { if case .chatList = location {
} else { } else {
return [] return []
@ -4222,7 +4238,7 @@ func chatListItemTags(location: ChatListControllerLocation, accountPeerId: Engin
for case let .filter(id, title, _, data) in chatListFilters { for case let .filter(id, title, _, data) in chatListFilters {
if data.color != nil { if data.color != nil {
let predicate = chatListFilterPredicate(filter: data, accountPeerId: accountPeerId) let predicate = chatListFilterPredicate(filter: data, accountPeerId: accountPeerId)
if predicate.includes(peer: peer._asPeer(), groupId: .root, isRemovedFromTotalUnreadCount: isMuted, isUnread: isUnread, isContact: isContact, messageTagSummaryResult: hasUnseenMentions) { if predicate.pinnedPeerIds.contains(peer.id) || predicate.includes(peer: peer._asPeer(), groupId: .root, isRemovedFromTotalUnreadCount: isMuted, isUnread: isUnread, isContact: isContact, messageTagSummaryResult: hasUnseenMentions) {
result.append(ChatListItemContent.Tag( result.append(ChatListItemContent.Tag(
id: id, id: id,
title: title, title: title,

View File

@ -216,8 +216,8 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[1135897376] = { return Api.DefaultHistoryTTL.parse_defaultHistoryTTL($0) } dict[1135897376] = { return Api.DefaultHistoryTTL.parse_defaultHistoryTTL($0) }
dict[-712374074] = { return Api.Dialog.parse_dialog($0) } dict[-712374074] = { return Api.Dialog.parse_dialog($0) }
dict[1908216652] = { return Api.Dialog.parse_dialogFolder($0) } dict[1908216652] = { return Api.Dialog.parse_dialogFolder($0) }
dict[1949890536] = { return Api.DialogFilter.parse_dialogFilter($0) } dict[1605718587] = { return Api.DialogFilter.parse_dialogFilter($0) }
dict[-699792216] = { return Api.DialogFilter.parse_dialogFilterChatlist($0) } dict[-1612542300] = { return Api.DialogFilter.parse_dialogFilterChatlist($0) }
dict[909284270] = { return Api.DialogFilter.parse_dialogFilterDefault($0) } dict[909284270] = { return Api.DialogFilter.parse_dialogFilterDefault($0) }
dict[2004110666] = { return Api.DialogFilterSuggested.parse_dialogFilterSuggested($0) } dict[2004110666] = { return Api.DialogFilterSuggested.parse_dialogFilterSuggested($0) }
dict[-445792507] = { return Api.DialogPeer.parse_dialogPeer($0) } dict[-445792507] = { return Api.DialogPeer.parse_dialogPeer($0) }
@ -1175,6 +1175,7 @@ fileprivate let parsers: [Int32 : (BufferReader) -> Any?] = {
dict[-1571952873] = { return Api.messages.CheckedHistoryImportPeer.parse_checkedHistoryImportPeer($0) } dict[-1571952873] = { return Api.messages.CheckedHistoryImportPeer.parse_checkedHistoryImportPeer($0) }
dict[740433629] = { return Api.messages.DhConfig.parse_dhConfig($0) } dict[740433629] = { return Api.messages.DhConfig.parse_dhConfig($0) }
dict[-1058912715] = { return Api.messages.DhConfig.parse_dhConfigNotModified($0) } dict[-1058912715] = { return Api.messages.DhConfig.parse_dhConfigNotModified($0) }
dict[718878489] = { return Api.messages.DialogFilters.parse_dialogFilters($0) }
dict[364538944] = { return Api.messages.Dialogs.parse_dialogs($0) } dict[364538944] = { return Api.messages.Dialogs.parse_dialogs($0) }
dict[-253500010] = { return Api.messages.Dialogs.parse_dialogsNotModified($0) } dict[-253500010] = { return Api.messages.Dialogs.parse_dialogsNotModified($0) }
dict[1910543603] = { return Api.messages.Dialogs.parse_dialogsSlice($0) } dict[1910543603] = { return Api.messages.Dialogs.parse_dialogsSlice($0) }
@ -2112,6 +2113,8 @@ public extension Api {
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.messages.DhConfig: case let _1 as Api.messages.DhConfig:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.messages.DialogFilters:
_1.serialize(buffer, boxed)
case let _1 as Api.messages.Dialogs: case let _1 as Api.messages.Dialogs:
_1.serialize(buffer, boxed) _1.serialize(buffer, boxed)
case let _1 as Api.messages.DiscussionMessage: case let _1 as Api.messages.DiscussionMessage:

View File

@ -1291,67 +1291,19 @@ public extension Api.messages {
} }
} }
public extension Api.messages { public extension Api.messages {
enum Dialogs: TypeConstructorDescription { enum DialogFilters: TypeConstructorDescription {
case dialogs(dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) case dialogFilters(flags: Int32, filters: [Api.DialogFilter])
case dialogsNotModified(count: Int32)
case dialogsSlice(count: Int32, dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .dialogs(let dialogs, let messages, let chats, let users): case .dialogFilters(let flags, let filters):
if boxed { if boxed {
buffer.appendInt32(364538944) buffer.appendInt32(718878489)
} }
serializeInt32(flags, buffer: buffer, boxed: false)
buffer.appendInt32(481674261) buffer.appendInt32(481674261)
buffer.appendInt32(Int32(dialogs.count)) buffer.appendInt32(Int32(filters.count))
for item in dialogs { for item in filters {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(messages.count))
for item in messages {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
case .dialogsNotModified(let count):
if boxed {
buffer.appendInt32(-253500010)
}
serializeInt32(count, buffer: buffer, boxed: false)
break
case .dialogsSlice(let count, let dialogs, let messages, let chats, let users):
if boxed {
buffer.appendInt32(1910543603)
}
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(dialogs.count))
for item in dialogs {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(messages.count))
for item in messages {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true) item.serialize(buffer, true)
} }
break break
@ -1360,80 +1312,22 @@ public extension Api.messages {
public func descriptionFields() -> (String, [(String, Any)]) { public func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .dialogs(let dialogs, let messages, let chats, let users): case .dialogFilters(let flags, let filters):
return ("dialogs", [("dialogs", dialogs as Any), ("messages", messages as Any), ("chats", chats as Any), ("users", users as Any)]) return ("dialogFilters", [("flags", flags as Any), ("filters", filters as Any)])
case .dialogsNotModified(let count):
return ("dialogsNotModified", [("count", count as Any)])
case .dialogsSlice(let count, let dialogs, let messages, let chats, let users):
return ("dialogsSlice", [("count", count as Any), ("dialogs", dialogs as Any), ("messages", messages as Any), ("chats", chats as Any), ("users", users as Any)])
} }
} }
public static func parse_dialogs(_ reader: BufferReader) -> Dialogs? { public static func parse_dialogFilters(_ reader: BufferReader) -> DialogFilters? {
var _1: [Api.Dialog]? var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.DialogFilter]?
if let _ = reader.readInt32() { if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Dialog.self) _2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.DialogFilter.self)
}
var _2: [Api.Message]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self)
}
var _3: [Api.Chat]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _4: [Api.User]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
} }
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = _3 != nil if _c1 && _c2 {
let _c4 = _4 != nil return Api.messages.DialogFilters.dialogFilters(flags: _1!, filters: _2!)
if _c1 && _c2 && _c3 && _c4 {
return Api.messages.Dialogs.dialogs(dialogs: _1!, messages: _2!, chats: _3!, users: _4!)
}
else {
return nil
}
}
public static func parse_dialogsNotModified(_ reader: BufferReader) -> Dialogs? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return Api.messages.Dialogs.dialogsNotModified(count: _1!)
}
else {
return nil
}
}
public static func parse_dialogsSlice(_ reader: BufferReader) -> Dialogs? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.Dialog]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Dialog.self)
}
var _3: [Api.Message]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self)
}
var _4: [Api.Chat]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _5: [Api.User]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.messages.Dialogs.dialogsSlice(count: _1!, dialogs: _2!, messages: _3!, chats: _4!, users: _5!)
} }
else { else {
return nil return nil

View File

@ -1,3 +1,155 @@
public extension Api.messages {
enum Dialogs: TypeConstructorDescription {
case dialogs(dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User])
case dialogsNotModified(count: Int32)
case dialogsSlice(count: Int32, dialogs: [Api.Dialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .dialogs(let dialogs, let messages, let chats, let users):
if boxed {
buffer.appendInt32(364538944)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(dialogs.count))
for item in dialogs {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(messages.count))
for item in messages {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
case .dialogsNotModified(let count):
if boxed {
buffer.appendInt32(-253500010)
}
serializeInt32(count, buffer: buffer, boxed: false)
break
case .dialogsSlice(let count, let dialogs, let messages, let chats, let users):
if boxed {
buffer.appendInt32(1910543603)
}
serializeInt32(count, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(dialogs.count))
for item in dialogs {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(messages.count))
for item in messages {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(chats.count))
for item in chats {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .dialogs(let dialogs, let messages, let chats, let users):
return ("dialogs", [("dialogs", dialogs as Any), ("messages", messages as Any), ("chats", chats as Any), ("users", users as Any)])
case .dialogsNotModified(let count):
return ("dialogsNotModified", [("count", count as Any)])
case .dialogsSlice(let count, let dialogs, let messages, let chats, let users):
return ("dialogsSlice", [("count", count as Any), ("dialogs", dialogs as Any), ("messages", messages as Any), ("chats", chats as Any), ("users", users as Any)])
}
}
public static func parse_dialogs(_ reader: BufferReader) -> Dialogs? {
var _1: [Api.Dialog]?
if let _ = reader.readInt32() {
_1 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Dialog.self)
}
var _2: [Api.Message]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self)
}
var _3: [Api.Chat]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _4: [Api.User]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.messages.Dialogs.dialogs(dialogs: _1!, messages: _2!, chats: _3!, users: _4!)
}
else {
return nil
}
}
public static func parse_dialogsNotModified(_ reader: BufferReader) -> Dialogs? {
var _1: Int32?
_1 = reader.readInt32()
let _c1 = _1 != nil
if _c1 {
return Api.messages.Dialogs.dialogsNotModified(count: _1!)
}
else {
return nil
}
}
public static func parse_dialogsSlice(_ reader: BufferReader) -> Dialogs? {
var _1: Int32?
_1 = reader.readInt32()
var _2: [Api.Dialog]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Dialog.self)
}
var _3: [Api.Message]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Message.self)
}
var _4: [Api.Chat]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Chat.self)
}
var _5: [Api.User]?
if let _ = reader.readInt32() {
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 {
return Api.messages.Dialogs.dialogsSlice(count: _1!, dialogs: _2!, messages: _3!, chats: _4!, users: _5!)
}
else {
return nil
}
}
}
}
public extension Api.messages { public extension Api.messages {
enum DiscussionMessage: TypeConstructorDescription { enum DiscussionMessage: TypeConstructorDescription {
case discussionMessage(flags: Int32, messages: [Api.Message], maxId: Int32?, readInboxMaxId: Int32?, readOutboxMaxId: Int32?, unreadCount: Int32, chats: [Api.Chat], users: [Api.User]) case discussionMessage(flags: Int32, messages: [Api.Message], maxId: Int32?, readInboxMaxId: Int32?, readOutboxMaxId: Int32?, unreadCount: Int32, chats: [Api.Chat], users: [Api.User])
@ -1430,81 +1582,3 @@ public extension Api.messages {
} }
} }
public extension Api.messages {
enum RecentStickers: TypeConstructorDescription {
case recentStickers(hash: Int64, packs: [Api.StickerPack], stickers: [Api.Document], dates: [Int32])
case recentStickersNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .recentStickers(let hash, let packs, let stickers, let dates):
if boxed {
buffer.appendInt32(-1999405994)
}
serializeInt64(hash, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(packs.count))
for item in packs {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(stickers.count))
for item in stickers {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(dates.count))
for item in dates {
serializeInt32(item, buffer: buffer, boxed: false)
}
break
case .recentStickersNotModified:
if boxed {
buffer.appendInt32(186120336)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .recentStickers(let hash, let packs, let stickers, let dates):
return ("recentStickers", [("hash", hash as Any), ("packs", packs as Any), ("stickers", stickers as Any), ("dates", dates as Any)])
case .recentStickersNotModified:
return ("recentStickersNotModified", [])
}
}
public static func parse_recentStickers(_ reader: BufferReader) -> RecentStickers? {
var _1: Int64?
_1 = reader.readInt64()
var _2: [Api.StickerPack]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerPack.self)
}
var _3: [Api.Document]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
}
var _4: [Int32]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.messages.RecentStickers.recentStickers(hash: _1!, packs: _2!, stickers: _3!, dates: _4!)
}
else {
return nil
}
}
public static func parse_recentStickersNotModified(_ reader: BufferReader) -> RecentStickers? {
return Api.messages.RecentStickers.recentStickersNotModified
}
}
}

View File

@ -1,3 +1,81 @@
public extension Api.messages {
enum RecentStickers: TypeConstructorDescription {
case recentStickers(hash: Int64, packs: [Api.StickerPack], stickers: [Api.Document], dates: [Int32])
case recentStickersNotModified
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .recentStickers(let hash, let packs, let stickers, let dates):
if boxed {
buffer.appendInt32(-1999405994)
}
serializeInt64(hash, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(packs.count))
for item in packs {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(stickers.count))
for item in stickers {
item.serialize(buffer, true)
}
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(dates.count))
for item in dates {
serializeInt32(item, buffer: buffer, boxed: false)
}
break
case .recentStickersNotModified:
if boxed {
buffer.appendInt32(186120336)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .recentStickers(let hash, let packs, let stickers, let dates):
return ("recentStickers", [("hash", hash as Any), ("packs", packs as Any), ("stickers", stickers as Any), ("dates", dates as Any)])
case .recentStickersNotModified:
return ("recentStickersNotModified", [])
}
}
public static func parse_recentStickers(_ reader: BufferReader) -> RecentStickers? {
var _1: Int64?
_1 = reader.readInt64()
var _2: [Api.StickerPack]?
if let _ = reader.readInt32() {
_2 = Api.parseVector(reader, elementSignature: 0, elementType: Api.StickerPack.self)
}
var _3: [Api.Document]?
if let _ = reader.readInt32() {
_3 = Api.parseVector(reader, elementSignature: 0, elementType: Api.Document.self)
}
var _4: [Int32]?
if let _ = reader.readInt32() {
_4 = Api.parseVector(reader, elementSignature: -1471112230, elementType: Int32.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
if _c1 && _c2 && _c3 && _c4 {
return Api.messages.RecentStickers.recentStickers(hash: _1!, packs: _2!, stickers: _3!, dates: _4!)
}
else {
return nil
}
}
public static func parse_recentStickersNotModified(_ reader: BufferReader) -> RecentStickers? {
return Api.messages.RecentStickers.recentStickersNotModified
}
}
}
public extension Api.messages { public extension Api.messages {
enum SavedDialogs: TypeConstructorDescription { enum SavedDialogs: TypeConstructorDescription {
case savedDialogs(dialogs: [Api.SavedDialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User]) case savedDialogs(dialogs: [Api.SavedDialog], messages: [Api.Message], chats: [Api.Chat], users: [Api.User])
@ -1386,167 +1464,3 @@ public extension Api.payments {
} }
} }
public extension Api.payments {
enum PaymentReceipt: TypeConstructorDescription {
case paymentReceipt(flags: Int32, date: Int32, botId: Int64, providerId: Int64, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, info: Api.PaymentRequestedInfo?, shipping: Api.ShippingOption?, tipAmount: Int64?, currency: String, totalAmount: Int64, credentialsTitle: String, users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .paymentReceipt(let flags, let date, let botId, let providerId, let title, let description, let photo, let invoice, let info, let shipping, let tipAmount, let currency, let totalAmount, let credentialsTitle, let users):
if boxed {
buffer.appendInt32(1891958275)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt64(botId, buffer: buffer, boxed: false)
serializeInt64(providerId, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false)
serializeString(description, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {photo!.serialize(buffer, true)}
invoice.serialize(buffer, true)
if Int(flags) & Int(1 << 0) != 0 {info!.serialize(buffer, true)}
if Int(flags) & Int(1 << 1) != 0 {shipping!.serialize(buffer, true)}
if Int(flags) & Int(1 << 3) != 0 {serializeInt64(tipAmount!, buffer: buffer, boxed: false)}
serializeString(currency, buffer: buffer, boxed: false)
serializeInt64(totalAmount, buffer: buffer, boxed: false)
serializeString(credentialsTitle, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .paymentReceipt(let flags, let date, let botId, let providerId, let title, let description, let photo, let invoice, let info, let shipping, let tipAmount, let currency, let totalAmount, let credentialsTitle, let users):
return ("paymentReceipt", [("flags", flags as Any), ("date", date as Any), ("botId", botId as Any), ("providerId", providerId as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("invoice", invoice as Any), ("info", info as Any), ("shipping", shipping as Any), ("tipAmount", tipAmount as Any), ("currency", currency as Any), ("totalAmount", totalAmount as Any), ("credentialsTitle", credentialsTitle as Any), ("users", users as Any)])
}
}
public static func parse_paymentReceipt(_ reader: BufferReader) -> PaymentReceipt? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int64?
_3 = reader.readInt64()
var _4: Int64?
_4 = reader.readInt64()
var _5: String?
_5 = parseString(reader)
var _6: String?
_6 = parseString(reader)
var _7: Api.WebDocument?
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
_7 = Api.parse(reader, signature: signature) as? Api.WebDocument
} }
var _8: Api.Invoice?
if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.Invoice
}
var _9: Api.PaymentRequestedInfo?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_9 = Api.parse(reader, signature: signature) as? Api.PaymentRequestedInfo
} }
var _10: Api.ShippingOption?
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
_10 = Api.parse(reader, signature: signature) as? Api.ShippingOption
} }
var _11: Int64?
if Int(_1!) & Int(1 << 3) != 0 {_11 = reader.readInt64() }
var _12: String?
_12 = parseString(reader)
var _13: Int64?
_13 = reader.readInt64()
var _14: String?
_14 = parseString(reader)
var _15: [Api.User]?
if let _ = reader.readInt32() {
_15 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = (Int(_1!) & Int(1 << 2) == 0) || _7 != nil
let _c8 = _8 != nil
let _c9 = (Int(_1!) & Int(1 << 0) == 0) || _9 != nil
let _c10 = (Int(_1!) & Int(1 << 1) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 3) == 0) || _11 != nil
let _c12 = _12 != nil
let _c13 = _13 != nil
let _c14 = _14 != nil
let _c15 = _15 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 {
return Api.payments.PaymentReceipt.paymentReceipt(flags: _1!, date: _2!, botId: _3!, providerId: _4!, title: _5!, description: _6!, photo: _7, invoice: _8!, info: _9, shipping: _10, tipAmount: _11, currency: _12!, totalAmount: _13!, credentialsTitle: _14!, users: _15!)
}
else {
return nil
}
}
}
}
public extension Api.payments {
indirect enum PaymentResult: TypeConstructorDescription {
case paymentResult(updates: Api.Updates)
case paymentVerificationNeeded(url: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .paymentResult(let updates):
if boxed {
buffer.appendInt32(1314881805)
}
updates.serialize(buffer, true)
break
case .paymentVerificationNeeded(let url):
if boxed {
buffer.appendInt32(-666824391)
}
serializeString(url, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .paymentResult(let updates):
return ("paymentResult", [("updates", updates as Any)])
case .paymentVerificationNeeded(let url):
return ("paymentVerificationNeeded", [("url", url as Any)])
}
}
public static func parse_paymentResult(_ reader: BufferReader) -> PaymentResult? {
var _1: Api.Updates?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.Updates
}
let _c1 = _1 != nil
if _c1 {
return Api.payments.PaymentResult.paymentResult(updates: _1!)
}
else {
return nil
}
}
public static func parse_paymentVerificationNeeded(_ reader: BufferReader) -> PaymentResult? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.payments.PaymentResult.paymentVerificationNeeded(url: _1!)
}
else {
return nil
}
}
}
}

View File

@ -1,3 +1,167 @@
public extension Api.payments {
enum PaymentReceipt: TypeConstructorDescription {
case paymentReceipt(flags: Int32, date: Int32, botId: Int64, providerId: Int64, title: String, description: String, photo: Api.WebDocument?, invoice: Api.Invoice, info: Api.PaymentRequestedInfo?, shipping: Api.ShippingOption?, tipAmount: Int64?, currency: String, totalAmount: Int64, credentialsTitle: String, users: [Api.User])
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .paymentReceipt(let flags, let date, let botId, let providerId, let title, let description, let photo, let invoice, let info, let shipping, let tipAmount, let currency, let totalAmount, let credentialsTitle, let users):
if boxed {
buffer.appendInt32(1891958275)
}
serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(date, buffer: buffer, boxed: false)
serializeInt64(botId, buffer: buffer, boxed: false)
serializeInt64(providerId, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false)
serializeString(description, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 2) != 0 {photo!.serialize(buffer, true)}
invoice.serialize(buffer, true)
if Int(flags) & Int(1 << 0) != 0 {info!.serialize(buffer, true)}
if Int(flags) & Int(1 << 1) != 0 {shipping!.serialize(buffer, true)}
if Int(flags) & Int(1 << 3) != 0 {serializeInt64(tipAmount!, buffer: buffer, boxed: false)}
serializeString(currency, buffer: buffer, boxed: false)
serializeInt64(totalAmount, buffer: buffer, boxed: false)
serializeString(credentialsTitle, buffer: buffer, boxed: false)
buffer.appendInt32(481674261)
buffer.appendInt32(Int32(users.count))
for item in users {
item.serialize(buffer, true)
}
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .paymentReceipt(let flags, let date, let botId, let providerId, let title, let description, let photo, let invoice, let info, let shipping, let tipAmount, let currency, let totalAmount, let credentialsTitle, let users):
return ("paymentReceipt", [("flags", flags as Any), ("date", date as Any), ("botId", botId as Any), ("providerId", providerId as Any), ("title", title as Any), ("description", description as Any), ("photo", photo as Any), ("invoice", invoice as Any), ("info", info as Any), ("shipping", shipping as Any), ("tipAmount", tipAmount as Any), ("currency", currency as Any), ("totalAmount", totalAmount as Any), ("credentialsTitle", credentialsTitle as Any), ("users", users as Any)])
}
}
public static func parse_paymentReceipt(_ reader: BufferReader) -> PaymentReceipt? {
var _1: Int32?
_1 = reader.readInt32()
var _2: Int32?
_2 = reader.readInt32()
var _3: Int64?
_3 = reader.readInt64()
var _4: Int64?
_4 = reader.readInt64()
var _5: String?
_5 = parseString(reader)
var _6: String?
_6 = parseString(reader)
var _7: Api.WebDocument?
if Int(_1!) & Int(1 << 2) != 0 {if let signature = reader.readInt32() {
_7 = Api.parse(reader, signature: signature) as? Api.WebDocument
} }
var _8: Api.Invoice?
if let signature = reader.readInt32() {
_8 = Api.parse(reader, signature: signature) as? Api.Invoice
}
var _9: Api.PaymentRequestedInfo?
if Int(_1!) & Int(1 << 0) != 0 {if let signature = reader.readInt32() {
_9 = Api.parse(reader, signature: signature) as? Api.PaymentRequestedInfo
} }
var _10: Api.ShippingOption?
if Int(_1!) & Int(1 << 1) != 0 {if let signature = reader.readInt32() {
_10 = Api.parse(reader, signature: signature) as? Api.ShippingOption
} }
var _11: Int64?
if Int(_1!) & Int(1 << 3) != 0 {_11 = reader.readInt64() }
var _12: String?
_12 = parseString(reader)
var _13: Int64?
_13 = reader.readInt64()
var _14: String?
_14 = parseString(reader)
var _15: [Api.User]?
if let _ = reader.readInt32() {
_15 = Api.parseVector(reader, elementSignature: 0, elementType: Api.User.self)
}
let _c1 = _1 != nil
let _c2 = _2 != nil
let _c3 = _3 != nil
let _c4 = _4 != nil
let _c5 = _5 != nil
let _c6 = _6 != nil
let _c7 = (Int(_1!) & Int(1 << 2) == 0) || _7 != nil
let _c8 = _8 != nil
let _c9 = (Int(_1!) & Int(1 << 0) == 0) || _9 != nil
let _c10 = (Int(_1!) & Int(1 << 1) == 0) || _10 != nil
let _c11 = (Int(_1!) & Int(1 << 3) == 0) || _11 != nil
let _c12 = _12 != nil
let _c13 = _13 != nil
let _c14 = _14 != nil
let _c15 = _15 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 && _c9 && _c10 && _c11 && _c12 && _c13 && _c14 && _c15 {
return Api.payments.PaymentReceipt.paymentReceipt(flags: _1!, date: _2!, botId: _3!, providerId: _4!, title: _5!, description: _6!, photo: _7, invoice: _8!, info: _9, shipping: _10, tipAmount: _11, currency: _12!, totalAmount: _13!, credentialsTitle: _14!, users: _15!)
}
else {
return nil
}
}
}
}
public extension Api.payments {
indirect enum PaymentResult: TypeConstructorDescription {
case paymentResult(updates: Api.Updates)
case paymentVerificationNeeded(url: String)
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self {
case .paymentResult(let updates):
if boxed {
buffer.appendInt32(1314881805)
}
updates.serialize(buffer, true)
break
case .paymentVerificationNeeded(let url):
if boxed {
buffer.appendInt32(-666824391)
}
serializeString(url, buffer: buffer, boxed: false)
break
}
}
public func descriptionFields() -> (String, [(String, Any)]) {
switch self {
case .paymentResult(let updates):
return ("paymentResult", [("updates", updates as Any)])
case .paymentVerificationNeeded(let url):
return ("paymentVerificationNeeded", [("url", url as Any)])
}
}
public static func parse_paymentResult(_ reader: BufferReader) -> PaymentResult? {
var _1: Api.Updates?
if let signature = reader.readInt32() {
_1 = Api.parse(reader, signature: signature) as? Api.Updates
}
let _c1 = _1 != nil
if _c1 {
return Api.payments.PaymentResult.paymentResult(updates: _1!)
}
else {
return nil
}
}
public static func parse_paymentVerificationNeeded(_ reader: BufferReader) -> PaymentResult? {
var _1: String?
_1 = parseString(reader)
let _c1 = _1 != nil
if _c1 {
return Api.payments.PaymentResult.paymentVerificationNeeded(url: _1!)
}
else {
return nil
}
}
}
}
public extension Api.payments { public extension Api.payments {
enum SavedInfo: TypeConstructorDescription { enum SavedInfo: TypeConstructorDescription {
case savedInfo(flags: Int32, savedInfo: Api.PaymentRequestedInfo?) case savedInfo(flags: Int32, savedInfo: Api.PaymentRequestedInfo?)

View File

@ -5325,15 +5325,15 @@ public extension Api.functions.messages {
} }
} }
public extension Api.functions.messages { public extension Api.functions.messages {
static func getDialogFilters() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<[Api.DialogFilter]>) { static func getDialogFilters() -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.messages.DialogFilters>) {
let buffer = Buffer() let buffer = Buffer()
buffer.appendInt32(-241247891) buffer.appendInt32(-271283063)
return (FunctionDescription(name: "messages.getDialogFilters", parameters: []), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> [Api.DialogFilter]? in return (FunctionDescription(name: "messages.getDialogFilters", parameters: []), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.messages.DialogFilters? in
let reader = BufferReader(buffer) let reader = BufferReader(buffer)
var result: [Api.DialogFilter]? var result: Api.messages.DialogFilters?
if let _ = reader.readInt32() { if let signature = reader.readInt32() {
result = Api.parseVector(reader, elementSignature: 0, elementType: Api.DialogFilter.self) result = Api.parse(reader, signature: signature) as? Api.messages.DialogFilters
} }
return result return result
}) })
@ -7816,6 +7816,21 @@ public extension Api.functions.messages {
}) })
} }
} }
public extension Api.functions.messages {
static func toggleDialogFilterTags(enabled: Api.Bool) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer()
buffer.appendInt32(-47326647)
enabled.serialize(buffer, true)
return (FunctionDescription(name: "messages.toggleDialogFilterTags", parameters: [("enabled", String(describing: enabled))]), buffer, DeserializeFunctionResponse { (buffer: Buffer) -> Api.Bool? in
let reader = BufferReader(buffer)
var result: Api.Bool?
if let signature = reader.readInt32() {
result = Api.parse(reader, signature: signature) as? Api.Bool
}
return result
})
}
}
public extension Api.functions.messages { public extension Api.functions.messages {
static func toggleDialogPin(flags: Int32, peer: Api.InputDialogPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) { static func toggleDialogPin(flags: Int32, peer: Api.InputDialogPeer) -> (FunctionDescription, Buffer, DeserializeFunctionResponse<Api.Bool>) {
let buffer = Buffer() let buffer = Buffer()

View File

@ -1060,20 +1060,21 @@ public extension Api {
} }
public extension Api { public extension Api {
enum DialogFilter: TypeConstructorDescription { enum DialogFilter: TypeConstructorDescription {
case dialogFilter(flags: Int32, id: Int32, title: String, emoticon: String?, pinnedPeers: [Api.InputPeer], includePeers: [Api.InputPeer], excludePeers: [Api.InputPeer]) case dialogFilter(flags: Int32, id: Int32, title: String, emoticon: String?, color: Int32?, pinnedPeers: [Api.InputPeer], includePeers: [Api.InputPeer], excludePeers: [Api.InputPeer])
case dialogFilterChatlist(flags: Int32, id: Int32, title: String, emoticon: String?, pinnedPeers: [Api.InputPeer], includePeers: [Api.InputPeer]) case dialogFilterChatlist(flags: Int32, id: Int32, title: String, emoticon: String?, color: Int32?, pinnedPeers: [Api.InputPeer], includePeers: [Api.InputPeer])
case dialogFilterDefault case dialogFilterDefault
public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) { public func serialize(_ buffer: Buffer, _ boxed: Swift.Bool) {
switch self { switch self {
case .dialogFilter(let flags, let id, let title, let emoticon, let pinnedPeers, let includePeers, let excludePeers): case .dialogFilter(let flags, let id, let title, let emoticon, let color, let pinnedPeers, let includePeers, let excludePeers):
if boxed { if boxed {
buffer.appendInt32(1949890536) buffer.appendInt32(1605718587)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 25) != 0 {serializeString(emoticon!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 25) != 0 {serializeString(emoticon!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 27) != 0 {serializeInt32(color!, buffer: buffer, boxed: false)}
buffer.appendInt32(481674261) buffer.appendInt32(481674261)
buffer.appendInt32(Int32(pinnedPeers.count)) buffer.appendInt32(Int32(pinnedPeers.count))
for item in pinnedPeers { for item in pinnedPeers {
@ -1090,14 +1091,15 @@ public extension Api {
item.serialize(buffer, true) item.serialize(buffer, true)
} }
break break
case .dialogFilterChatlist(let flags, let id, let title, let emoticon, let pinnedPeers, let includePeers): case .dialogFilterChatlist(let flags, let id, let title, let emoticon, let color, let pinnedPeers, let includePeers):
if boxed { if boxed {
buffer.appendInt32(-699792216) buffer.appendInt32(-1612542300)
} }
serializeInt32(flags, buffer: buffer, boxed: false) serializeInt32(flags, buffer: buffer, boxed: false)
serializeInt32(id, buffer: buffer, boxed: false) serializeInt32(id, buffer: buffer, boxed: false)
serializeString(title, buffer: buffer, boxed: false) serializeString(title, buffer: buffer, boxed: false)
if Int(flags) & Int(1 << 25) != 0 {serializeString(emoticon!, buffer: buffer, boxed: false)} if Int(flags) & Int(1 << 25) != 0 {serializeString(emoticon!, buffer: buffer, boxed: false)}
if Int(flags) & Int(1 << 27) != 0 {serializeInt32(color!, buffer: buffer, boxed: false)}
buffer.appendInt32(481674261) buffer.appendInt32(481674261)
buffer.appendInt32(Int32(pinnedPeers.count)) buffer.appendInt32(Int32(pinnedPeers.count))
for item in pinnedPeers { for item in pinnedPeers {
@ -1120,10 +1122,10 @@ public extension Api {
public func descriptionFields() -> (String, [(String, Any)]) { public func descriptionFields() -> (String, [(String, Any)]) {
switch self { switch self {
case .dialogFilter(let flags, let id, let title, let emoticon, let pinnedPeers, let includePeers, let excludePeers): case .dialogFilter(let flags, let id, let title, let emoticon, let color, let pinnedPeers, let includePeers, let excludePeers):
return ("dialogFilter", [("flags", flags as Any), ("id", id as Any), ("title", title as Any), ("emoticon", emoticon as Any), ("pinnedPeers", pinnedPeers as Any), ("includePeers", includePeers as Any), ("excludePeers", excludePeers as Any)]) return ("dialogFilter", [("flags", flags as Any), ("id", id as Any), ("title", title as Any), ("emoticon", emoticon as Any), ("color", color as Any), ("pinnedPeers", pinnedPeers as Any), ("includePeers", includePeers as Any), ("excludePeers", excludePeers as Any)])
case .dialogFilterChatlist(let flags, let id, let title, let emoticon, let pinnedPeers, let includePeers): case .dialogFilterChatlist(let flags, let id, let title, let emoticon, let color, let pinnedPeers, let includePeers):
return ("dialogFilterChatlist", [("flags", flags as Any), ("id", id as Any), ("title", title as Any), ("emoticon", emoticon as Any), ("pinnedPeers", pinnedPeers as Any), ("includePeers", includePeers as Any)]) return ("dialogFilterChatlist", [("flags", flags as Any), ("id", id as Any), ("title", title as Any), ("emoticon", emoticon as Any), ("color", color as Any), ("pinnedPeers", pinnedPeers as Any), ("includePeers", includePeers as Any)])
case .dialogFilterDefault: case .dialogFilterDefault:
return ("dialogFilterDefault", []) return ("dialogFilterDefault", [])
} }
@ -1138,10 +1140,8 @@ public extension Api {
_3 = parseString(reader) _3 = parseString(reader)
var _4: String? var _4: String?
if Int(_1!) & Int(1 << 25) != 0 {_4 = parseString(reader) } if Int(_1!) & Int(1 << 25) != 0 {_4 = parseString(reader) }
var _5: [Api.InputPeer]? var _5: Int32?
if let _ = reader.readInt32() { if Int(_1!) & Int(1 << 27) != 0 {_5 = reader.readInt32() }
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputPeer.self)
}
var _6: [Api.InputPeer]? var _6: [Api.InputPeer]?
if let _ = reader.readInt32() { if let _ = reader.readInt32() {
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputPeer.self) _6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputPeer.self)
@ -1150,15 +1150,20 @@ public extension Api {
if let _ = reader.readInt32() { if let _ = reader.readInt32() {
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputPeer.self) _7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputPeer.self)
} }
var _8: [Api.InputPeer]?
if let _ = reader.readInt32() {
_8 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputPeer.self)
}
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = _3 != nil let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 25) == 0) || _4 != nil let _c4 = (Int(_1!) & Int(1 << 25) == 0) || _4 != nil
let _c5 = _5 != nil let _c5 = (Int(_1!) & Int(1 << 27) == 0) || _5 != nil
let _c6 = _6 != nil let _c6 = _6 != nil
let _c7 = _7 != nil let _c7 = _7 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 { let _c8 = _8 != nil
return Api.DialogFilter.dialogFilter(flags: _1!, id: _2!, title: _3!, emoticon: _4, pinnedPeers: _5!, includePeers: _6!, excludePeers: _7!) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 && _c8 {
return Api.DialogFilter.dialogFilter(flags: _1!, id: _2!, title: _3!, emoticon: _4, color: _5, pinnedPeers: _6!, includePeers: _7!, excludePeers: _8!)
} }
else { else {
return nil return nil
@ -1173,22 +1178,25 @@ public extension Api {
_3 = parseString(reader) _3 = parseString(reader)
var _4: String? var _4: String?
if Int(_1!) & Int(1 << 25) != 0 {_4 = parseString(reader) } if Int(_1!) & Int(1 << 25) != 0 {_4 = parseString(reader) }
var _5: [Api.InputPeer]? var _5: Int32?
if let _ = reader.readInt32() { if Int(_1!) & Int(1 << 27) != 0 {_5 = reader.readInt32() }
_5 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputPeer.self)
}
var _6: [Api.InputPeer]? var _6: [Api.InputPeer]?
if let _ = reader.readInt32() { if let _ = reader.readInt32() {
_6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputPeer.self) _6 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputPeer.self)
} }
var _7: [Api.InputPeer]?
if let _ = reader.readInt32() {
_7 = Api.parseVector(reader, elementSignature: 0, elementType: Api.InputPeer.self)
}
let _c1 = _1 != nil let _c1 = _1 != nil
let _c2 = _2 != nil let _c2 = _2 != nil
let _c3 = _3 != nil let _c3 = _3 != nil
let _c4 = (Int(_1!) & Int(1 << 25) == 0) || _4 != nil let _c4 = (Int(_1!) & Int(1 << 25) == 0) || _4 != nil
let _c5 = _5 != nil let _c5 = (Int(_1!) & Int(1 << 27) == 0) || _5 != nil
let _c6 = _6 != nil let _c6 = _6 != nil
if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 { let _c7 = _7 != nil
return Api.DialogFilter.dialogFilterChatlist(flags: _1!, id: _2!, title: _3!, emoticon: _4, pinnedPeers: _5!, includePeers: _6!) if _c1 && _c2 && _c3 && _c4 && _c5 && _c6 && _c7 {
return Api.DialogFilter.dialogFilterChatlist(flags: _1!, id: _2!, title: _3!, emoticon: _4, color: _5, pinnedPeers: _6!, includePeers: _7!)
} }
else { else {
return nil return nil

View File

@ -306,7 +306,7 @@ extension ChatListFilter {
switch apiFilter { switch apiFilter {
case .dialogFilterDefault: case .dialogFilterDefault:
self = .allChats self = .allChats
case let .dialogFilter(flags, id, title, emoticon, pinnedPeers, includePeers, excludePeers): case let .dialogFilter(flags, id, title, emoticon, color, pinnedPeers, includePeers, excludePeers):
self = .filter( self = .filter(
id: id, id: id,
title: title, title: title,
@ -353,10 +353,10 @@ extension ChatListFilter {
return nil return nil
} }
}, },
color: nil color: color.flatMap(PeerNameColor.init(rawValue:))
) )
) )
case let .dialogFilterChatlist(flags, id, title, emoticon, pinnedPeers, includePeers): case let .dialogFilterChatlist(flags, id, title, emoticon, color, pinnedPeers, includePeers):
self = .filter( self = .filter(
id: id, id: id,
title: title, title: title,
@ -392,7 +392,7 @@ extension ChatListFilter {
} }
}), }),
excludePeers: [], excludePeers: [],
color: nil color: color.flatMap(PeerNameColor.init(rawValue:))
) )
) )
} }
@ -408,7 +408,10 @@ extension ChatListFilter {
if emoticon != nil { if emoticon != nil {
flags |= 1 << 25 flags |= 1 << 25
} }
return .dialogFilterChatlist(flags: flags, id: id, title: title, emoticon: emoticon, pinnedPeers: data.includePeers.pinnedPeers.compactMap { peerId -> Api.InputPeer? in if data.color != nil {
flags |= 1 << 27
}
return .dialogFilterChatlist(flags: flags, id: id, title: title, emoticon: emoticon, color: data.color?.rawValue, pinnedPeers: data.includePeers.pinnedPeers.compactMap { peerId -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer) return transaction.getPeer(peerId).flatMap(apiInputPeer)
}, includePeers: data.includePeers.peers.compactMap { peerId -> Api.InputPeer? in }, includePeers: data.includePeers.peers.compactMap { peerId -> Api.InputPeer? in
if data.includePeers.pinnedPeers.contains(peerId) { if data.includePeers.pinnedPeers.contains(peerId) {
@ -431,7 +434,10 @@ extension ChatListFilter {
if emoticon != nil { if emoticon != nil {
flags |= 1 << 25 flags |= 1 << 25
} }
return .dialogFilter(flags: flags, id: id, title: title, emoticon: emoticon, pinnedPeers: data.includePeers.pinnedPeers.compactMap { peerId -> Api.InputPeer? in if data.color != nil {
flags |= 1 << 27
}
return .dialogFilter(flags: flags, id: id, title: title, emoticon: emoticon, color: data.color?.rawValue, pinnedPeers: data.includePeers.pinnedPeers.compactMap { peerId -> Api.InputPeer? in
return transaction.getPeer(peerId).flatMap(apiInputPeer) return transaction.getPeer(peerId).flatMap(apiInputPeer)
}, includePeers: data.includePeers.peers.compactMap { peerId -> Api.InputPeer? in }, includePeers: data.includePeers.peers.compactMap { peerId -> Api.InputPeer? in
if data.includePeers.pinnedPeers.contains(peerId) { if data.includePeers.pinnedPeers.contains(peerId) {
@ -488,25 +494,29 @@ private enum RequestChatListFiltersError {
case generic case generic
} }
private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, network: Network) -> Signal<[ChatListFilter], RequestChatListFiltersError> { private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, network: Network) -> Signal<([ChatListFilter], Bool), RequestChatListFiltersError> {
return network.request(Api.functions.messages.getDialogFilters()) return network.request(Api.functions.messages.getDialogFilters())
|> mapError { _ -> RequestChatListFiltersError in |> mapError { _ -> RequestChatListFiltersError in
return .generic return .generic
} }
|> mapToSignal { result -> Signal<[ChatListFilter], RequestChatListFiltersError> in |> mapToSignal { result -> Signal<([ChatListFilter], Bool), RequestChatListFiltersError> in
return postbox.transaction { transaction -> ([ChatListFilter], [Api.InputPeer], [Api.InputPeer]) in return postbox.transaction { transaction -> ([ChatListFilter], [Api.InputPeer], [Api.InputPeer], Bool) in
switch result {
case let .dialogFilters(flags, apiFilters):
let tagsEnabled = (flags & (1 << 0)) != 0
var filters: [ChatListFilter] = [] var filters: [ChatListFilter] = []
var missingPeers: [Api.InputPeer] = [] var missingPeers: [Api.InputPeer] = []
var missingChats: [Api.InputPeer] = [] var missingChats: [Api.InputPeer] = []
var missingPeerIds = Set<PeerId>() var missingPeerIds = Set<PeerId>()
var missingChatIds = Set<PeerId>() var missingChatIds = Set<PeerId>()
for apiFilter in result { for apiFilter in apiFilters {
let filter = ChatListFilter(apiFilter: apiFilter) let filter = ChatListFilter(apiFilter: apiFilter)
filters.append(filter) filters.append(filter)
switch apiFilter { switch apiFilter {
case .dialogFilterDefault: case .dialogFilterDefault:
break break
case let .dialogFilter(_, _, _, _, pinnedPeers, includePeers, excludePeers): case let .dialogFilter(_, _, _, _, _, pinnedPeers, includePeers, excludePeers):
for peer in pinnedPeers + includePeers + excludePeers { for peer in pinnedPeers + includePeers + excludePeers {
var peerId: PeerId? var peerId: PeerId?
switch peer { switch peer {
@ -546,7 +556,7 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
} }
} }
} }
case let .dialogFilterChatlist(_, _, _, _, pinnedPeers, includePeers): case let .dialogFilterChatlist(_, _, _, _, _, pinnedPeers, includePeers):
for peer in pinnedPeers + includePeers { for peer in pinnedPeers + includePeers {
var peerId: PeerId? var peerId: PeerId?
switch peer { switch peer {
@ -588,11 +598,12 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
} }
} }
} }
return (filters, missingPeers, missingChats) return (filters, missingPeers, missingChats, tagsEnabled)
}
} }
|> castError(RequestChatListFiltersError.self) |> castError(RequestChatListFiltersError.self)
|> mapToSignal { filtersAndMissingPeers -> Signal<[ChatListFilter], RequestChatListFiltersError> in |> mapToSignal { filtersAndMissingPeers -> Signal<([ChatListFilter], Bool), RequestChatListFiltersError> in
let (filters, missingPeers, missingChats) = filtersAndMissingPeers let (filters, missingPeers, missingChats, tagsEnabled) = filtersAndMissingPeers
var missingUsers: [Api.InputUser] = [] var missingUsers: [Api.InputUser] = []
var missingChannels: [Api.InputChannel] = [] var missingChannels: [Api.InputChannel] = []
@ -700,13 +711,10 @@ private func requestChatListFilters(accountPeerId: PeerId, postbox: Postbox, net
loadMissingChats loadMissingChats
) )
|> castError(RequestChatListFiltersError.self) |> castError(RequestChatListFiltersError.self)
|> mapToSignal { _ -> Signal<[ChatListFilter], RequestChatListFiltersError> in |> mapToSignal { _ -> Signal<([ChatListFilter], Bool), RequestChatListFiltersError> in
#if swift(<5.1)
return .complete()
#endif
} }
|> then( |> then(
.single(filters) Signal<([ChatListFilter], Bool), RequestChatListFiltersError>.single((filters, tagsEnabled))
) )
} }
} }
@ -889,14 +897,16 @@ struct ChatListFiltersState: Codable, Equatable {
var updates: [ChatListFilterUpdates] var updates: [ChatListFilterUpdates]
var remoteDisplayTags: Bool?
var displayTags: Bool var displayTags: Bool
static var `default` = ChatListFiltersState(filters: [], remoteFilters: nil, updates: [], displayTags: false) static var `default` = ChatListFiltersState(filters: [], remoteFilters: nil, updates: [], remoteDisplayTags: nil, displayTags: false)
fileprivate init(filters: [ChatListFilter], remoteFilters: [ChatListFilter]?, updates: [ChatListFilterUpdates], displayTags: Bool) { fileprivate init(filters: [ChatListFilter], remoteFilters: [ChatListFilter]?, updates: [ChatListFilterUpdates], remoteDisplayTags: Bool?, displayTags: Bool) {
self.filters = filters self.filters = filters
self.remoteFilters = remoteFilters self.remoteFilters = remoteFilters
self.updates = updates self.updates = updates
self.remoteDisplayTags = remoteDisplayTags
self.displayTags = displayTags self.displayTags = displayTags
} }
@ -906,6 +916,7 @@ struct ChatListFiltersState: Codable, Equatable {
self.filters = try container.decode([ChatListFilter].self, forKey: "filters") self.filters = try container.decode([ChatListFilter].self, forKey: "filters")
self.remoteFilters = try container.decodeIfPresent([ChatListFilter].self, forKey: "remoteFilters") self.remoteFilters = try container.decodeIfPresent([ChatListFilter].self, forKey: "remoteFilters")
self.updates = try container.decodeIfPresent([ChatListFilterUpdates].self, forKey: "updates") ?? [] self.updates = try container.decodeIfPresent([ChatListFilterUpdates].self, forKey: "updates") ?? []
self.remoteDisplayTags = try container.decodeIfPresent(Bool.self, forKey: "remoteDisplayTags")
self.displayTags = try container.decodeIfPresent(Bool.self, forKey: "displayTags") ?? false self.displayTags = try container.decodeIfPresent(Bool.self, forKey: "displayTags") ?? false
} }
@ -915,6 +926,7 @@ struct ChatListFiltersState: Codable, Equatable {
try container.encode(self.filters, forKey: "filters") try container.encode(self.filters, forKey: "filters")
try container.encodeIfPresent(self.remoteFilters, forKey: "remoteFilters") try container.encodeIfPresent(self.remoteFilters, forKey: "remoteFilters")
try container.encode(self.updates, forKey: "updates") try container.encode(self.updates, forKey: "updates")
try container.encodeIfPresent(self.remoteDisplayTags, forKey: "remoteDisplayTags")
try container.encode(self.displayTags, forKey: "displayTags") try container.encode(self.displayTags, forKey: "displayTags")
} }
@ -959,6 +971,27 @@ func _internal_updateChatListFiltersInteractively(postbox: Postbox, _ f: @escapi
} }
} }
func _internal_updateChatListFiltersDisplayTagsInteractively(postbox: Postbox, displayTags: Bool) -> Signal<Never, NoError> {
return postbox.transaction { transaction -> Void in
var hasUpdates = false
transaction.updatePreferencesEntry(key: PreferencesKeys.chatListFilters, { entry in
var state = entry?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default
if displayTags != state.displayTags {
state.displayTags = displayTags
hasUpdates = true
}
state.normalize()
return PreferencesEntry(state)
})
if hasUpdates {
requestChatListFiltersSync(transaction: transaction)
}
}
|> ignoreValues
}
func _internal_updateChatListFiltersInteractively(transaction: Transaction, _ f: ([ChatListFilter]) -> [ChatListFilter]) { func _internal_updateChatListFiltersInteractively(transaction: Transaction, _ f: ([ChatListFilter]) -> [ChatListFilter]) {
var hasUpdates = false var hasUpdates = false
transaction.updatePreferencesEntry(key: PreferencesKeys.chatListFilters, { entry in transaction.updatePreferencesEntry(key: PreferencesKeys.chatListFilters, { entry in
@ -1366,18 +1399,21 @@ private func synchronizeChatListFilters(transaction: Transaction, accountPeerId:
let settings = transaction.getPreferencesEntry(key: PreferencesKeys.chatListFilters)?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default let settings = transaction.getPreferencesEntry(key: PreferencesKeys.chatListFilters)?.get(ChatListFiltersState.self) ?? ChatListFiltersState.default
let localFilters = settings.filters let localFilters = settings.filters
let locallyKnownRemoteFilters = settings.remoteFilters ?? [] let locallyKnownRemoteFilters = settings.remoteFilters ?? []
let localDisplayTags = settings.displayTags
let locallyKnownRemoteDisplayTags = settings.remoteDisplayTags ?? false
return requestChatListFilters(accountPeerId: accountPeerId, postbox: postbox, network: network) return requestChatListFilters(accountPeerId: accountPeerId, postbox: postbox, network: network)
|> `catch` { _ -> Signal<[ChatListFilter], NoError> in |> `catch` { _ -> Signal<([ChatListFilter], Bool), NoError> in
return .complete() return .complete()
} }
|> mapToSignal { remoteFilters -> Signal<Never, NoError> in |> mapToSignal { remoteFilters, remoteTagsEnabled -> Signal<Never, NoError> in
if localFilters == locallyKnownRemoteFilters { if localFilters == locallyKnownRemoteFilters && localDisplayTags == locallyKnownRemoteDisplayTags {
return postbox.transaction { transaction -> Void in return postbox.transaction { transaction -> Void in
let _ = updateChatListFiltersState(transaction: transaction, { state in let _ = updateChatListFiltersState(transaction: transaction, { state in
var state = state var state = state
state.filters = remoteFilters state.filters = remoteFilters
state.remoteFilters = state.filters state.remoteFilters = state.filters
state.displayTags = remoteTagsEnabled
return state return state
}) })
} }
@ -1453,6 +1489,17 @@ private func synchronizeChatListFilters(transaction: Transaction, accountPeerId:
reorderFilters = .complete() reorderFilters = .complete()
} }
let updateTagsEnabled: Signal<Never, NoError>
if localDisplayTags != remoteTagsEnabled {
updateTagsEnabled = network.request(Api.functions.messages.toggleDialogFilterTags(enabled: localDisplayTags ? .boolTrue : .boolFalse))
|> ignoreValues
|> `catch` { _ -> Signal<Never, NoError> in
return .complete()
}
} else {
updateTagsEnabled = .complete()
}
return deleteSignals return deleteSignals
|> then( |> then(
addSignals addSignals
@ -1460,12 +1507,16 @@ private func synchronizeChatListFilters(transaction: Transaction, accountPeerId:
|> then( |> then(
reorderFilters reorderFilters
) )
|> then(
updateTagsEnabled
)
|> then( |> then(
postbox.transaction { transaction -> Void in postbox.transaction { transaction -> Void in
let _ = updateChatListFiltersState(transaction: transaction, { state in let _ = updateChatListFiltersState(transaction: transaction, { state in
var state = state var state = state
state.filters = mergedFilters state.filters = mergedFilters
state.remoteFilters = state.filters state.remoteFilters = state.filters
state.remoteDisplayTags = state.displayTags
return state return state
}) })
} }

View File

@ -589,13 +589,7 @@ public extension TelegramEngine {
} }
public func updateChatListFiltersDisplayTags(isEnabled: Bool) { public func updateChatListFiltersDisplayTags(isEnabled: Bool) {
let _ = self.account.postbox.transaction({ transaction in let _ = _internal_updateChatListFiltersDisplayTagsInteractively(postbox: self.account.postbox, displayTags: isEnabled).startStandalone()
updateChatListFiltersState(transaction: transaction, { state in
var state = state
state.displayTags = isEnabled
return state
})
}).start()
} }
public func updatedChatListFilters() -> Signal<[ChatListFilter], NoError> { public func updatedChatListFilters() -> Signal<[ChatListFilter], NoError> {

View File

@ -233,21 +233,27 @@ private final class PeerNameColorIconItemNode : ASDisplayNode {
} }
public final class PeerNameColorItem: ListViewItem, ItemListItem, ListItemComponentAdaptor.ItemGenerator { public final class PeerNameColorItem: ListViewItem, ItemListItem, ListItemComponentAdaptor.ItemGenerator {
public enum Mode {
case name
case profile
case folderTag
}
public var sectionId: ItemListSectionId public var sectionId: ItemListSectionId
public let theme: PresentationTheme public let theme: PresentationTheme
public let colors: PeerNameColors public let colors: PeerNameColors
public let isProfile: Bool public let mode: Mode
public let displayEmptyColor: Bool public let displayEmptyColor: Bool
public let isLocked: Bool public let isLocked: Bool
public let currentColor: PeerNameColor? public let currentColor: PeerNameColor?
public let updated: (PeerNameColor?) -> Void public let updated: (PeerNameColor?) -> Void
public let tag: ItemListItemTag? public let tag: ItemListItemTag?
public init(theme: PresentationTheme, colors: PeerNameColors, isProfile: Bool, displayEmptyColor: Bool = false, currentColor: PeerNameColor?, isLocked: Bool = false, updated: @escaping (PeerNameColor?) -> Void, tag: ItemListItemTag? = nil, sectionId: ItemListSectionId) { public init(theme: PresentationTheme, colors: PeerNameColors, mode: Mode, displayEmptyColor: Bool = false, currentColor: PeerNameColor?, isLocked: Bool = false, updated: @escaping (PeerNameColor?) -> Void, tag: ItemListItemTag? = nil, sectionId: ItemListSectionId) {
self.theme = theme self.theme = theme
self.colors = colors self.colors = colors
self.isProfile = isProfile self.mode = mode
self.displayEmptyColor = displayEmptyColor self.displayEmptyColor = displayEmptyColor
self.isLocked = isLocked self.isLocked = isLocked
self.currentColor = currentColor self.currentColor = currentColor
@ -300,7 +306,7 @@ public final class PeerNameColorItem: ListViewItem, ItemListItem, ListItemCompon
if lhs.colors != rhs.colors { if lhs.colors != rhs.colors {
return false return false
} }
if lhs.isProfile != rhs.isProfile { if lhs.mode != rhs.mode {
return false return false
} }
if lhs.currentColor != rhs.currentColor { if lhs.currentColor != rhs.currentColor {
@ -363,13 +369,18 @@ public final class PeerNameColorItemNode: ListViewItemNode, ItemListItemNode {
let itemsPerRow: Int let itemsPerRow: Int
let displayOrder: [Int32] let displayOrder: [Int32]
if item.isProfile { switch item.mode {
displayOrder = item.colors.profileDisplayOrder case .name:
itemsPerRow = 8
} else {
displayOrder = item.colors.displayOrder displayOrder = item.colors.displayOrder
itemsPerRow = 7 itemsPerRow = 7
case .profile:
displayOrder = item.colors.profileDisplayOrder
itemsPerRow = 8
case .folderTag:
displayOrder = item.colors.chatFolderTagDisplayOrder
itemsPerRow = 8
} }
var numItems = displayOrder.count var numItems = displayOrder.count
if item.displayEmptyColor { if item.displayEmptyColor {
numItems += 1 numItems += 1
@ -466,10 +477,13 @@ public final class PeerNameColorItemNode: ListViewItemNode, ItemListItemNode {
for index in displayOrder { for index in displayOrder {
let color = PeerNameColor(rawValue: index) let color = PeerNameColor(rawValue: index)
let colors: PeerNameColors.Colors let colors: PeerNameColors.Colors
if item.isProfile { switch item.mode {
colors = item.colors.getProfile(color, dark: item.theme.overallDarkAppearance, subject: .palette) case .name:
} else {
colors = item.colors.get(color, dark: item.theme.overallDarkAppearance) colors = item.colors.get(color, dark: item.theme.overallDarkAppearance)
case .profile:
colors = item.colors.getProfile(color, dark: item.theme.overallDarkAppearance, subject: .palette)
case .folderTag:
colors = item.colors.getChatFolderTag(color, dark: item.theme.overallDarkAppearance)
} }
items.append(PeerNameColorIconItem(index: color, colors: colors, isDark: item.theme.overallDarkAppearance, selected: color == item.currentColor, isLocked: item.isLocked, action: action)) items.append(PeerNameColorIconItem(index: color, colors: colors, isDark: item.theme.overallDarkAppearance, selected: color == item.currentColor, isLocked: item.isLocked, action: action))

View File

@ -1261,7 +1261,7 @@ final class ChannelAppearanceScreenComponent: Component {
itemGenerator: PeerNameColorItem( itemGenerator: PeerNameColorItem(
theme: environment.theme, theme: environment.theme,
colors: component.context.peerNameColors, colors: component.context.peerNameColors,
isProfile: true, mode: .profile,
currentColor: profileColor, currentColor: profileColor,
updated: { [weak self] value in updated: { [weak self] value in
guard let self, let value else { guard let self, let value else {
@ -1578,7 +1578,7 @@ final class ChannelAppearanceScreenComponent: Component {
itemGenerator: PeerNameColorItem( itemGenerator: PeerNameColorItem(
theme: environment.theme, theme: environment.theme,
colors: component.context.peerNameColors, colors: component.context.peerNameColors,
isProfile: false, mode: .name,
currentColor: resolvedState.nameColor, currentColor: resolvedState.nameColor,
updated: { [weak self] value in updated: { [weak self] value in
guard let self, let value else { guard let self, let value else {

View File

@ -212,7 +212,7 @@ private enum PeerNameColorScreenEntry: ItemListNodeEntry {
return PeerNameColorItem( return PeerNameColorItem(
theme: presentationData.theme, theme: presentationData.theme,
colors: colors, colors: colors,
isProfile: isProfile, mode: isProfile ? .profile : .name,
currentColor: currentColor, currentColor: currentColor,
updated: { color in updated: { color in
if let color { if let color {