Fix infinite group set requests on bad API responses.

This commit is contained in:
John Preston 2019-03-26 10:38:54 +04:00
parent 9b247ce5ed
commit 8aaa70a05a
2 changed files with 39 additions and 29 deletions

View file

@ -2015,7 +2015,9 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
if (canEdit && hidden) {
removeHiddenForGroup();
}
if (_megagroupSet->mgInfo->stickerSet.type() == mtpc_inputStickerSetID) {
if (_megagroupSet->mgInfo->stickerSet.type() != mtpc_inputStickerSetID) {
return;
}
auto &set = _megagroupSet->mgInfo->stickerSet.c_inputStickerSetID();
auto &sets = Auth().data().stickerSets();
auto it = sets.constFind(set.vid.v);
@ -2039,14 +2041,21 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
it->stickers);
}
return;
}
}
if (!isShownHere(hidden)) {
} else if (!isShownHere(hidden)
|| _megagroupSetIdRequested == set.vid.v) {
return;
}
request(MTPmessages_GetStickerSet(_megagroupSet->mgInfo->stickerSet)).done([this](const MTPmessages_StickerSet &result) {
if (auto set = Stickers::FeedSetFull(result)) {
_megagroupSetIdRequested = set.vid.v;
request(MTPmessages_GetStickerSet(
_megagroupSet->mgInfo->stickerSet
)).done([=](const MTPmessages_StickerSet &result) {
if (const auto set = Stickers::FeedSetFull(result)) {
refreshStickers();
if (set->id == _megagroupSetIdRequested) {
_megagroupSetIdRequested = 0;
} else {
LOG(("API Error: Got different set."));
}
}
}).send();
}

View file

@ -246,6 +246,7 @@ private:
void showPreview();
ChannelData *_megagroupSet = nullptr;
uint64 _megagroupSetIdRequested = 0;
std::vector<Set> _mySets;
std::vector<Set> _featuredSets;
std::vector<Set> _searchSets;