2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-09-05 09:05:14 +00:00

Don't store MTPInputStickerSet in data.

This commit is contained in:
John Preston
2021-07-08 19:42:57 +03:00
parent 9dfb43d525
commit 75090dedaa
23 changed files with 152 additions and 119 deletions

View File

@@ -233,7 +233,7 @@ private:
void rebuildMegagroupSet();
void fixupMegagroupSetAddress();
void handleMegagroupSetAddressChange();
void setMegagroupSelectedSet(const MTPInputStickerSet &set);
void setMegagroupSelectedSet(const StickerSetIdentifier &set);
int countMaxNameWidth() const;
@@ -284,7 +284,7 @@ private:
int _scrollbar = 0;
ChannelData *_megagroupSet = nullptr;
MTPInputStickerSet _megagroupSetInput = MTP_inputStickerSetEmpty();
StickerSetIdentifier _megagroupSetInput;
std::unique_ptr<Row> _megagroupSelectedSet;
object_ptr<AddressField> _megagroupSetField = { nullptr };
object_ptr<Ui::PlainShadow> _megagroupSelectedShadow = { nullptr };
@@ -1713,14 +1713,14 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
const auto showSetByRow = [&](const Row &row) {
setSelected(SelectedRow());
_controller->show(
Box<StickerSetBox>(_controller, row.set->mtpInput()),
Box<StickerSetBox>(_controller, row.set->identifier()),
Ui::LayerOption::KeepOther);
};
if (selectedIndex >= 0 && !_inDragArea) {
const auto row = _rows[selectedIndex].get();
if (!row->isRecentSet()) {
if (_megagroupSet) {
setMegagroupSelectedSet(row->set->mtpInput());
setMegagroupSelectedSet(row->set->identifier());
} else {
showSetByRow(*row);
}
@@ -1735,12 +1735,8 @@ void StickersBox::Inner::mouseReleaseEvent(QMouseEvent *e) {
void StickersBox::Inner::saveGroupSet() {
Expects(_megagroupSet != nullptr);
auto oldId = (_megagroupSet->mgInfo->stickerSet.type() == mtpc_inputStickerSetID)
? _megagroupSet->mgInfo->stickerSet.c_inputStickerSetID().vid().v
: 0;
auto newId = (_megagroupSetInput.type() == mtpc_inputStickerSetID)
? _megagroupSetInput.c_inputStickerSetID().vid().v
: 0;
auto oldId = _megagroupSet->mgInfo->stickerSet.id;
auto newId = _megagroupSetInput.id;
if (newId != oldId) {
session().api().setGroupStickerSet(_megagroupSet, _megagroupSetInput);
session().data().stickers().notifyStickerSetInstalled(
@@ -1877,7 +1873,7 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() {
const auto &sets = session().data().stickers().sets();
const auto it = sets.find(_megagroupSelectedSet->set->id);
if (it != sets.cend() && !it->second->shortName.isEmpty()) {
setMegagroupSelectedSet(MTP_inputStickerSetEmpty());
setMegagroupSelectedSet({});
}
}
} else if (!_megagroupSetRequestId) {
@@ -1886,12 +1882,10 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() {
)).done([=](const MTPmessages_StickerSet &result) {
_megagroupSetRequestId = 0;
auto set = session().data().stickers().feedSetFull(result);
setMegagroupSelectedSet(MTP_inputStickerSetID(
MTP_long(set->id),
MTP_long(set->access)));
setMegagroupSelectedSet(set->identifier());
}).fail([=](const MTP::Error &error) {
_megagroupSetRequestId = 0;
setMegagroupSelectedSet(MTP_inputStickerSetEmpty());
setMegagroupSelectedSet({});
}).send();
} else {
_megagroupSetAddressChangedTimer.callOnce(kHandleMegagroupSetAddressChangeTimeout);
@@ -1900,7 +1894,8 @@ void StickersBox::Inner::handleMegagroupSetAddressChange() {
void StickersBox::Inner::rebuildMegagroupSet() {
Expects(_megagroupSet != nullptr);
if (_megagroupSetInput.type() != mtpc_inputStickerSetID) {
if (!_megagroupSetInput.id) {
if (_megagroupSelectedSet) {
_megagroupSetField->setText(QString());
_megagroupSetField->finishAnimating();
@@ -1910,15 +1905,14 @@ void StickersBox::Inner::rebuildMegagroupSet() {
_megagroupSelectedShadow.destroy();
return;
}
auto &inputId = _megagroupSetInput.c_inputStickerSetID();
auto setId = inputId.vid().v;
auto setId = _megagroupSetInput.id;
const auto &sets = session().data().stickers().sets();
auto it = sets.find(setId);
if (it == sets.cend()
|| (it->second->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
session().api().scheduleStickerSetRequest(
inputId.vid().v,
inputId.vaccess_hash().v);
_megagroupSetInput.id,
_megagroupSetInput.accessHash);
return;
}
@@ -1954,7 +1948,7 @@ void StickersBox::Inner::rebuildMegagroupSet() {
_megagroupSelectedRemove.create(this, st::groupStickersRemove);
_megagroupSelectedRemove->show(anim::type::instant);
_megagroupSelectedRemove->setClickedCallback([this] {
setMegagroupSelectedSet(MTP_inputStickerSetEmpty());
setMegagroupSelectedSet({});
});
_megagroupSelectedShadow.create(this);
updateControlsGeometry();
@@ -2025,7 +2019,7 @@ void StickersBox::Inner::rebuild(bool masks) {
updateSize();
}
void StickersBox::Inner::setMegagroupSelectedSet(const MTPInputStickerSet &set) {
void StickersBox::Inner::setMegagroupSelectedSet(const StickerSetIdentifier &set) {
_megagroupSetInput = set;
rebuild(false);
_scrollsToY.fire(0);