diff --git a/submodules/ChatListUI/Sources/ChatListController.swift b/submodules/ChatListUI/Sources/ChatListController.swift index b9b1d45a9f..5242db897b 100644 --- a/submodules/ChatListUI/Sources/ChatListController.swift +++ b/submodules/ChatListUI/Sources/ChatListController.swift @@ -1967,17 +1967,29 @@ public class ChatListControllerImpl: TelegramBaseController, ChatListController self.rawStoryArchiveSubscriptions = rawStoryArchiveSubscriptions - let hasUnseenArchive: Bool? + let archiveStoryState: ChatListNodeState.StoryState? if rawStoryArchiveSubscriptions.items.isEmpty { - hasUnseenArchive = nil + archiveStoryState = nil } else { - hasUnseenArchive = rawStoryArchiveSubscriptions.items.contains(where: { $0.hasUnseen }) + var unseenCount = 0 + for item in rawStoryArchiveSubscriptions.items { + if item.hasUnseen { + unseenCount += 1 + } + } + archiveStoryState = ChatListNodeState.StoryState( + stats: EngineChatList.StoryStats( + totalCount: rawStoryArchiveSubscriptions.items.count, + unseenCount: unseenCount + ), + hasUnseenCloseFriends: rawStoryArchiveSubscriptions.items.contains(where: { $0.hasUnseenCloseFriends }) + ) } self.chatListDisplayNode.mainContainerNode.currentItemNode.updateState { chatListState in var chatListState = chatListState - chatListState.hasUnseenArchiveStories = hasUnseenArchive + chatListState.archiveStoryState = archiveStoryState return chatListState } diff --git a/submodules/ChatListUI/Sources/Node/ChatListNode.swift b/submodules/ChatListUI/Sources/Node/ChatListNode.swift index 1d7337e6c6..834a1d8bbf 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNode.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNode.swift @@ -251,7 +251,7 @@ public struct ChatListNodeState: Equatable { public var foundPeers: [(EnginePeer, EnginePeer?)] public var selectedPeerMap: [EnginePeer.Id: EnginePeer] public var selectedThreadIds: Set - public var hasUnseenArchiveStories: Bool? + public var archiveStoryState: StoryState? public init( presentationData: ChatListPresentationData, @@ -267,7 +267,7 @@ public struct ChatListNodeState: Equatable { hiddenItemShouldBeTemporaryRevealed: Bool, hiddenPsaPeerId: EnginePeer.Id?, selectedThreadIds: Set, - hasUnseenArchiveStories: Bool? + archiveStoryState: StoryState? ) { self.presentationData = presentationData self.editing = editing @@ -282,7 +282,7 @@ public struct ChatListNodeState: Equatable { self.hiddenItemShouldBeTemporaryRevealed = hiddenItemShouldBeTemporaryRevealed self.hiddenPsaPeerId = hiddenPsaPeerId self.selectedThreadIds = selectedThreadIds - self.hasUnseenArchiveStories = hasUnseenArchiveStories + self.archiveStoryState = archiveStoryState } public static func ==(lhs: ChatListNodeState, rhs: ChatListNodeState) -> Bool { @@ -325,7 +325,7 @@ public struct ChatListNodeState: Equatable { if lhs.selectedThreadIds != rhs.selectedThreadIds { return false } - if lhs.hasUnseenArchiveStories != rhs.hasUnseenArchiveStories { + if lhs.archiveStoryState != rhs.archiveStoryState { return false } return true @@ -1251,7 +1251,7 @@ public final class ChatListNode: ListView { isSelecting = true } - self.currentState = ChatListNodeState(presentationData: ChatListPresentationData(theme: theme, fontSize: fontSize, strings: strings, dateTimeFormat: dateTimeFormat, nameSortOrder: nameSortOrder, nameDisplayOrder: nameDisplayOrder, disableAnimations: disableAnimations), editing: isSelecting, peerIdWithRevealedOptions: nil, selectedPeerIds: Set(), foundPeers: [], selectedPeerMap: [:], selectedAdditionalCategoryIds: Set(), peerInputActivities: nil, pendingRemovalItemIds: Set(), pendingClearHistoryPeerIds: Set(), hiddenItemShouldBeTemporaryRevealed: false, hiddenPsaPeerId: nil, selectedThreadIds: Set(), hasUnseenArchiveStories: nil) + self.currentState = ChatListNodeState(presentationData: ChatListPresentationData(theme: theme, fontSize: fontSize, strings: strings, dateTimeFormat: dateTimeFormat, nameSortOrder: nameSortOrder, nameDisplayOrder: nameDisplayOrder, disableAnimations: disableAnimations), editing: isSelecting, peerIdWithRevealedOptions: nil, selectedPeerIds: Set(), foundPeers: [], selectedPeerMap: [:], selectedAdditionalCategoryIds: Set(), peerInputActivities: nil, pendingRemovalItemIds: Set(), pendingClearHistoryPeerIds: Set(), hiddenItemShouldBeTemporaryRevealed: false, hiddenPsaPeerId: nil, selectedThreadIds: Set(), archiveStoryState: nil) self.statePromise = ValuePromise(self.currentState, ignoreRepeated: true) self.theme = theme diff --git a/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift b/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift index 12b7dab724..16140b6b2e 100644 --- a/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift +++ b/submodules/ChatListUI/Sources/Node/ChatListNodeEntries.swift @@ -834,13 +834,8 @@ func chatListNodeEntriesForView(view: EngineChatList, state: ChatListNodeState, for groupReference in view.groupItems { let messageIndex = EngineMessage.Index(id: EngineMessage.Id(peerId: EnginePeer.Id(0), namespace: 0, id: 0), timestamp: 1) var mappedStoryState: ChatListNodeState.StoryState? - if let hasUnseenArchiveStories = state.hasUnseenArchiveStories { - mappedStoryState = ChatListNodeState.StoryState( - stats: EngineChatList.StoryStats( - totalCount: 1, unseenCount: hasUnseenArchiveStories ? 1 : 0 - ), - hasUnseenCloseFriends: false - ) + if let archiveStoryState = state.archiveStoryState { + mappedStoryState = archiveStoryState } result.append(.GroupReferenceEntry(ChatListNodeEntry.GroupReferenceEntryData( index: .chatList(EngineChatList.Item.Index.ChatList(pinningIndex: pinningIndex, messageIndex: messageIndex)),