/* 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_indexed_list.h" #include "dialogs/dialogs_pinned_list.h" namespace Main { class Session; } // namespace Main namespace Dialogs { class MainList final { public: MainList( not_null session, FilterId filterId, rpl::producer pinnedLimit); bool empty() const; bool loaded() const; void setLoaded(bool loaded = true); void setAllAreMuted(bool allAreMuted = true); void clear(); RowsByLetter addEntry(const Key &key); void removeEntry(const Key &key); void unreadStateChanged( const UnreadState &wasState, const UnreadState &nowState); void unreadEntryChanged( const Dialogs::UnreadState &state, bool added); void updateCloudUnread(const MTPDdialogFolder &data); [[nodiscard]] bool cloudUnreadKnown() const; [[nodiscard]] UnreadState unreadState() const; [[nodiscard]] rpl::producer unreadStateChanges() const; [[nodiscard]] not_null indexed(); [[nodiscard]] not_null indexed() const; [[nodiscard]] not_null pinned(); [[nodiscard]] not_null pinned() const; void setCloudListSize(int size); [[nodiscard]] const rpl::variable &fullSize() const; private: void finalizeCloudUnread(); void recomputeFullListSize(); auto unreadStateChangeNotifier(bool notify) { const auto wasState = notify ? unreadState() : UnreadState(); return gsl::finally([=] { if (notify) { _unreadStateChanges.fire_copy(wasState); } }); } FilterId _filterId = 0; IndexedList _all; PinnedList _pinned; UnreadState _unreadState; UnreadState _cloudUnreadState; rpl::event_stream _unreadStateChanges; rpl::variable _fullListSize = 0; int _cloudListSize = 0; bool _loaded = false; bool _allAreMuted = false; rpl::lifetime _lifetime; }; } // namespace Dialogs