/* This file is part of Telegram Desktop, the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ #pragma once #include "dialogs/dialogs_main_list.h" #include "ui/text/text.h" class ChannelData; class History; class PeerData; namespace Data { struct CommunityLinkedPeer { not_null peer; std::optional visible; bool canViewHistory = false; friend inline bool operator==( const CommunityLinkedPeer &, const CommunityLinkedPeer &) = default; }; [[nodiscard]] bool IsCommunityChatViewable(const CommunityLinkedPeer &linked); [[nodiscard]] ChannelId PeerLinkedCommunityId(not_null peer); [[nodiscard]] bool CommunityChatJoined(not_null peer); [[nodiscard]] bool CommunityChatJoined(not_null history); class CommunityInfo final { public: explicit CommunityInfo(not_null channel); [[nodiscard]] not_null channel() const { return _channel; } void applyLinkedPeers(const QVector &list); [[nodiscard]] auto linkedPeers() const -> const std::vector & { return _linkedPeers; } [[nodiscard]] rpl::producer<> linkedPeersValue() const; [[nodiscard]] rpl::producer<> refreshed() const; [[nodiscard]] bool isHidden(not_null peer) const; [[nodiscard]] bool collapsedInDialogs() const; void collapsedChanged(); void ensureRowInChatList(); void registerOne(not_null history); void unregisterOne(not_null history); void refreshOneMembership(not_null history); [[nodiscard]] auto histories() const -> const base::flat_set> & { return _histories; } [[nodiscard]] not_null chatsList(); [[nodiscard]] TimeId chatsListDate() const { return _chatsListDate; } void oneChatsListDateChanged(TimeId was, TimeId now); void oneListMessageChanged(); void oneUnreadStateChanged(); [[nodiscard]] auto lastHistories() const -> const std::vector> & { return _lastHistories; } void validateListEntryCache(); [[nodiscard]] const Ui::Text::String &listEntryCache() const { return _listEntryCache; } private: void memberAdded(not_null history); void recountChatsListDate(); void reorderLastHistories(); void updateRowSortPosition(); void repaintRow(); void moveHistory(not_null history, bool nowCollapsed); const not_null _channel; std::vector _linkedPeers; base::flat_set> _hiddenPeers; rpl::event_stream<> _linkedPeersChanges; rpl::event_stream<> _refreshed; // Member chats (CommunityChatJoined()) — joined channels and bot // chats with messages; the source of the grouped row's aggregated // badge / date / preview. Non-member linked chats whose History is // loaded are tracked separately in _otherHistories so they never // leak into those aggregates. base::flat_set> _histories; base::flat_set> _otherHistories; std::vector> _lastHistories; Ui::Text::String _listEntryCache; int _listEntryCacheVersion = 0; int _chatListViewVersion = 0; TimeId _chatsListDate = 0; Dialogs::MainList _chatsList; rpl::lifetime _lifetime; }; } // namespace Data