/* 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 "history/history_item.h" class History; namespace Main { class Session; } // namespace Main namespace Data { class Session; struct MessagesSlice; class ScheduledMessages final { public: explicit ScheduledMessages(not_null owner); ScheduledMessages(const ScheduledMessages &other) = delete; ScheduledMessages &operator=(const ScheduledMessages &other) = delete; ~ScheduledMessages(); [[nodiscard]] MsgId lookupId(not_null item) const; [[nodiscard]] int count(not_null history) const; void apply(const MTPDupdateNewScheduledMessage &update); void apply(const MTPDupdateDeleteScheduledMessages &update); void apply( const MTPDupdateMessageID &update, not_null local); void appendSending(not_null item); void removeSending(not_null item); [[nodiscard]] rpl::producer<> updates(not_null history); [[nodiscard]] Data::MessagesSlice list(not_null history); private: using OwnedItem = std::unique_ptr; struct List { std::vector items; base::flat_map> itemById; base::flat_map, MsgId> idByItem; }; struct Request { mtpRequestId requestId = 0; }; void request(not_null history); void parse( not_null history, const MTPmessages_Messages &list); HistoryItem *append( not_null history, List &list, const MTPMessage &message); void clearNotSending(not_null history); void updated( not_null history, const base::flat_set> &added, const base::flat_set> &clear); void sort(List &list); void remove(not_null item); [[nodiscard]] int32 countListHash(const List &list) const; const not_null _session; base::flat_map, List> _data; base::flat_map, Request> _requests; rpl::event_stream> _updates; rpl::lifetime _lifetime; }; } // namespace Data