mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Add "Archive Sticker" into Sticker Box 3dots menu
This commit is contained in:
parent
680a9a7ca7
commit
ee156fc6a8
3 changed files with 53 additions and 0 deletions
|
@ -1401,6 +1401,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
"lng_stickers_search_sets" = "Search sticker sets";
|
"lng_stickers_search_sets" = "Search sticker sets";
|
||||||
"lng_stickers_nothing_found" = "No stickers found";
|
"lng_stickers_nothing_found" = "No stickers found";
|
||||||
"lng_stickers_remove_pack_confirm" = "Remove";
|
"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_photo" = "Photo";
|
||||||
"lng_in_dlg_album" = "Album";
|
"lng_in_dlg_album" = "Album";
|
||||||
|
|
|
@ -198,6 +198,38 @@ void StickerSetBox::copyStickersLink() {
|
||||||
QGuiApplication::clipboard()->setText(url);
|
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() {
|
void StickerSetBox::updateTitleAndButtons() {
|
||||||
setTitle(_inner->title());
|
setTitle(_inner->title());
|
||||||
updateButtons();
|
updateButtons();
|
||||||
|
@ -237,6 +269,24 @@ void StickerSetBox::updateButtons() {
|
||||||
};
|
};
|
||||||
addButton(tr::lng_stickers_share_pack(), std::move(share));
|
addButton(tr::lng_stickers_share_pack(), std::move(share));
|
||||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
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<base::unique_qptr<Ui::PopupMenu>>();
|
||||||
|
top->setClickedCallback([=] {
|
||||||
|
*menu = base::make_unique_q<Ui::PopupMenu>(top);
|
||||||
|
(*menu)->addAction(
|
||||||
|
tr::lng_stickers_archive_pack(tr::now),
|
||||||
|
archive);
|
||||||
|
(*menu)->popup(QCursor::pos());
|
||||||
|
return true;
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
addButton(tr::lng_cancel(), [=] { closeBox(); });
|
||||||
|
|
|
@ -42,6 +42,7 @@ private:
|
||||||
void updateButtons();
|
void updateButtons();
|
||||||
void addStickers();
|
void addStickers();
|
||||||
void copyStickersLink();
|
void copyStickersLink();
|
||||||
|
void archiveStickers();
|
||||||
|
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
MTPInputStickerSet _set;
|
MTPInputStickerSet _set;
|
||||||
|
|
Loading…
Add table
Reference in a new issue