/* 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/timer.h" namespace Main { class Session; } // namespace Main namespace Ui { struct EmojiGroup; } // namespace Ui namespace Data { class DocumentMedia; class Session; class EmojiStatuses final { public: explicit EmojiStatuses(not_null owner); ~EmojiStatuses(); [[nodiscard]] Session &owner() const { return *_owner; } [[nodiscard]] Main::Session &session() const; void refreshRecent(); void refreshRecentDelayed(); void refreshDefault(); void refreshColored(); void refreshChannelDefault(); void refreshChannelColored(); enum class Type { Recent, Default, Colored, ChannelDefault, ChannelColored, }; [[nodiscard]] const std::vector &list(Type type) const; [[nodiscard]] rpl::producer<> recentUpdates() const; [[nodiscard]] rpl::producer<> defaultUpdates() const; [[nodiscard]] rpl::producer<> channelDefaultUpdates() const; void set(DocumentId id, TimeId until = 0); void set(not_null peer, DocumentId id, TimeId until = 0); void registerAutomaticClear(not_null peer, TimeId until); using Groups = std::vector; [[nodiscard]] rpl::producer emojiGroupsValue() const; [[nodiscard]] rpl::producer statusGroupsValue() const; [[nodiscard]] rpl::producer stickerGroupsValue() const; [[nodiscard]] rpl::producer profilePhotoGroupsValue() const; void requestEmojiGroups(); void requestStatusGroups(); void requestStickerGroups(); void requestProfilePhotoGroups(); private: struct GroupsType { rpl::variable data; mtpRequestId requestId = 0; int32 hash = 0; }; void requestRecent(); void requestDefault(); void requestColored(); void requestChannelDefault(); void requestChannelColored(); void updateRecent(const MTPDaccount_emojiStatuses &data); void updateDefault(const MTPDaccount_emojiStatuses &data); void updateColored(const MTPDmessages_stickerSet &data); void updateChannelDefault(const MTPDaccount_emojiStatuses &data); void updateChannelColored(const MTPDmessages_stickerSet &data); void processClearingIn(TimeId wait); void processClearing(); template void requestGroups(not_null type, Request &&request); const not_null _owner; std::vector _recent; std::vector _default; std::vector _colored; std::vector _channelDefault; std::vector _channelColored; rpl::event_stream<> _recentUpdated; rpl::event_stream<> _defaultUpdated; rpl::event_stream<> _coloredUpdated; rpl::event_stream<> _channelDefaultUpdated; rpl::event_stream<> _channelColoredUpdated; mtpRequestId _recentRequestId = 0; bool _recentRequestScheduled = false; uint64 _recentHash = 0; mtpRequestId _defaultRequestId = 0; uint64 _defaultHash = 0; mtpRequestId _coloredRequestId = 0; mtpRequestId _channelDefaultRequestId = 0; uint64 _channelDefaultHash = 0; mtpRequestId _channelColoredRequestId = 0; base::flat_map, mtpRequestId> _sentRequests; base::flat_map, TimeId> _clearing; base::Timer _clearingTimer; GroupsType _emojiGroups; GroupsType _statusGroups; GroupsType _stickerGroups; GroupsType _profilePhotoGroups; rpl::lifetime _lifetime; }; struct EmojiStatusData { DocumentId id = 0; TimeId until = 0; }; [[nodiscard]] EmojiStatusData ParseEmojiStatus(const MTPEmojiStatus &status); } // namespace Data