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