Fix duplicated stickers.

GitOrigin-RevId: 138fddeb69af48ce77a6e3005e7d356165b897f9
This commit is contained in:
levlam 2018-07-31 23:48:54 +03:00
parent 7626c1a6dc
commit 6dd751ab10
2 changed files with 10 additions and 2 deletions

View File

@ -1638,7 +1638,12 @@ void StickersManager::on_get_messages_sticker_set(int64 sticker_set_id,
stickers.push_back(it->second);
s->sticker_emojis_map_[it->second].push_back(pack->emoticon_);
}
s->emoji_stickers_map_.emplace(remove_emoji_modifiers(pack->emoticon_), std::move(stickers));
auto &sticker_ids = s->emoji_stickers_map_[remove_emoji_modifiers(pack->emoticon_)];
for (auto sticker_id : stickers) {
if (std::find(sticker_ids.begin(), sticker_ids.end(), sticker_id) == sticker_ids.end()) {
sticker_ids.push_back(sticker_id);
}
}
}
update_sticker_set(s);

View File

@ -225,7 +225,10 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, T &parser) {
vector<string> emojis;
parse(emojis, parser);
for (auto &emoji : emojis) {
sticker_set->emoji_stickers_map_[remove_emoji_modifiers(emoji)].push_back(sticker_id);
auto &sticker_ids = sticker_set->emoji_stickers_map_[remove_emoji_modifiers(emoji)];
if (sticker_ids.empty() || sticker_ids.back() != sticker_id) {
sticker_ids.push_back(sticker_id);
}
}
sticker_set->sticker_emojis_map_[sticker_id] = std::move(emojis);
}