/* 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 "base/weak_ptr.h" class History; class HistoryService; namespace Data { class Histories; struct MessagePosition; struct MessagesSlice; struct MessageUpdate; class RepliesList final : public base::has_weak_ptr { public: RepliesList(not_null history, MsgId rootId); ~RepliesList(); [[nodiscard]] rpl::producer source( MessagePosition aroundId, int limitBefore, int limitAfter); [[nodiscard]] rpl::producer fullCount() const; [[nodiscard]] std::optional fullUnreadCountAfter( MsgId readTillId, MsgId wasReadTillId, std::optional wasUnreadCountAfter) const; private: struct Viewer; HistoryItem *lookupRoot(); [[nodiscard]] Histories &histories(); [[nodiscard]] rpl::producer sourceFromServer( MessagePosition aroundId, int limitBefore, int limitAfter); void appendClientSideMessages(MessagesSlice &slice); [[nodiscard]] bool buildFromData(not_null viewer); [[nodiscard]] bool applyUpdate( not_null viewer, const MessageUpdate &update); void injectRootMessageAndReverse(not_null viewer); void injectRootMessage(not_null viewer); void injectRootDivider( not_null root, not_null slice); bool processMessagesIsEmpty(const MTPmessages_Messages &result); void loadAround(MsgId id); void loadBefore(); void loadAfter(); const not_null _history; const MsgId _rootId = 0; std::vector _list; std::optional _skippedBefore; std::optional _skippedAfter; rpl::variable> _fullCount; rpl::event_stream<> _partLoaded; std::optional _loadingAround; HistoryService *_divider = nullptr; bool _dividerWithComments = false; int _beforeId = 0; int _afterId = 0; }; } // namespace Data