From 25f18c0c3af5aeab087ae335c9ab5f80ddf80e9e Mon Sep 17 00:00:00 2001 From: John Preston Date: Sat, 5 Aug 2017 14:38:59 +0200 Subject: [PATCH] Allow to fave stickers from deleted sticker packs. --- .../SourceFiles/chat_helpers/stickers.cpp | 26 +++++++++++++------ 1 file changed, 18 insertions(+), 8 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/stickers.cpp b/Telegram/SourceFiles/chat_helpers/stickers.cpp index f4833bc09..9840e8b91 100644 --- a/Telegram/SourceFiles/chat_helpers/stickers.cpp +++ b/Telegram/SourceFiles/chat_helpers/stickers.cpp @@ -240,7 +240,17 @@ void SetIsFaved(gsl::not_null document, const std::vectorsticker()->set), rpcDone([document](const MTPmessages_StickerSet &result) { + auto addAnyway = [document](std::vector> list) { + if (list.empty()) { + if (auto sticker = document->sticker()) { + if (auto emoji = Ui::Emoji::Find(sticker->alt)) { + list.push_back(emoji); + } + } + } + SetIsFaved(document, &list); + }; + MTP::send(MTPmessages_GetStickerSet(document->sticker()->set), rpcDone([document, addAnyway](const MTPmessages_StickerSet &result) { Expects(result.type() == mtpc_messages_stickerSet); auto list = std::vector>(); auto &d = result.c_messages_stickerSet(); @@ -256,14 +266,14 @@ void SetIsFaved(gsl::not_null document, const std::vectorsticker()) { - if (auto emoji = Ui::Emoji::Find(sticker->alt)) { - list.push_back(emoji); - } - } + addAnyway(std::move(list)); + }), rpcFail([addAnyway](const RPCError &error) { + if (MTP::isDefaultHandledError(error)) { + return false; } - SetIsFaved(document, &list); + // Perhaps this is a deleted sticker pack. Add anyway. + addAnyway(std::vector>()); + return true; })); return; }