mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-18 15:17:07 +02:00
Added ability to force request favorite stickers.
This commit is contained in:
parent
06f2b23687
commit
3cc92e01fe
4 changed files with 38 additions and 26 deletions
Telegram/SourceFiles
|
@ -128,7 +128,7 @@ mtpRequestId EditMessage(
|
|||
}
|
||||
|
||||
if (updateRecentStickers) {
|
||||
api->requestRecentStickersForce(true);
|
||||
api->requestSpecialStickersForce(false, false, true);
|
||||
}
|
||||
}).fail([=](const MTP::Error &error, mtpRequestId requestId) {
|
||||
if constexpr (ErrorWithId<FailCallback>) {
|
||||
|
|
|
@ -2585,7 +2585,7 @@ void ApiWrap::gotWebPages(ChannelData *channel, const MTPmessages_Messages &resu
|
|||
void ApiWrap::updateStickers() {
|
||||
const auto now = crl::now();
|
||||
requestStickers(now);
|
||||
requestRecentStickers(now);
|
||||
requestRecentStickers(now, false);
|
||||
requestFavedStickers(now);
|
||||
requestFeaturedStickers(now);
|
||||
}
|
||||
|
@ -2607,8 +2607,15 @@ void ApiWrap::updateCustomEmoji() {
|
|||
requestFeaturedEmoji(now);
|
||||
}
|
||||
|
||||
void ApiWrap::requestRecentStickersForce(bool attached) {
|
||||
requestRecentStickersWithHash(0, attached);
|
||||
void ApiWrap::requestSpecialStickersForce(
|
||||
bool faved,
|
||||
bool recent,
|
||||
bool attached) {
|
||||
if (faved) {
|
||||
requestFavedStickers(std::nullopt);
|
||||
} else if (recent || attached) {
|
||||
requestRecentStickers(std::nullopt, attached);
|
||||
}
|
||||
}
|
||||
|
||||
void ApiWrap::setGroupStickerSet(
|
||||
|
@ -2761,18 +2768,17 @@ void ApiWrap::requestCustomEmoji(TimeId now) {
|
|||
}).send();
|
||||
}
|
||||
|
||||
void ApiWrap::requestRecentStickers(TimeId now, bool attached) {
|
||||
const auto needed = attached
|
||||
? _session->data().stickers().recentAttachedUpdateNeeded(now)
|
||||
: _session->data().stickers().recentUpdateNeeded(now);
|
||||
void ApiWrap::requestRecentStickers(
|
||||
std::optional<TimeId> now,
|
||||
bool attached) {
|
||||
const auto needed = !now
|
||||
? true
|
||||
: attached
|
||||
? _session->data().stickers().recentAttachedUpdateNeeded(*now)
|
||||
: _session->data().stickers().recentUpdateNeeded(*now);
|
||||
if (!needed) {
|
||||
return;
|
||||
}
|
||||
requestRecentStickersWithHash(
|
||||
Api::CountRecentStickersHash(_session, attached), attached);
|
||||
}
|
||||
|
||||
void ApiWrap::requestRecentStickersWithHash(uint64 hash, bool attached) {
|
||||
const auto requestId = [=]() -> mtpRequestId & {
|
||||
return attached
|
||||
? _recentAttachedStickersUpdateRequest
|
||||
|
@ -2795,7 +2801,7 @@ void ApiWrap::requestRecentStickersWithHash(uint64 hash, bool attached) {
|
|||
: MTPmessages_getRecentStickers::Flags(0);
|
||||
requestId() = request(MTPmessages_GetRecentStickers(
|
||||
MTP_flags(flags),
|
||||
MTP_long(hash)
|
||||
MTP_long(now ? Api::CountRecentStickersHash(_session, attached) : 0)
|
||||
)).done([=](const MTPmessages_RecentStickers &result) {
|
||||
finish();
|
||||
|
||||
|
@ -2822,13 +2828,15 @@ void ApiWrap::requestRecentStickersWithHash(uint64 hash, bool attached) {
|
|||
}).send();
|
||||
}
|
||||
|
||||
void ApiWrap::requestFavedStickers(TimeId now) {
|
||||
if (!_session->data().stickers().favedUpdateNeeded(now)
|
||||
|| _favedStickersUpdateRequest) {
|
||||
return;
|
||||
void ApiWrap::requestFavedStickers(std::optional<TimeId> now) {
|
||||
if (now) {
|
||||
if (!_session->data().stickers().favedUpdateNeeded(*now)
|
||||
|| _favedStickersUpdateRequest) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
_favedStickersUpdateRequest = request(MTPmessages_GetFavedStickers(
|
||||
MTP_long(Api::CountFavedStickersHash(_session))
|
||||
MTP_long(now ? Api::CountFavedStickersHash(_session) : 0)
|
||||
)).done([=](const MTPmessages_FavedStickers &result) {
|
||||
_session->data().stickers().setLastFavedUpdate(crl::now());
|
||||
_favedStickersUpdateRequest = 0;
|
||||
|
@ -4204,7 +4212,7 @@ void ApiWrap::sendMediaWithRandomId(
|
|||
), [=](const MTPUpdates &result, const MTP::Response &response) {
|
||||
if (done) done(true);
|
||||
if (updateRecentStickers) {
|
||||
requestRecentStickersForce(true);
|
||||
requestRecentStickers(std::nullopt, true);
|
||||
}
|
||||
}, [=](const MTP::Error &error, const MTP::Response &response) {
|
||||
if (done) done(false);
|
||||
|
|
|
@ -244,7 +244,10 @@ public:
|
|||
void updateSavedGifs();
|
||||
void updateMasks();
|
||||
void updateCustomEmoji();
|
||||
void requestRecentStickersForce(bool attached = false);
|
||||
void requestSpecialStickersForce(
|
||||
bool faved,
|
||||
bool recent,
|
||||
bool attached);
|
||||
void setGroupStickerSet(
|
||||
not_null<ChannelData*> megagroup,
|
||||
const StickerSetIdentifier &set);
|
||||
|
@ -477,9 +480,10 @@ private:
|
|||
void requestStickers(TimeId now);
|
||||
void requestMasks(TimeId now);
|
||||
void requestCustomEmoji(TimeId now);
|
||||
void requestRecentStickers(TimeId now, bool attached = false);
|
||||
void requestRecentStickersWithHash(uint64 hash, bool attached = false);
|
||||
void requestFavedStickers(TimeId now);
|
||||
void requestRecentStickers(
|
||||
std::optional<TimeId> now,
|
||||
bool attached);
|
||||
void requestFavedStickers(std::optional<TimeId> now);
|
||||
void requestFeaturedStickers(TimeId now);
|
||||
void requestFeaturedEmoji(TimeId now);
|
||||
void requestSavedGifs(TimeId now);
|
||||
|
|
|
@ -228,7 +228,7 @@ void Stickers::incrementSticker(not_null<DocumentData*> document) {
|
|||
auto index = set->stickers.indexOf(document);
|
||||
if (index > 0) {
|
||||
if (set->dates.empty()) {
|
||||
session().api().requestRecentStickersForce();
|
||||
session().api().requestSpecialStickersForce(false, true, false);
|
||||
} else {
|
||||
Assert(set->dates.size() == set->stickers.size());
|
||||
set->dates.erase(set->dates.begin() + index);
|
||||
|
@ -260,7 +260,7 @@ void Stickers::incrementSticker(not_null<DocumentData*> document) {
|
|||
set->emoji[emoji].push_front(document);
|
||||
}
|
||||
} else {
|
||||
session().api().requestRecentStickersForce();
|
||||
session().api().requestSpecialStickersForce(false, true, false);
|
||||
}
|
||||
|
||||
writeRecentStickers = true;
|
||||
|
|
Loading…
Add table
Reference in a new issue