Added support for archived masks.
This commit is contained in:
parent
2d17bd02a3
commit
e7104b5ebe
|
@ -2101,7 +2101,11 @@ void ApiWrap::saveStickerSets(
|
||||||
session().saveSettings();
|
session().saveSettings();
|
||||||
}
|
}
|
||||||
if (writeArchived) {
|
if (writeArchived) {
|
||||||
storage.writeArchivedStickers();
|
if (setsMasks) {
|
||||||
|
storage.writeArchivedMasks();
|
||||||
|
} else {
|
||||||
|
storage.writeArchivedStickers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (writeCloudRecent) {
|
if (writeCloudRecent) {
|
||||||
storage.writeRecentStickers();
|
storage.writeRecentStickers();
|
||||||
|
|
|
@ -494,9 +494,13 @@ void StickerSetBox::Inner::installDone(
|
||||||
|
|
||||||
const bool wasArchived = (_setFlags & MTPDstickerSet::Flag::f_archived);
|
const bool wasArchived = (_setFlags & MTPDstickerSet::Flag::f_archived);
|
||||||
if (wasArchived) {
|
if (wasArchived) {
|
||||||
const auto index = stickers.archivedSetsOrderRef().indexOf(_setId);
|
const auto index = (isMasks
|
||||||
|
? stickers.archivedMaskSetsOrderRef()
|
||||||
|
: stickers.archivedSetsOrderRef()).indexOf(_setId);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
stickers.archivedSetsOrderRef().removeAt(index);
|
(isMasks
|
||||||
|
? stickers.archivedMaskSetsOrderRef()
|
||||||
|
: stickers.archivedSetsOrderRef()).removeAt(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_setInstallDate = base::unixtime::now();
|
_setInstallDate = base::unixtime::now();
|
||||||
|
@ -556,7 +560,11 @@ void StickerSetBox::Inner::installDone(
|
||||||
} else {
|
} else {
|
||||||
auto &storage = _controller->session().local();
|
auto &storage = _controller->session().local();
|
||||||
if (wasArchived) {
|
if (wasArchived) {
|
||||||
storage.writeArchivedStickers();
|
if (isMasks) {
|
||||||
|
storage.writeArchivedMasks();
|
||||||
|
} else {
|
||||||
|
storage.writeArchivedStickers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (isMasks) {
|
if (isMasks) {
|
||||||
storage.writeInstalledMasks();
|
storage.writeInstalledMasks();
|
||||||
|
|
|
@ -90,7 +90,7 @@ public:
|
||||||
|
|
||||||
void saveGroupSet();
|
void saveGroupSet();
|
||||||
|
|
||||||
void rebuild();
|
void rebuild(bool masks);
|
||||||
void updateSize(int newWidth = 0);
|
void updateSize(int newWidth = 0);
|
||||||
void updateRows(); // refresh only pack cover stickers
|
void updateRows(); // refresh only pack cover stickers
|
||||||
bool appendSet(not_null<StickersSet*> set);
|
bool appendSet(not_null<StickersSet*> set);
|
||||||
|
@ -454,7 +454,7 @@ void StickersBox::getArchivedDone(
|
||||||
}
|
}
|
||||||
|
|
||||||
auto &stickers = result.c_messages_archivedStickers();
|
auto &stickers = result.c_messages_archivedStickers();
|
||||||
auto &archived = session().data().stickers().archivedSetsOrderRef();
|
auto &archived = archivedSetsOrderRef();
|
||||||
if (offsetId) {
|
if (offsetId) {
|
||||||
auto index = archived.indexOf(offsetId);
|
auto index = archived.indexOf(offsetId);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
|
@ -521,7 +521,11 @@ void StickersBox::getArchivedDone(
|
||||||
void StickersBox::prepare() {
|
void StickersBox::prepare() {
|
||||||
if (_section == Section::Installed) {
|
if (_section == Section::Installed) {
|
||||||
if (_tabs) {
|
if (_tabs) {
|
||||||
session().local().readArchivedStickers();
|
if (_isMasks) {
|
||||||
|
session().local().readArchivedMasks();
|
||||||
|
} else {
|
||||||
|
session().local().readArchivedStickers();
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
setTitle(tr::lng_stickers_group_set());
|
setTitle(tr::lng_stickers_group_set());
|
||||||
}
|
}
|
||||||
|
@ -531,7 +535,7 @@ void StickersBox::prepare() {
|
||||||
setTitle(tr::lng_stickers_attached_sets());
|
setTitle(tr::lng_stickers_attached_sets());
|
||||||
}
|
}
|
||||||
if (_tabs) {
|
if (_tabs) {
|
||||||
if (session().data().stickers().archivedSetsOrder().isEmpty()) {
|
if (archivedSetsOrder().isEmpty()) {
|
||||||
preloadArchivedSets();
|
preloadArchivedSets();
|
||||||
}
|
}
|
||||||
setNoContentMargin(true);
|
setNoContentMargin(true);
|
||||||
|
@ -645,7 +649,7 @@ void StickersBox::refreshTabs() {
|
||||||
sections.push_back(tr::lng_stickers_featured_tab(tr::now).toUpper());
|
sections.push_back(tr::lng_stickers_featured_tab(tr::now).toUpper());
|
||||||
_tabIndices.push_back(Section::Featured);
|
_tabIndices.push_back(Section::Featured);
|
||||||
}
|
}
|
||||||
if (!stickers.archivedSetsOrder().isEmpty() && _archived.widget()) {
|
if (!archivedSetsOrder().isEmpty() && _archived.widget()) {
|
||||||
sections.push_back(tr::lng_stickers_archived_tab(tr::now).toUpper());
|
sections.push_back(tr::lng_stickers_archived_tab(tr::now).toUpper());
|
||||||
_tabIndices.push_back(Section::Archived);
|
_tabIndices.push_back(Section::Archived);
|
||||||
}
|
}
|
||||||
|
@ -672,7 +676,7 @@ void StickersBox::loadMoreArchived() {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 lastId = 0;
|
uint64 lastId = 0;
|
||||||
const auto &order = session().data().stickers().archivedSetsOrder();
|
const auto &order = archivedSetsOrder();
|
||||||
const auto &sets = session().data().stickers().sets();
|
const auto &sets = session().data().stickers().sets();
|
||||||
for (auto setIt = order.cend(), e = order.cbegin(); setIt != e;) {
|
for (auto setIt = order.cend(), e = order.cbegin(); setIt != e;) {
|
||||||
--setIt;
|
--setIt;
|
||||||
|
@ -684,8 +688,11 @@ void StickersBox::loadMoreArchived() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
const auto flags = _isMasks
|
||||||
|
? MTPmessages_GetArchivedStickers::Flag::f_masks
|
||||||
|
: MTPmessages_GetArchivedStickers::Flags(0);
|
||||||
_archivedRequestId = _api.request(MTPmessages_GetArchivedStickers(
|
_archivedRequestId = _api.request(MTPmessages_GetArchivedStickers(
|
||||||
MTP_flags(0),
|
MTP_flags(flags),
|
||||||
MTP_long(lastId),
|
MTP_long(lastId),
|
||||||
MTP_int(kArchivedLimitPerPage)
|
MTP_int(kArchivedLimitPerPage)
|
||||||
)).done([=](const MTPmessages_ArchivedStickers &result) {
|
)).done([=](const MTPmessages_ArchivedStickers &result) {
|
||||||
|
@ -864,8 +871,11 @@ void StickersBox::preloadArchivedSets() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!_archivedRequestId) {
|
if (!_archivedRequestId) {
|
||||||
|
const auto flags = _isMasks
|
||||||
|
? MTPmessages_GetArchivedStickers::Flag::f_masks
|
||||||
|
: MTPmessages_GetArchivedStickers::Flags(0);
|
||||||
_archivedRequestId = _api.request(MTPmessages_GetArchivedStickers(
|
_archivedRequestId = _api.request(MTPmessages_GetArchivedStickers(
|
||||||
MTP_flags(0),
|
MTP_flags(flags),
|
||||||
MTP_long(0),
|
MTP_long(0),
|
||||||
MTP_int(kArchivedLimitFirstRequest)
|
MTP_int(kArchivedLimitFirstRequest)
|
||||||
)).done([=](const MTPmessages_ArchivedStickers &result) {
|
)).done([=](const MTPmessages_ArchivedStickers &result) {
|
||||||
|
@ -881,7 +891,7 @@ void StickersBox::requestArchivedSets() {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto &sets = session().data().stickers().sets();
|
const auto &sets = session().data().stickers().sets();
|
||||||
const auto &order = session().data().stickers().archivedSetsOrder();
|
const auto &order = archivedSetsOrder();
|
||||||
for (const auto setId : order) {
|
for (const auto setId : order) {
|
||||||
auto it = sets.find(setId);
|
auto it = sets.find(setId);
|
||||||
if (it != sets.cend()) {
|
if (it != sets.cend()) {
|
||||||
|
@ -918,7 +928,7 @@ void StickersBox::handleStickersUpdated() {
|
||||||
} else {
|
} else {
|
||||||
_tab->widget()->updateRows();
|
_tab->widget()->updateRows();
|
||||||
}
|
}
|
||||||
if (session().data().stickers().archivedSetsOrder().isEmpty()) {
|
if (archivedSetsOrder().isEmpty()) {
|
||||||
preloadArchivedSets();
|
preloadArchivedSets();
|
||||||
} else {
|
} else {
|
||||||
refreshTabs();
|
refreshTabs();
|
||||||
|
@ -937,7 +947,7 @@ void StickersBox::rebuildList(Tab *tab) {
|
||||||
_localOrder = tab->widget()->getFullOrder();
|
_localOrder = tab->widget()->getFullOrder();
|
||||||
_localRemoved = tab->widget()->getRemovedSets();
|
_localRemoved = tab->widget()->getRemovedSets();
|
||||||
}
|
}
|
||||||
tab->widget()->rebuild();
|
tab->widget()->rebuild(_isMasks);
|
||||||
if ((tab == &_installed) || (tab == &_masks)) {
|
if ((tab == &_installed) || (tab == &_masks)) {
|
||||||
tab->widget()->setFullOrder(_localOrder);
|
tab->widget()->setFullOrder(_localOrder);
|
||||||
}
|
}
|
||||||
|
@ -957,7 +967,11 @@ void StickersBox::saveChanges() {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_someArchivedLoaded) {
|
if (_someArchivedLoaded) {
|
||||||
session().local().writeArchivedStickers();
|
if (_isMasks) {
|
||||||
|
session().local().writeArchivedMasks();
|
||||||
|
} else {
|
||||||
|
session().local().writeArchivedStickers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (installed) {
|
if (installed) {
|
||||||
session().api().saveStickerSets(
|
session().api().saveStickerSets(
|
||||||
|
@ -979,6 +993,18 @@ void StickersBox::setInnerFocus() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const Data::StickersSetsOrder &StickersBox::archivedSetsOrder() const {
|
||||||
|
return !_isMasks
|
||||||
|
? session().data().stickers().archivedSetsOrder()
|
||||||
|
: session().data().stickers().archivedMaskSetsOrder();
|
||||||
|
}
|
||||||
|
|
||||||
|
Data::StickersSetsOrder &StickersBox::archivedSetsOrderRef() {
|
||||||
|
return !_isMasks
|
||||||
|
? session().data().stickers().archivedSetsOrderRef()
|
||||||
|
: session().data().stickers().archivedMaskSetsOrderRef();
|
||||||
|
}
|
||||||
|
|
||||||
StickersBox::~StickersBox() = default;
|
StickersBox::~StickersBox() = default;
|
||||||
|
|
||||||
StickersBox::Inner::Row::Row(
|
StickersBox::Inner::Row::Row(
|
||||||
|
@ -1935,7 +1961,7 @@ void StickersBox::Inner::rebuildMegagroupSet() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void StickersBox::Inner::rebuild() {
|
void StickersBox::Inner::rebuild(bool masks) {
|
||||||
_itemsTop = st::membersMarginTop;
|
_itemsTop = st::membersMarginTop;
|
||||||
|
|
||||||
if (_megagroupSet) {
|
if (_megagroupSet) {
|
||||||
|
@ -1959,7 +1985,9 @@ void StickersBox::Inner::rebuild() {
|
||||||
} else if (_section == Section::Featured) {
|
} else if (_section == Section::Featured) {
|
||||||
return session().data().stickers().featuredSetsOrder();
|
return session().data().stickers().featuredSetsOrder();
|
||||||
}
|
}
|
||||||
return session().data().stickers().archivedSetsOrder();
|
return masks
|
||||||
|
? session().data().stickers().archivedMaskSetsOrder()
|
||||||
|
: session().data().stickers().archivedSetsOrder();
|
||||||
})();
|
})();
|
||||||
_rows.reserve(order.size() + 1);
|
_rows.reserve(order.size() + 1);
|
||||||
_shiftingStartTimes.reserve(order.size() + 1);
|
_shiftingStartTimes.reserve(order.size() + 1);
|
||||||
|
@ -1999,7 +2027,7 @@ void StickersBox::Inner::rebuild() {
|
||||||
|
|
||||||
void StickersBox::Inner::setMegagroupSelectedSet(const MTPInputStickerSet &set) {
|
void StickersBox::Inner::setMegagroupSelectedSet(const MTPInputStickerSet &set) {
|
||||||
_megagroupSetInput = set;
|
_megagroupSetInput = set;
|
||||||
rebuild();
|
rebuild(false);
|
||||||
_scrollsToY.fire(0);
|
_scrollsToY.fire(0);
|
||||||
updateSelected();
|
updateSelected();
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,6 +134,9 @@ private:
|
||||||
uint64 offsetId);
|
uint64 offsetId);
|
||||||
void showAttachedStickers();
|
void showAttachedStickers();
|
||||||
|
|
||||||
|
const Data::StickersSetsOrder &archivedSetsOrder() const;
|
||||||
|
Data::StickersSetsOrder &archivedSetsOrderRef();
|
||||||
|
|
||||||
std::array<Inner*, 5> widgets() const;
|
std::array<Inner*, 5> widgets() const;
|
||||||
|
|
||||||
const not_null<Window::SessionController*> _controller;
|
const not_null<Window::SessionController*> _controller;
|
||||||
|
|
|
@ -263,10 +263,12 @@ void Stickers::checkSavedGif(not_null<HistoryItem*> item) {
|
||||||
void Stickers::applyArchivedResult(
|
void Stickers::applyArchivedResult(
|
||||||
const MTPDmessages_stickerSetInstallResultArchive &d) {
|
const MTPDmessages_stickerSetInstallResultArchive &d) {
|
||||||
auto &v = d.vsets().v;
|
auto &v = d.vsets().v;
|
||||||
auto &order = setsOrderRef();
|
|
||||||
StickersSetsOrder archived;
|
StickersSetsOrder archived;
|
||||||
archived.reserve(v.size());
|
archived.reserve(v.size());
|
||||||
QMap<uint64, uint64> setsToRequest;
|
QMap<uint64, uint64> setsToRequest;
|
||||||
|
|
||||||
|
auto masksCount = 0;
|
||||||
|
auto stickersCount = 0;
|
||||||
for (const auto &stickerSet : v) {
|
for (const auto &stickerSet : v) {
|
||||||
const MTPDstickerSet *setData = nullptr;
|
const MTPDstickerSet *setData = nullptr;
|
||||||
switch (stickerSet.type()) {
|
switch (stickerSet.type()) {
|
||||||
|
@ -288,7 +290,10 @@ void Stickers::applyArchivedResult(
|
||||||
if (set->stickers.isEmpty()) {
|
if (set->stickers.isEmpty()) {
|
||||||
setsToRequest.insert(set->id, set->access);
|
setsToRequest.insert(set->id, set->access);
|
||||||
}
|
}
|
||||||
auto index = order.indexOf(set->id);
|
const auto masks = !!(set->flags & MTPDstickerSet::Flag::f_masks);
|
||||||
|
(masks ? masksCount : stickersCount)++;
|
||||||
|
auto &order = masks ? maskSetsOrderRef() : setsOrderRef();
|
||||||
|
const auto index = order.indexOf(set->id);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
order.removeAt(index);
|
order.removeAt(index);
|
||||||
}
|
}
|
||||||
|
@ -301,8 +306,14 @@ void Stickers::applyArchivedResult(
|
||||||
}
|
}
|
||||||
session().api().requestStickerSets();
|
session().api().requestStickerSets();
|
||||||
}
|
}
|
||||||
session().local().writeInstalledStickers();
|
if (stickersCount) {
|
||||||
session().local().writeArchivedStickers();
|
session().local().writeInstalledStickers();
|
||||||
|
session().local().writeArchivedStickers();
|
||||||
|
}
|
||||||
|
if (masksCount) {
|
||||||
|
session().local().writeInstalledMasks();
|
||||||
|
session().local().writeArchivedMasks();
|
||||||
|
}
|
||||||
|
|
||||||
Ui::Toast::Show(Ui::Toast::Config{
|
Ui::Toast::Show(Ui::Toast::Config{
|
||||||
.text = { tr::lng_stickers_packs_archived(tr::now) },
|
.text = { tr::lng_stickers_packs_archived(tr::now) },
|
||||||
|
@ -360,12 +371,14 @@ void Stickers::installLocally(uint64 setId) {
|
||||||
|
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
auto flags = set->flags;
|
auto flags = set->flags;
|
||||||
set->flags &= ~(MTPDstickerSet::Flag::f_archived | MTPDstickerSet_ClientFlag::f_unread);
|
set->flags &= ~(MTPDstickerSet::Flag::f_archived
|
||||||
|
| MTPDstickerSet_ClientFlag::f_unread);
|
||||||
set->flags |= MTPDstickerSet::Flag::f_installed_date;
|
set->flags |= MTPDstickerSet::Flag::f_installed_date;
|
||||||
set->installDate = base::unixtime::now();
|
set->installDate = base::unixtime::now();
|
||||||
auto changedFlags = flags ^ set->flags;
|
auto changedFlags = flags ^ set->flags;
|
||||||
|
|
||||||
auto &order = setsOrderRef();
|
const auto masks = !!(flags & MTPDstickerSet::Flag::f_masks);
|
||||||
|
auto &order = masks ? maskSetsOrderRef() : setsOrderRef();
|
||||||
int insertAtIndex = 0, currentIndex = order.indexOf(setId);
|
int insertAtIndex = 0, currentIndex = order.indexOf(setId);
|
||||||
if (currentIndex != insertAtIndex) {
|
if (currentIndex != insertAtIndex) {
|
||||||
if (currentIndex > 0) {
|
if (currentIndex > 0) {
|
||||||
|
@ -390,10 +403,17 @@ void Stickers::installLocally(uint64 setId) {
|
||||||
session().local().writeFeaturedStickers();
|
session().local().writeFeaturedStickers();
|
||||||
}
|
}
|
||||||
if (changedFlags & MTPDstickerSet::Flag::f_archived) {
|
if (changedFlags & MTPDstickerSet::Flag::f_archived) {
|
||||||
auto index = archivedSetsOrderRef().indexOf(setId);
|
auto &archivedOrder = masks
|
||||||
|
? archivedMaskSetsOrderRef()
|
||||||
|
: archivedSetsOrderRef();
|
||||||
|
const auto index = archivedOrder.indexOf(setId);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
archivedSetsOrderRef().removeAt(index);
|
archivedOrder.removeAt(index);
|
||||||
session().local().writeArchivedStickers();
|
if (masks) {
|
||||||
|
session().local().writeArchivedMasks();
|
||||||
|
} else {
|
||||||
|
session().local().writeArchivedStickers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
notifyUpdated();
|
notifyUpdated();
|
||||||
|
@ -1234,13 +1254,17 @@ StickersSet *Stickers::feedSet(const MTPDstickerSet &data) {
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
auto changedFlags = (flags ^ set->flags);
|
auto changedFlags = (flags ^ set->flags);
|
||||||
if (changedFlags & MTPDstickerSet::Flag::f_archived) {
|
if (changedFlags & MTPDstickerSet::Flag::f_archived) {
|
||||||
auto index = archivedSetsOrder().indexOf(set->id);
|
const auto masks = !!(set->flags & MTPDstickerSet::Flag::f_masks);
|
||||||
|
auto &archivedOrder = masks
|
||||||
|
? archivedMaskSetsOrderRef()
|
||||||
|
: archivedSetsOrderRef();
|
||||||
|
const auto index = archivedOrder.indexOf(set->id);
|
||||||
if (set->flags & MTPDstickerSet::Flag::f_archived) {
|
if (set->flags & MTPDstickerSet::Flag::f_archived) {
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
archivedSetsOrderRef().push_front(set->id);
|
archivedOrder.push_front(set->id);
|
||||||
}
|
}
|
||||||
} else if (index >= 0) {
|
} else if (index >= 0) {
|
||||||
archivedSetsOrderRef().removeAt(index);
|
archivedOrder.removeAt(index);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return it->second.get();
|
return it->second.get();
|
||||||
|
@ -1358,7 +1382,11 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) {
|
||||||
session().local().writeFeaturedStickers();
|
session().local().writeFeaturedStickers();
|
||||||
}
|
}
|
||||||
if (wasArchived != isArchived) {
|
if (wasArchived != isArchived) {
|
||||||
session().local().writeArchivedStickers();
|
if (isMasks) {
|
||||||
|
session().local().writeArchivedMasks();
|
||||||
|
} else {
|
||||||
|
session().local().writeArchivedStickers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -152,6 +152,12 @@ public:
|
||||||
StickersSetsOrder &archivedSetsOrderRef() {
|
StickersSetsOrder &archivedSetsOrderRef() {
|
||||||
return _archivedSetsOrder;
|
return _archivedSetsOrder;
|
||||||
}
|
}
|
||||||
|
const StickersSetsOrder &archivedMaskSetsOrder() const {
|
||||||
|
return _archivedMaskSetsOrder;
|
||||||
|
}
|
||||||
|
StickersSetsOrder &archivedMaskSetsOrderRef() {
|
||||||
|
return _archivedMaskSetsOrder;
|
||||||
|
}
|
||||||
const SavedGifs &savedGifs() const {
|
const SavedGifs &savedGifs() const {
|
||||||
return _savedGifs;
|
return _savedGifs;
|
||||||
}
|
}
|
||||||
|
@ -241,6 +247,7 @@ private:
|
||||||
StickersSetsOrder _maskSetsOrder;
|
StickersSetsOrder _maskSetsOrder;
|
||||||
StickersSetsOrder _featuredSetsOrder;
|
StickersSetsOrder _featuredSetsOrder;
|
||||||
StickersSetsOrder _archivedSetsOrder;
|
StickersSetsOrder _archivedSetsOrder;
|
||||||
|
StickersSetsOrder _archivedMaskSetsOrder;
|
||||||
SavedGifs _savedGifs;
|
SavedGifs _savedGifs;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
|
@ -187,6 +187,7 @@ base::flat_set<QString> Account::collectGoodNames() const {
|
||||||
_trustedBotsKey,
|
_trustedBotsKey,
|
||||||
_installedMasksKey,
|
_installedMasksKey,
|
||||||
_recentMasksKey,
|
_recentMasksKey,
|
||||||
|
_archivedMasksKey,
|
||||||
};
|
};
|
||||||
auto result = base::flat_set<QString>{
|
auto result = base::flat_set<QString>{
|
||||||
"map0",
|
"map0",
|
||||||
|
@ -267,7 +268,7 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
quint64 locationsKey = 0, reportSpamStatusesKey = 0, trustedBotsKey = 0;
|
quint64 locationsKey = 0, reportSpamStatusesKey = 0, trustedBotsKey = 0;
|
||||||
quint64 recentStickersKeyOld = 0;
|
quint64 recentStickersKeyOld = 0;
|
||||||
quint64 installedStickersKey = 0, featuredStickersKey = 0, recentStickersKey = 0, favedStickersKey = 0, archivedStickersKey = 0;
|
quint64 installedStickersKey = 0, featuredStickersKey = 0, recentStickersKey = 0, favedStickersKey = 0, archivedStickersKey = 0;
|
||||||
quint64 installedMasksKey = 0, recentMasksKey = 0;
|
quint64 installedMasksKey = 0, recentMasksKey = 0, archivedMasksKey = 0;
|
||||||
quint64 savedGifsKey = 0;
|
quint64 savedGifsKey = 0;
|
||||||
quint64 legacyBackgroundKeyDay = 0, legacyBackgroundKeyNight = 0;
|
quint64 legacyBackgroundKeyDay = 0, legacyBackgroundKeyNight = 0;
|
||||||
quint64 userSettingsKey = 0, recentHashtagsAndBotsKey = 0, exportSettingsKey = 0;
|
quint64 userSettingsKey = 0, recentHashtagsAndBotsKey = 0, exportSettingsKey = 0;
|
||||||
|
@ -365,7 +366,10 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
map.stream >> exportSettingsKey;
|
map.stream >> exportSettingsKey;
|
||||||
} break;
|
} break;
|
||||||
case lskMasksKeys: {
|
case lskMasksKeys: {
|
||||||
map.stream >> installedMasksKey >> recentMasksKey;
|
map.stream
|
||||||
|
>> installedMasksKey
|
||||||
|
>> recentMasksKey
|
||||||
|
>> archivedMasksKey;
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
LOG(("App Error: unknown key type in encrypted map: %1").arg(keyType));
|
LOG(("App Error: unknown key type in encrypted map: %1").arg(keyType));
|
||||||
|
@ -393,6 +397,7 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
_savedGifsKey = savedGifsKey;
|
_savedGifsKey = savedGifsKey;
|
||||||
_installedMasksKey = installedMasksKey;
|
_installedMasksKey = installedMasksKey;
|
||||||
_recentMasksKey = recentMasksKey;
|
_recentMasksKey = recentMasksKey;
|
||||||
|
_archivedMasksKey = archivedMasksKey;
|
||||||
_legacyBackgroundKeyDay = legacyBackgroundKeyDay;
|
_legacyBackgroundKeyDay = legacyBackgroundKeyDay;
|
||||||
_legacyBackgroundKeyNight = legacyBackgroundKeyNight;
|
_legacyBackgroundKeyNight = legacyBackgroundKeyNight;
|
||||||
_settingsKey = userSettingsKey;
|
_settingsKey = userSettingsKey;
|
||||||
|
@ -497,8 +502,8 @@ void Account::writeMap() {
|
||||||
if (_settingsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
if (_settingsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
||||||
if (_recentHashtagsAndBotsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
if (_recentHashtagsAndBotsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
||||||
if (_exportSettingsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
if (_exportSettingsKey) mapSize += sizeof(quint32) + sizeof(quint64);
|
||||||
if (_installedMasksKey || _recentMasksKey) {
|
if (_installedMasksKey || _recentMasksKey || _archivedMasksKey) {
|
||||||
mapSize += sizeof(quint32) + 2 * sizeof(quint64);
|
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
||||||
}
|
}
|
||||||
|
|
||||||
EncryptedDescriptor mapData(mapSize);
|
EncryptedDescriptor mapData(mapSize);
|
||||||
|
@ -545,11 +550,12 @@ void Account::writeMap() {
|
||||||
if (_exportSettingsKey) {
|
if (_exportSettingsKey) {
|
||||||
mapData.stream << quint32(lskExportSettings) << quint64(_exportSettingsKey);
|
mapData.stream << quint32(lskExportSettings) << quint64(_exportSettingsKey);
|
||||||
}
|
}
|
||||||
if (_installedMasksKey || _recentMasksKey) {
|
if (_installedMasksKey || _recentMasksKey || _archivedMasksKey) {
|
||||||
mapData.stream << quint32(lskMasksKeys);
|
mapData.stream << quint32(lskMasksKeys);
|
||||||
mapData.stream
|
mapData.stream
|
||||||
<< quint64(_installedMasksKey)
|
<< quint64(_installedMasksKey)
|
||||||
<< quint64(_recentMasksKey);
|
<< quint64(_recentMasksKey)
|
||||||
|
<< quint64(_archivedMasksKey);
|
||||||
}
|
}
|
||||||
map.writeEncrypted(mapData, _localKey);
|
map.writeEncrypted(mapData, _localKey);
|
||||||
|
|
||||||
|
@ -571,6 +577,7 @@ void Account::reset() {
|
||||||
_savedGifsKey = 0;
|
_savedGifsKey = 0;
|
||||||
_installedMasksKey = 0;
|
_installedMasksKey = 0;
|
||||||
_recentMasksKey = 0;
|
_recentMasksKey = 0;
|
||||||
|
_archivedMasksKey = 0;
|
||||||
_legacyBackgroundKeyDay = _legacyBackgroundKeyNight = 0;
|
_legacyBackgroundKeyDay = _legacyBackgroundKeyNight = 0;
|
||||||
_settingsKey = _recentHashtagsAndBotsKey = _exportSettingsKey = 0;
|
_settingsKey = _recentHashtagsAndBotsKey = _exportSettingsKey = 0;
|
||||||
_oldMapVersion = 0;
|
_oldMapVersion = 0;
|
||||||
|
@ -1885,6 +1892,8 @@ void Account::writeInstalledStickers() {
|
||||||
}
|
}
|
||||||
} else if (!(set.flags & MTPDstickerSet::Flag::f_installed_date) || (set.flags & MTPDstickerSet::Flag::f_archived)) {
|
} else if (!(set.flags & MTPDstickerSet::Flag::f_installed_date) || (set.flags & MTPDstickerSet::Flag::f_archived)) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
|
} else if (set.flags & MTPDstickerSet::Flag::f_masks) {
|
||||||
|
return StickerSetCheckResult::Skip;
|
||||||
} else if (set.flags & MTPDstickerSet_ClientFlag::f_not_loaded) { // waiting to receive
|
} else if (set.flags & MTPDstickerSet_ClientFlag::f_not_loaded) { // waiting to receive
|
||||||
return StickerSetCheckResult::Abort;
|
return StickerSetCheckResult::Abort;
|
||||||
} else if (set.stickers.isEmpty()) {
|
} else if (set.stickers.isEmpty()) {
|
||||||
|
@ -1933,6 +1942,9 @@ void Account::writeFavedStickers() {
|
||||||
|
|
||||||
void Account::writeArchivedStickers() {
|
void Account::writeArchivedStickers() {
|
||||||
writeStickerSets(_archivedStickersKey, [](const Data::StickersSet &set) {
|
writeStickerSets(_archivedStickersKey, [](const Data::StickersSet &set) {
|
||||||
|
if (set.flags & MTPDstickerSet::Flag::f_masks) {
|
||||||
|
return StickerSetCheckResult::Skip;
|
||||||
|
}
|
||||||
if (!(set.flags & MTPDstickerSet::Flag::f_archived) || set.stickers.isEmpty()) {
|
if (!(set.flags & MTPDstickerSet::Flag::f_archived) || set.stickers.isEmpty()) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
}
|
}
|
||||||
|
@ -1940,6 +1952,18 @@ void Account::writeArchivedStickers() {
|
||||||
}, _owner->session().data().stickers().archivedSetsOrder());
|
}, _owner->session().data().stickers().archivedSetsOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Account::writeArchivedMasks() {
|
||||||
|
writeStickerSets(_archivedStickersKey, [](const Data::StickersSet &set) {
|
||||||
|
if (!(set.flags & MTPDstickerSet::Flag::f_masks)) {
|
||||||
|
return StickerSetCheckResult::Skip;
|
||||||
|
}
|
||||||
|
if (!(set.flags & MTPDstickerSet::Flag::f_archived) || set.stickers.isEmpty()) {
|
||||||
|
return StickerSetCheckResult::Skip;
|
||||||
|
}
|
||||||
|
return StickerSetCheckResult::Write;
|
||||||
|
}, _owner->session().data().stickers().archivedMaskSetsOrder());
|
||||||
|
}
|
||||||
|
|
||||||
void Account::writeInstalledMasks() {
|
void Account::writeInstalledMasks() {
|
||||||
writeStickerSets(_installedMasksKey, [](const Data::StickersSet &set) {
|
writeStickerSets(_installedMasksKey, [](const Data::StickersSet &set) {
|
||||||
if (!(set.flags & MTPDstickerSet::Flag::f_masks) || set.stickers.isEmpty()) {
|
if (!(set.flags & MTPDstickerSet::Flag::f_masks) || set.stickers.isEmpty()) {
|
||||||
|
@ -2123,13 +2147,27 @@ void Account::readFavedStickers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::readArchivedStickers() {
|
void Account::readArchivedStickers() {
|
||||||
|
// TODO: refactor to support for multiple accounts.
|
||||||
static bool archivedStickersRead = false;
|
static bool archivedStickersRead = false;
|
||||||
if (!archivedStickersRead) {
|
if (!archivedStickersRead) {
|
||||||
readStickerSets(_archivedStickersKey, &_owner->session().data().stickers().archivedSetsOrderRef());
|
readStickerSets(
|
||||||
|
_archivedStickersKey,
|
||||||
|
&_owner->session().data().stickers().archivedSetsOrderRef());
|
||||||
archivedStickersRead = true;
|
archivedStickersRead = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Account::readArchivedMasks() {
|
||||||
|
// TODO: refactor to support for multiple accounts.
|
||||||
|
static bool archivedMasksRead = false;
|
||||||
|
if (!archivedMasksRead) {
|
||||||
|
readStickerSets(
|
||||||
|
_archivedMasksKey,
|
||||||
|
&_owner->session().data().stickers().archivedMaskSetsOrderRef());
|
||||||
|
archivedMasksRead = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void Account::readInstalledMasks() {
|
void Account::readInstalledMasks() {
|
||||||
readStickerSets(
|
readStickerSets(
|
||||||
_installedMasksKey,
|
_installedMasksKey,
|
||||||
|
|
|
@ -111,11 +111,13 @@ public:
|
||||||
void writeRecentStickers();
|
void writeRecentStickers();
|
||||||
void writeFavedStickers();
|
void writeFavedStickers();
|
||||||
void writeArchivedStickers();
|
void writeArchivedStickers();
|
||||||
|
void writeArchivedMasks();
|
||||||
void readInstalledStickers();
|
void readInstalledStickers();
|
||||||
void readFeaturedStickers();
|
void readFeaturedStickers();
|
||||||
void readRecentStickers();
|
void readRecentStickers();
|
||||||
void readFavedStickers();
|
void readFavedStickers();
|
||||||
void readArchivedStickers();
|
void readArchivedStickers();
|
||||||
|
void readArchivedMasks();
|
||||||
void writeSavedGifs();
|
void writeSavedGifs();
|
||||||
void readSavedGifs();
|
void readSavedGifs();
|
||||||
void writeInstalledMasks();
|
void writeInstalledMasks();
|
||||||
|
@ -252,6 +254,7 @@ private:
|
||||||
FileKey _recentStickersKey = 0;
|
FileKey _recentStickersKey = 0;
|
||||||
FileKey _favedStickersKey = 0;
|
FileKey _favedStickersKey = 0;
|
||||||
FileKey _archivedStickersKey = 0;
|
FileKey _archivedStickersKey = 0;
|
||||||
|
FileKey _archivedMasksKey = 0;
|
||||||
FileKey _savedGifsKey = 0;
|
FileKey _savedGifsKey = 0;
|
||||||
FileKey _recentStickersKeyOld = 0;
|
FileKey _recentStickersKeyOld = 0;
|
||||||
FileKey _legacyBackgroundKeyDay = 0;
|
FileKey _legacyBackgroundKeyDay = 0;
|
||||||
|
|
Loading…
Reference in New Issue