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

View File

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