2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Added ability to set emoji status for certain period of time.

This commit is contained in:
23rd
2022-09-01 22:24:46 +03:00
committed by John Preston
parent 9bb2bb09b9
commit fa4801ac94
10 changed files with 166 additions and 47 deletions

View File

@@ -239,14 +239,18 @@ void EmojiStatuses::updateColored(const MTPDmessages_stickerSet &data) {
_coloredUpdated.fire({});
}
void EmojiStatuses::set(DocumentId id) {
void EmojiStatuses::set(DocumentId id, TimeId until) {
auto &api = _owner->session().api();
if (_sentRequestId) {
api.request(base::take(_sentRequestId)).cancel();
}
_owner->session().user()->setEmojiStatus(id);
_owner->session().user()->setEmojiStatus(id, until);
_sentRequestId = api.request(MTPaccount_UpdateEmojiStatus(
id ? MTP_emojiStatus(MTP_long(id)) : MTP_emojiStatusEmpty()
!id
? MTP_emojiStatusEmpty()
: !until
? MTP_emojiStatus(MTP_long(id))
: MTP_emojiStatusUntil(MTP_long(id), MTP_int(until))
)).done([=] {
_sentRequestId = 0;
}).fail([=] {

View File

@@ -48,7 +48,7 @@ public:
[[nodiscard]] rpl::producer<> defaultUpdates() const;
[[nodiscard]] rpl::producer<> coloredUpdates() const;
void set(DocumentId id);
void set(DocumentId id, TimeId until = 0);
[[nodiscard]] bool setting() const;
void registerAutomaticClear(not_null<UserData*> user, TimeId until);