mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33: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,55 +3153,75 @@ 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()) {
|
||||||
const auto set = it->second.get();
|
return;
|
||||||
_removingSetId = set->id;
|
|
||||||
auto text = tr::lng_stickers_remove_pack(tr::now, lt_sticker_pack, set->title);
|
|
||||||
controller()->show(Box<ConfirmBox>(text, tr::lng_stickers_remove_pack_confirm(tr::now), crl::guard(this, [=] {
|
|
||||||
Ui::hideLayer();
|
|
||||||
const auto &sets = session().data().stickers().sets();
|
|
||||||
const auto it = sets.find(_removingSetId);
|
|
||||||
if (it != sets.cend()) {
|
|
||||||
const auto set = it->second.get();
|
|
||||||
if (set->id && set->access) {
|
|
||||||
_api.request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetID(MTP_long(set->id), MTP_long(set->access)))).send();
|
|
||||||
} else if (!set->shortName.isEmpty()) {
|
|
||||||
_api.request(MTPmessages_UninstallStickerSet(MTP_inputStickerSetShortName(MTP_string(set->shortName)))).send();
|
|
||||||
}
|
|
||||||
auto writeRecent = false;
|
|
||||||
auto &recent = session().data().stickers().getRecentPack();
|
|
||||||
for (auto i = recent.begin(); i != recent.cend();) {
|
|
||||||
if (set->stickers.indexOf(i->first) >= 0) {
|
|
||||||
i = recent.erase(i);
|
|
||||||
writeRecent = true;
|
|
||||||
} else {
|
|
||||||
++i;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
set->flags &= ~MTPDstickerSet::Flag::f_installed_date;
|
|
||||||
set->installDate = TimeId(0);
|
|
||||||
//
|
|
||||||
// Set can be in search results.
|
|
||||||
//
|
|
||||||
//if (!(set->flags & MTPDstickerSet_ClientFlag::f_featured)
|
|
||||||
// && !(set->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
|
||||||
// sets.erase(it);
|
|
||||||
//}
|
|
||||||
int removeIndex = defaultSetsOrder().indexOf(_removingSetId);
|
|
||||||
if (removeIndex >= 0) {
|
|
||||||
defaultSetsOrderRef().removeAt(removeIndex);
|
|
||||||
}
|
|
||||||
refreshStickers();
|
|
||||||
session().local().writeInstalledStickers();
|
|
||||||
if (writeRecent) session().saveSettings();
|
|
||||||
}
|
|
||||||
_removingSetId = 0;
|
|
||||||
_checkForHide.fire({});
|
|
||||||
}), crl::guard(this, [=] {
|
|
||||||
_removingSetId = 0;
|
|
||||||
_checkForHide.fire({});
|
|
||||||
})));
|
|
||||||
}
|
}
|
||||||
|
const auto set = it->second.get();
|
||||||
|
_removingSetId = set->id;
|
||||||
|
const auto text = tr::lng_stickers_remove_pack(
|
||||||
|
tr::now,
|
||||||
|
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 it = sets.find(_removingSetId);
|
||||||
|
if (it != sets.cend()) {
|
||||||
|
const auto set = it->second.get();
|
||||||
|
if (set->id && set->access) {
|
||||||
|
_api.request(MTPmessages_UninstallStickerSet(
|
||||||
|
MTP_inputStickerSetID(
|
||||||
|
MTP_long(set->id),
|
||||||
|
MTP_long(set->access)))
|
||||||
|
).send();
|
||||||
|
} else if (!set->shortName.isEmpty()) {
|
||||||
|
_api.request(MTPmessages_UninstallStickerSet(
|
||||||
|
MTP_inputStickerSetShortName(
|
||||||
|
MTP_string(set->shortName)))
|
||||||
|
).send();
|
||||||
|
}
|
||||||
|
auto writeRecent = false;
|
||||||
|
auto &recent = session().data().stickers().getRecentPack();
|
||||||
|
for (auto i = recent.begin(); i != recent.cend();) {
|
||||||
|
if (set->stickers.indexOf(i->first) >= 0) {
|
||||||
|
i = recent.erase(i);
|
||||||
|
writeRecent = true;
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
set->flags &= ~MTPDstickerSet::Flag::f_installed_date;
|
||||||
|
set->installDate = TimeId(0);
|
||||||
|
//
|
||||||
|
// Set can be in search results.
|
||||||
|
//
|
||||||
|
//if (!(set->flags & MTPDstickerSet_ClientFlag::f_featured)
|
||||||
|
// && !(set->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
||||||
|
// sets.erase(it);
|
||||||
|
//}
|
||||||
|
const auto removeIndex = defaultSetsOrder().indexOf(
|
||||||
|
_removingSetId);
|
||||||
|
if (removeIndex >= 0) {
|
||||||
|
defaultSetsOrderRef().removeAt(removeIndex);
|
||||||
|
}
|
||||||
|
refreshStickers();
|
||||||
|
if (set->flags & MTPDstickerSet::Flag::f_masks) {
|
||||||
|
session().local().writeInstalledMasks();
|
||||||
|
} else {
|
||||||
|
session().local().writeInstalledStickers();
|
||||||
|
}
|
||||||
|
if (writeRecent) {
|
||||||
|
session().saveSettings();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
_removingSetId = 0;
|
||||||
|
_checkForHide.fire({});
|
||||||
|
}), crl::guard(this, [=] {
|
||||||
|
_removingSetId = 0;
|
||||||
|
_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