2022-08-30 15:21:14 +00:00
|
|
|
/*
|
|
|
|
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 Ui::Text {
|
|
|
|
class CustomEmoji;
|
|
|
|
} // namespace Ui::Text
|
|
|
|
|
|
|
|
namespace Main {
|
|
|
|
class Session;
|
|
|
|
} // namespace Main
|
|
|
|
|
|
|
|
namespace Data {
|
|
|
|
|
|
|
|
class DocumentMedia;
|
|
|
|
class Session;
|
|
|
|
|
|
|
|
class EmojiStatuses final {
|
|
|
|
public:
|
|
|
|
explicit EmojiStatuses(not_null<Session*> owner);
|
|
|
|
~EmojiStatuses();
|
|
|
|
|
|
|
|
[[nodiscard]] Session &owner() const {
|
|
|
|
return *_owner;
|
|
|
|
}
|
|
|
|
[[nodiscard]] Main::Session &session() const;
|
|
|
|
|
|
|
|
void refreshRecent();
|
|
|
|
void refreshRecentDelayed();
|
|
|
|
void refreshDefault();
|
2022-09-02 11:17:52 +00:00
|
|
|
void refreshColored();
|
2022-08-30 15:21:14 +00:00
|
|
|
|
|
|
|
enum class Type {
|
|
|
|
Recent,
|
|
|
|
Default,
|
2022-09-02 11:17:52 +00:00
|
|
|
Colored,
|
2022-08-30 15:21:14 +00:00
|
|
|
};
|
|
|
|
[[nodiscard]] const std::vector<DocumentId> &list(Type type) const;
|
|
|
|
|
|
|
|
[[nodiscard]] rpl::producer<> recentUpdates() const;
|
|
|
|
[[nodiscard]] rpl::producer<> defaultUpdates() const;
|
2022-09-02 11:17:52 +00:00
|
|
|
[[nodiscard]] rpl::producer<> coloredUpdates() const;
|
2022-08-30 15:21:14 +00:00
|
|
|
|
2022-09-01 19:24:46 +00:00
|
|
|
void set(DocumentId id, TimeId until = 0);
|
2022-08-30 15:21:14 +00:00
|
|
|
[[nodiscard]] bool setting() const;
|
|
|
|
|
2022-09-01 05:58:04 +00:00
|
|
|
void registerAutomaticClear(not_null<UserData*> user, TimeId until);
|
|
|
|
|
2022-08-30 15:21:14 +00:00
|
|
|
private:
|
|
|
|
void requestRecent();
|
|
|
|
void requestDefault();
|
2022-09-02 11:17:52 +00:00
|
|
|
void requestColored();
|
2022-08-30 15:21:14 +00:00
|
|
|
|
|
|
|
void updateRecent(const MTPDaccount_emojiStatuses &data);
|
|
|
|
void updateDefault(const MTPDaccount_emojiStatuses &data);
|
2022-09-02 11:17:52 +00:00
|
|
|
void updateColored(const MTPDmessages_stickerSet &data);
|
2022-08-30 15:21:14 +00:00
|
|
|
|
2022-09-30 09:37:34 +00:00
|
|
|
void processClearingIn(TimeId wait);
|
2022-09-01 05:58:04 +00:00
|
|
|
void processClearing();
|
|
|
|
|
2022-08-30 15:21:14 +00:00
|
|
|
const not_null<Session*> _owner;
|
|
|
|
|
|
|
|
std::vector<DocumentId> _recent;
|
|
|
|
std::vector<DocumentId> _default;
|
2022-09-02 11:17:52 +00:00
|
|
|
std::vector<DocumentId> _colored;
|
2022-08-30 15:21:14 +00:00
|
|
|
rpl::event_stream<> _recentUpdated;
|
|
|
|
rpl::event_stream<> _defaultUpdated;
|
2022-09-02 11:17:52 +00:00
|
|
|
rpl::event_stream<> _coloredUpdated;
|
2022-08-30 15:21:14 +00:00
|
|
|
|
|
|
|
mtpRequestId _recentRequestId = 0;
|
|
|
|
bool _recentRequestScheduled = false;
|
|
|
|
uint64 _recentHash = 0;
|
|
|
|
|
|
|
|
base::Timer _defaultRefreshTimer;
|
|
|
|
mtpRequestId _defaultRequestId = 0;
|
|
|
|
uint64 _defaultHash = 0;
|
|
|
|
|
2022-09-02 11:17:52 +00:00
|
|
|
mtpRequestId _coloredRequestId = 0;
|
|
|
|
|
2022-08-30 15:21:14 +00:00
|
|
|
mtpRequestId _sentRequestId = 0;
|
|
|
|
|
2022-09-30 09:37:34 +00:00
|
|
|
base::flat_map<not_null<UserData*>, TimeId> _clearing;
|
2022-09-01 05:58:04 +00:00
|
|
|
base::Timer _clearingTimer;
|
|
|
|
|
2022-08-30 15:21:14 +00:00
|
|
|
rpl::lifetime _lifetime;
|
|
|
|
|
|
|
|
};
|
|
|
|
|
2022-09-01 05:58:04 +00:00
|
|
|
struct EmojiStatusData {
|
|
|
|
DocumentId id = 0;
|
|
|
|
TimeId until = 0;
|
|
|
|
};
|
|
|
|
[[nodiscard]] EmojiStatusData ParseEmojiStatus(const MTPEmojiStatus &status);
|
|
|
|
|
2022-08-30 15:21:14 +00:00
|
|
|
} // namespace Data
|