mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-06 15:13:57 +02:00
Fixed removing masks set from StickersListWidget.
This commit is contained in:
parent
e7104b5ebe
commit
de108c8efe
1 changed files with 68 additions and 48 deletions
|
@ -3153,20 +3153,34 @@ void StickersListWidget::removeMegagroupSet(bool locally) {
|
||||||
void StickersListWidget::removeSet(uint64 setId) {
|
void StickersListWidget::removeSet(uint64 setId) {
|
||||||
const auto &sets = session().data().stickers().sets();
|
const auto &sets = session().data().stickers().sets();
|
||||||
const auto it = sets.find(setId);
|
const auto it = sets.find(setId);
|
||||||
if (it != sets.cend()) {
|
if (it == sets.cend()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
_removingSetId = set->id;
|
_removingSetId = set->id;
|
||||||
auto text = tr::lng_stickers_remove_pack(tr::now, lt_sticker_pack, set->title);
|
const auto text = tr::lng_stickers_remove_pack(
|
||||||
controller()->show(Box<ConfirmBox>(text, tr::lng_stickers_remove_pack_confirm(tr::now), crl::guard(this, [=] {
|
tr::now,
|
||||||
Ui::hideLayer();
|
lt_sticker_pack,
|
||||||
|
set->title);
|
||||||
|
const auto confirm = tr::lng_stickers_remove_pack_confirm(tr::now);
|
||||||
|
controller()->show(Box<ConfirmBox>(text, confirm, crl::guard(this, [=](
|
||||||
|
Fn<void()> &&close) {
|
||||||
|
close();
|
||||||
const auto &sets = session().data().stickers().sets();
|
const auto &sets = session().data().stickers().sets();
|
||||||
const auto it = sets.find(_removingSetId);
|
const auto it = sets.find(_removingSetId);
|
||||||
if (it != sets.cend()) {
|
if (it != sets.cend()) {
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
if (set->id && set->access) {
|
if (set->id && set->access) {
|
||||||
_api.request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetID(MTP_long(set->id), MTP_long(set->access)))).send();
|
_api.request(MTPmessages_UninstallStickerSet(
|
||||||
|
MTP_inputStickerSetID(
|
||||||
|
MTP_long(set->id),
|
||||||
|
MTP_long(set->access)))
|
||||||
|
).send();
|
||||||
} else if (!set->shortName.isEmpty()) {
|
} else if (!set->shortName.isEmpty()) {
|
||||||
_api.request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetShortName(MTP_string(set->shortName)))).send();
|
_api.request(MTPmessages_UninstallStickerSet(
|
||||||
|
MTP_inputStickerSetShortName(
|
||||||
|
MTP_string(set->shortName)))
|
||||||
|
).send();
|
||||||
}
|
}
|
||||||
auto writeRecent = false;
|
auto writeRecent = false;
|
||||||
auto &recent = session().data().stickers().getRecentPack();
|
auto &recent = session().data().stickers().getRecentPack();
|
||||||
|
@ -3187,21 +3201,27 @@ void StickersListWidget::removeSet(uint64 setId) {
|
||||||
// && !(set->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
// && !(set->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
||||||
// sets.erase(it);
|
// sets.erase(it);
|
||||||
//}
|
//}
|
||||||
int removeIndex = defaultSetsOrder().indexOf(_removingSetId);
|
const auto removeIndex = defaultSetsOrder().indexOf(
|
||||||
|
_removingSetId);
|
||||||
if (removeIndex >= 0) {
|
if (removeIndex >= 0) {
|
||||||
defaultSetsOrderRef().removeAt(removeIndex);
|
defaultSetsOrderRef().removeAt(removeIndex);
|
||||||
}
|
}
|
||||||
refreshStickers();
|
refreshStickers();
|
||||||
|
if (set->flags & MTPDstickerSet::Flag::f_masks) {
|
||||||
|
session().local().writeInstalledMasks();
|
||||||
|
} else {
|
||||||
session().local().writeInstalledStickers();
|
session().local().writeInstalledStickers();
|
||||||
if (writeRecent) session().saveSettings();
|
}
|
||||||
|
if (writeRecent) {
|
||||||
|
session().saveSettings();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_removingSetId = 0;
|
_removingSetId = 0;
|
||||||
_checkForHide.fire({});
|
_checkForHide.fire({});
|
||||||
}), crl::guard(this, [=] {
|
}), crl::guard(this, [=] {
|
||||||
_removingSetId = 0;
|
_removingSetId = 0;
|
||||||
_checkForHide.fire({});
|
_checkForHide.fire({});
|
||||||
})));
|
})), Ui::LayerOption::KeepOther);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const Data::StickersSetsOrder &StickersListWidget::defaultSetsOrder() const {
|
const Data::StickersSetsOrder &StickersListWidget::defaultSetsOrder() const {
|
||||||
|
|
Loading…
Add table
Reference in a new issue