diff --git a/Telegram/Telegram-iOS/en.lproj/Localizable.strings b/Telegram/Telegram-iOS/en.lproj/Localizable.strings index 3b86c42f45..cd4bba858c 100644 --- a/Telegram/Telegram-iOS/en.lproj/Localizable.strings +++ b/Telegram/Telegram-iOS/en.lproj/Localizable.strings @@ -8932,3 +8932,5 @@ Sorry for the inconvenience."; "VoiceOver.Chat.ReplyingToMessage" = "In reply to message: %@"; "MediaPicker.VoiceOver.Camera" = "Camera"; + +"ChatList.ReadAll" = "Read All"; diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index 90f855857a..0237950beb 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -1513,6 +1513,26 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController }) }))) + if let filterEntries = strongSelf.tabContainerData?.0 { + for filter in filterEntries { + if case let .filter(filterId, _, unread) = filter, filterId == id { + if unread.value > 0 { + items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.ChatList_ReadAll, textColor: .primary, icon: { theme in + return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/MarkAsRead"), color: theme.contextMenu.primaryColor) + }, action: { c, f in + c.dismiss(completion: { + guard let strongSelf = self else { + return + } + strongSelf.readAllInFilter(id: id) + }) + }))) + } + break + } + } + } + items.append(.action(ContextMenuActionItem(text: strongSelf.presentationData.strings.ChatList_RemoveFolder, textColor: .destructive, icon: { theme in return generateTintedImage(image: UIImage(bundleImageName: "Chat/Context Menu/Delete"), color: theme.contextMenu.destructiveColor) }, action: { c, f in @@ -2579,6 +2599,25 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController }) } + private func readAllInFilter(id: Int32) { + guard case let .chatList(groupId) = self.chatListDisplayNode.effectiveContainerNode.location else { + return + } + for filter in self.chatListDisplayNode.mainContainerNode.availableFilters { + if case let .filter(filter) = filter, case let .filter(filterId, _, _, data) = filter, filterId == id { + let filterPredicate = chatListFilterPredicate(filter: data) + var markItems: [(groupId: EngineChatList.Group, filterPredicate: ChatListFilterPredicate?)] = [] + markItems.append((groupId, filterPredicate)) + for additionalGroupId in filterPredicate.includeAdditionalPeerGroupIds { + markItems.append((EngineChatList.Group(additionalGroupId), filterPredicate)) + } + + let _ = self.context.engine.messages.markAllChatsAsReadInteractively(items: markItems).start() + break + } + } + } + private func askForFilterRemoval(id: Int32) { let actionSheet = ActionSheetController(presentationData: self.presentationData)