diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 234782058..d8d262f69 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -1401,6 +1401,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_stickers_search_sets" = "Search sticker sets"; "lng_stickers_nothing_found" = "No stickers found"; "lng_stickers_remove_pack_confirm" = "Remove"; +"lng_stickers_archive_pack" = "Archive Stickers"; +"lng_stickers_has_been_archived" = "Sticker pack has been archived."; "lng_in_dlg_photo" = "Photo"; "lng_in_dlg_album" = "Album"; diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 5fbec8d49..343576326 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -198,6 +198,38 @@ void StickerSetBox::copyStickersLink() { QGuiApplication::clipboard()->setText(url); } +void StickerSetBox::archiveStickers() { + const auto weak = base::make_weak(_controller.get()); + const auto setId = _set.c_inputStickerSetID().vid().v; + _controller->session().api().request(MTPmessages_InstallStickerSet( + _set, + MTP_boolTrue() + )).done([=](const MTPmessages_StickerSetInstallResult &result) { + const auto controller = weak.get(); + if (!controller) { + return; + } + if (result.type() == mtpc_messages_stickerSetInstallResultSuccess) { + Ui::Toast::Show(tr::lng_stickers_has_been_archived(tr::now)); + + const auto &session = controller->session(); + auto &order = session.data().stickers().setsOrderRef(); + const auto index = order.indexOf(setId); + if (index == -1) { + return; + } + order.removeAt(index); + + session.local().writeInstalledStickers(); + session.local().writeArchivedStickers(); + + session.data().stickers().notifyUpdated(); + } + }).fail([](const MTP::Error &error) { + Ui::Toast::Show(Lang::Hard::ServerError()); + }).send(); +} + void StickerSetBox::updateTitleAndButtons() { setTitle(_inner->title()); updateButtons(); @@ -237,6 +269,24 @@ void StickerSetBox::updateButtons() { }; addButton(tr::lng_stickers_share_pack(), std::move(share)); addButton(tr::lng_cancel(), [=] { closeBox(); }); + + if (!_inner->shortName().isEmpty()) { + const auto top = addTopButton(st::infoTopBarMenu); + const auto archive = [=] { + archiveStickers(); + closeBox(); + }; + const auto menu = + std::make_shared>(); + top->setClickedCallback([=] { + *menu = base::make_unique_q(top); + (*menu)->addAction( + tr::lng_stickers_archive_pack(tr::now), + archive); + (*menu)->popup(QCursor::pos()); + return true; + }); + } } } else { addButton(tr::lng_cancel(), [=] { closeBox(); }); diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.h b/Telegram/SourceFiles/boxes/sticker_set_box.h index b480f5885..a5c105531 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.h +++ b/Telegram/SourceFiles/boxes/sticker_set_box.h @@ -42,6 +42,7 @@ private: void updateButtons(); void addStickers(); void copyStickersLink(); + void archiveStickers(); const not_null _controller; MTPInputStickerSet _set;