From 1014179d4509d4b218b12a278ef223c13dc5b33c Mon Sep 17 00:00:00 2001 From: Ali <> Date: Thu, 26 Mar 2020 17:46:35 +0400 Subject: [PATCH] Allow archiving chats in folders that exclude archived chats --- .../Sources/Node/ChatListItem.swift | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/submodules/ChatListUI/Sources/Node/ChatListItem.swift b/submodules/ChatListUI/Sources/Node/ChatListItem.swift index 72254e1093..5b12e4dc16 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListItem.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListItem.swift @@ -234,12 +234,25 @@ private func revealOptions(strings: PresentationStrings, theme: PresentationThem if canDelete { options.append(ItemListRevealOption(key: RevealOptionKey.delete.rawValue, title: strings.Common_Delete, icon: deleteIcon, color: theme.list.itemDisclosureActions.destructive.fillColor, textColor: theme.list.itemDisclosureActions.destructive.foregroundColor)) } - if !isEditing && filterData == nil { - if case .root = groupId { + if !isEditing { + var canArchive = false + var canUnarchive = false + if let filterData = filterData { + if filterData.excludesArchived { + canArchive = true + } + } else { + if case .root = groupId { + canArchive = true + } else { + canUnarchive = true + } + } + if canArchive { if canArchivePeer(id: peerId, accountPeerId: accountPeerId) { options.append(ItemListRevealOption(key: RevealOptionKey.archive.rawValue, title: strings.ChatList_ArchiveAction, icon: archiveIcon, color: theme.list.itemDisclosureActions.inactive.fillColor, textColor: theme.list.itemDisclosureActions.inactive.foregroundColor)) } - } else { + } else if canUnarchive { options.append(ItemListRevealOption(key: RevealOptionKey.unarchive.rawValue, title: strings.ChatList_UnarchiveAction, icon: unarchiveIcon, color: theme.list.itemDisclosureActions.inactive.fillColor, textColor: theme.list.itemDisclosureActions.inactive.foregroundColor)) } }