mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Don't use MTP* for StickersSet flags.
This commit is contained in:
parent
62fd968409
commit
4206ff0483
14 changed files with 273 additions and 262 deletions
|
@ -40,6 +40,7 @@ namespace {
|
||||||
int32 CountStickersHash(
|
int32 CountStickersHash(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
bool checkOutdatedInfo) {
|
bool checkOutdatedInfo) {
|
||||||
|
using Flag = Data::StickersSetFlag;
|
||||||
auto result = HashInit();
|
auto result = HashInit();
|
||||||
bool foundOutdated = false;
|
bool foundOutdated = false;
|
||||||
const auto &sets = session->data().stickers().sets();
|
const auto &sets = session->data().stickers().sets();
|
||||||
|
@ -50,8 +51,8 @@ int32 CountStickersHash(
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
if (set->id == Data::Stickers::DefaultSetId) {
|
if (set->id == Data::Stickers::DefaultSetId) {
|
||||||
foundOutdated = true;
|
foundOutdated = true;
|
||||||
} else if (!(set->flags & MTPDstickerSet_ClientFlag::f_special)
|
} else if (!(set->flags & Flag::Special)
|
||||||
&& !(set->flags & MTPDstickerSet::Flag::f_archived)) {
|
&& !(set->flags & Flag::Archived)) {
|
||||||
HashUpdate(result, set->hash);
|
HashUpdate(result, set->hash);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,7 +85,7 @@ int32 CountFeaturedStickersHash(not_null<Main::Session*> session) {
|
||||||
|
|
||||||
const auto it = sets.find(setId);
|
const auto it = sets.find(setId);
|
||||||
if (it != sets.cend()
|
if (it != sets.cend()
|
||||||
&& (it->second->flags & MTPDstickerSet_ClientFlag::f_unread)) {
|
&& (it->second->flags & Data::StickersSetFlag::Unread)) {
|
||||||
HashUpdate(result, 1);
|
HashUpdate(result, 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1946,9 +1946,7 @@ void ApiWrap::saveStickerSets(
|
||||||
? _session->data().stickers().maskSetsOrderRef()
|
? _session->data().stickers().maskSetsOrderRef()
|
||||||
: _session->data().stickers().setsOrderRef();
|
: _session->data().stickers().setsOrderRef();
|
||||||
|
|
||||||
using Flag = MTPDstickerSet::Flag;
|
using Flag = Data::StickersSetFlag;
|
||||||
using ClientFlag = MTPDstickerSet_ClientFlag;
|
|
||||||
|
|
||||||
for (const auto removedSetId : localRemoved) {
|
for (const auto removedSetId : localRemoved) {
|
||||||
if ((removedSetId == Data::Stickers::CloudRecentSetId)
|
if ((removedSetId == Data::Stickers::CloudRecentSetId)
|
||||||
|| (removedSetId == Data::Stickers::CloudRecentAttachedSetId)) {
|
|| (removedSetId == Data::Stickers::CloudRecentAttachedSetId)) {
|
||||||
|
@ -2000,10 +1998,10 @@ void ApiWrap::saveStickerSets(
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto archived = !!(set->flags & Flag::f_archived);
|
const auto archived = !!(set->flags & Flag::Archived);
|
||||||
if (!archived) {
|
if (!archived) {
|
||||||
const auto featured = !!(set->flags & ClientFlag::f_featured);
|
const auto featured = !!(set->flags & Flag::Featured);
|
||||||
const auto special = !!(set->flags & ClientFlag::f_special);
|
const auto special = !!(set->flags & Flag::Special);
|
||||||
const auto setId = set->mtpInput();
|
const auto setId = set->mtpInput();
|
||||||
|
|
||||||
auto requestId = request(MTPmessages_UninstallStickerSet(
|
auto requestId = request(MTPmessages_UninstallStickerSet(
|
||||||
|
@ -2026,8 +2024,7 @@ void ApiWrap::saveStickerSets(
|
||||||
if (archived) {
|
if (archived) {
|
||||||
writeArchived = true;
|
writeArchived = true;
|
||||||
}
|
}
|
||||||
set->flags &= ~(Flag::f_installed_date
|
set->flags &= ~(Flag::Installed | Flag::Archived);
|
||||||
| Flag::f_archived);
|
|
||||||
set->installDate = TimeId(0);
|
set->installDate = TimeId(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2036,10 +2033,10 @@ void ApiWrap::saveStickerSets(
|
||||||
|
|
||||||
// Clear all installed flags, set only for sets from order.
|
// Clear all installed flags, set only for sets from order.
|
||||||
for (auto &[id, set] : sets) {
|
for (auto &[id, set] : sets) {
|
||||||
const auto archived = !!(set->flags & Flag::f_archived);
|
const auto archived = !!(set->flags & Flag::Archived);
|
||||||
const auto masks = !!(set->flags & MTPDstickerSet::Flag::f_masks);
|
const auto masks = !!(set->flags & Flag::Masks);
|
||||||
if (!archived && (setsMasks == masks)) {
|
if (!archived && (setsMasks == masks)) {
|
||||||
set->flags &= ~Flag::f_installed_date;
|
set->flags &= ~Flag::Installed;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2050,7 +2047,7 @@ void ApiWrap::saveStickerSets(
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
const auto archived = !!(set->flags & Flag::f_archived);
|
const auto archived = !!(set->flags & Flag::Archived);
|
||||||
if (archived && !localRemoved.contains(set->id)) {
|
if (archived && !localRemoved.contains(set->id)) {
|
||||||
const auto mtpSetId = set->mtpInput();
|
const auto mtpSetId = set->mtpInput();
|
||||||
|
|
||||||
|
@ -2069,11 +2066,11 @@ void ApiWrap::saveStickerSets(
|
||||||
|
|
||||||
setDisenableRequests.insert(requestId);
|
setDisenableRequests.insert(requestId);
|
||||||
|
|
||||||
set->flags &= ~Flag::f_archived;
|
set->flags &= ~Flag::Archived;
|
||||||
writeArchived = true;
|
writeArchived = true;
|
||||||
}
|
}
|
||||||
orderRef.push_back(setId);
|
orderRef.push_back(setId);
|
||||||
set->flags |= Flag::f_installed_date;
|
set->flags |= Flag::Installed;
|
||||||
if (!set->installDate) {
|
if (!set->installDate) {
|
||||||
set->installDate = base::unixtime::now();
|
set->installDate = base::unixtime::now();
|
||||||
}
|
}
|
||||||
|
@ -2081,10 +2078,10 @@ void ApiWrap::saveStickerSets(
|
||||||
|
|
||||||
for (auto it = sets.begin(); it != sets.cend();) {
|
for (auto it = sets.begin(); it != sets.cend();) {
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
if ((set->flags & ClientFlag::f_featured)
|
if ((set->flags & Flag::Featured)
|
||||||
|| (set->flags & Flag::f_installed_date)
|
|| (set->flags & Flag::Installed)
|
||||||
|| (set->flags & Flag::f_archived)
|
|| (set->flags & Flag::Archived)
|
||||||
|| (set->flags & ClientFlag::f_special)) {
|
|| (set->flags & Flag::Special)) {
|
||||||
++it;
|
++it;
|
||||||
} else {
|
} else {
|
||||||
it = sets.erase(it);
|
it = sets.erase(it);
|
||||||
|
@ -3303,7 +3300,7 @@ void ApiWrap::readFeaturedSets() {
|
||||||
for (const auto setId : _featuredSetsRead) {
|
for (const auto setId : _featuredSetsRead) {
|
||||||
const auto it = sets.find(setId);
|
const auto it = sets.find(setId);
|
||||||
if (it != sets.cend()) {
|
if (it != sets.cend()) {
|
||||||
it->second->flags &= ~MTPDstickerSet_ClientFlag::f_unread;
|
it->second->flags &= ~Data::StickersSetFlag::Unread;
|
||||||
wrappedIds.append(MTP_long(setId));
|
wrappedIds.append(MTP_long(setId));
|
||||||
if (count) {
|
if (count) {
|
||||||
--count;
|
--count;
|
||||||
|
|
|
@ -51,6 +51,7 @@ constexpr auto kStickersPanelPerRow = 5;
|
||||||
using Data::StickersSet;
|
using Data::StickersSet;
|
||||||
using Data::StickersPack;
|
using Data::StickersPack;
|
||||||
using Data::StickersByEmojiMap;
|
using Data::StickersByEmojiMap;
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
|
@ -77,7 +78,7 @@ public:
|
||||||
void archiveStickers();
|
void archiveStickers();
|
||||||
|
|
||||||
bool isMasksSet() const {
|
bool isMasksSet() const {
|
||||||
return (_setFlags & MTPDstickerSet::Flag::f_masks);
|
return (_setFlags & SetFlag::Masks);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Inner();
|
~Inner();
|
||||||
|
@ -128,7 +129,7 @@ private:
|
||||||
QString _setTitle, _setShortName;
|
QString _setTitle, _setShortName;
|
||||||
int _setCount = 0;
|
int _setCount = 0;
|
||||||
int32 _setHash = 0;
|
int32 _setHash = 0;
|
||||||
MTPDstickerSet::Flags _setFlags = 0;
|
Data::StickersSetFlags _setFlags;
|
||||||
TimeId _setInstallDate = TimeId(0);
|
TimeId _setInstallDate = TimeId(0);
|
||||||
ImageWithLocation _setThumbnail;
|
ImageWithLocation _setThumbnail;
|
||||||
|
|
||||||
|
@ -421,7 +422,8 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
|
||||||
_setAccess = set.vaccess_hash().v;
|
_setAccess = set.vaccess_hash().v;
|
||||||
_setCount = set.vcount().v;
|
_setCount = set.vcount().v;
|
||||||
_setHash = set.vhash().v;
|
_setHash = set.vhash().v;
|
||||||
_setFlags = set.vflags().v;
|
using Flag = Data::StickersSetFlag;
|
||||||
|
_setFlags = Data::ParseStickersSetFlags(set);
|
||||||
_setInstallDate = set.vinstalled_date().value_or(0);
|
_setInstallDate = set.vinstalled_date().value_or(0);
|
||||||
_setThumbnail = [&] {
|
_setThumbnail = [&] {
|
||||||
if (const auto thumbs = set.vthumbs()) {
|
if (const auto thumbs = set.vthumbs()) {
|
||||||
|
@ -441,12 +443,11 @@ void StickerSetBox::Inner::gotSet(const MTPmessages_StickerSet &set) {
|
||||||
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();
|
const auto set = it->second.get();
|
||||||
using ClientFlag = MTPDstickerSet_ClientFlag;
|
|
||||||
const auto clientFlags = set->flags
|
const auto clientFlags = set->flags
|
||||||
& (ClientFlag::f_featured
|
& (SetFlag::Featured
|
||||||
| ClientFlag::f_not_loaded
|
| SetFlag::NotLoaded
|
||||||
| ClientFlag::f_unread
|
| SetFlag::Unread
|
||||||
| ClientFlag::f_special);
|
| SetFlag::Special);
|
||||||
_setFlags |= clientFlags;
|
_setFlags |= clientFlags;
|
||||||
set->flags = _setFlags;
|
set->flags = _setFlags;
|
||||||
set->installDate = _setInstallDate;
|
set->installDate = _setInstallDate;
|
||||||
|
@ -492,7 +493,7 @@ void StickerSetBox::Inner::installDone(
|
||||||
auto &sets = stickers.setsRef();
|
auto &sets = stickers.setsRef();
|
||||||
const auto isMasks = isMasksSet();
|
const auto isMasks = isMasksSet();
|
||||||
|
|
||||||
const bool wasArchived = (_setFlags & MTPDstickerSet::Flag::f_archived);
|
const bool wasArchived = (_setFlags & SetFlag::Archived);
|
||||||
if (wasArchived) {
|
if (wasArchived) {
|
||||||
const auto index = (isMasks
|
const auto index = (isMasks
|
||||||
? stickers.archivedMaskSetsOrderRef()
|
? stickers.archivedMaskSetsOrderRef()
|
||||||
|
@ -504,8 +505,8 @@ void StickerSetBox::Inner::installDone(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
_setInstallDate = base::unixtime::now();
|
_setInstallDate = base::unixtime::now();
|
||||||
_setFlags &= ~MTPDstickerSet::Flag::f_archived;
|
_setFlags &= ~SetFlag::Archived;
|
||||||
_setFlags |= MTPDstickerSet::Flag::f_installed_date;
|
_setFlags |= SetFlag::Installed;
|
||||||
auto it = sets.find(_setId);
|
auto it = sets.find(_setId);
|
||||||
if (it == sets.cend()) {
|
if (it == sets.cend()) {
|
||||||
it = sets.emplace(
|
it = sets.emplace(
|
||||||
|
@ -843,8 +844,8 @@ bool StickerSetBox::Inner::notInstalled() const {
|
||||||
const auto &sets = _controller->session().data().stickers().sets();
|
const auto &sets = _controller->session().data().stickers().sets();
|
||||||
const auto it = sets.find(_setId);
|
const auto it = sets.find(_setId);
|
||||||
if ((it == sets.cend())
|
if ((it == sets.cend())
|
||||||
|| !(it->second->flags & MTPDstickerSet::Flag::f_installed_date)
|
|| !(it->second->flags & SetFlag::Installed)
|
||||||
|| (it->second->flags & MTPDstickerSet::Flag::f_archived)) {
|
|| (it->second->flags & SetFlag::Archived)) {
|
||||||
return !_pack.empty();
|
return !_pack.empty();
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -45,6 +45,7 @@ namespace {
|
||||||
using Data::StickersSet;
|
using Data::StickersSet;
|
||||||
using Data::StickersSetsOrder;
|
using Data::StickersSetsOrder;
|
||||||
using Data::StickersSetThumbnailView;
|
using Data::StickersSetThumbnailView;
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
constexpr auto kArchivedLimitFirstRequest = 10;
|
constexpr auto kArchivedLimitFirstRequest = 10;
|
||||||
constexpr auto kArchivedLimitPerPage = 30;
|
constexpr auto kArchivedLimitPerPage = 30;
|
||||||
|
@ -429,8 +430,11 @@ void StickersBox::showAttachedStickers() {
|
||||||
if (const auto set = session().data().stickers().feedSet(*setData)) {
|
if (const auto set = session().data().stickers().feedSet(*setData)) {
|
||||||
if (_attached.widget()->appendSet(set)) {
|
if (_attached.widget()->appendSet(set)) {
|
||||||
addedSet = true;
|
addedSet = true;
|
||||||
if (set->stickers.isEmpty() || (set->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
if (set->stickers.isEmpty()
|
||||||
session().api().scheduleStickerSetRequest(set->id, set->access);
|
|| (set->flags & SetFlag::NotLoaded)) {
|
||||||
|
session().api().scheduleStickerSetRequest(
|
||||||
|
set->id,
|
||||||
|
set->access);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -495,8 +499,11 @@ void StickersBox::getArchivedDone(
|
||||||
}
|
}
|
||||||
if (_archived.widget()->appendSet(set)) {
|
if (_archived.widget()->appendSet(set)) {
|
||||||
addedSet = true;
|
addedSet = true;
|
||||||
if (set->stickers.isEmpty() || (set->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
if (set->stickers.isEmpty()
|
||||||
session().api().scheduleStickerSetRequest(set->id, set->access);
|
|| (set->flags & SetFlag::NotLoaded)) {
|
||||||
|
session().api().scheduleStickerSetRequest(
|
||||||
|
set->id,
|
||||||
|
set->access);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -682,7 +689,7 @@ void StickersBox::loadMoreArchived() {
|
||||||
--setIt;
|
--setIt;
|
||||||
auto it = sets.find(*setIt);
|
auto it = sets.find(*setIt);
|
||||||
if (it != sets.cend()) {
|
if (it != sets.cend()) {
|
||||||
if (it->second->flags & MTPDstickerSet::Flag::f_archived) {
|
if (it->second->flags & SetFlag::Archived) {
|
||||||
lastId = it->second->id;
|
lastId = it->second->id;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -834,8 +841,8 @@ void StickersBox::installSet(uint64 setId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!(set->flags & MTPDstickerSet::Flag::f_installed_date)
|
if (!(set->flags & SetFlag::Installed)
|
||||||
|| (set->flags & MTPDstickerSet::Flag::f_archived)) {
|
|| (set->flags & SetFlag::Archived)) {
|
||||||
_api.request(MTPmessages_InstallStickerSet(
|
_api.request(MTPmessages_InstallStickerSet(
|
||||||
set->mtpInput(),
|
set->mtpInput(),
|
||||||
MTP_boolFalse()
|
MTP_boolFalse()
|
||||||
|
@ -896,7 +903,8 @@ void StickersBox::requestArchivedSets() {
|
||||||
auto it = sets.find(setId);
|
auto it = sets.find(setId);
|
||||||
if (it != sets.cend()) {
|
if (it != sets.cend()) {
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
if (set->stickers.isEmpty() && (set->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
if (set->stickers.isEmpty()
|
||||||
|
&& (set->flags & SetFlag::NotLoaded)) {
|
||||||
session().api().scheduleStickerSetRequest(setId, set->access);
|
session().api().scheduleStickerSetRequest(setId, set->access);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1042,7 +1050,7 @@ bool StickersBox::Inner::Row::isRecentSet() const {
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StickersBox::Inner::Row::isMasksSet() const {
|
bool StickersBox::Inner::Row::isMasksSet() const {
|
||||||
return (set->flags & MTPDstickerSet::Flag::f_masks);
|
return (set->flags & SetFlag::Masks);
|
||||||
}
|
}
|
||||||
|
|
||||||
StickersBox::Inner::Inner(
|
StickersBox::Inner::Inner(
|
||||||
|
@ -1909,7 +1917,7 @@ void StickersBox::Inner::rebuildMegagroupSet() {
|
||||||
const auto &sets = session().data().stickers().sets();
|
const auto &sets = session().data().stickers().sets();
|
||||||
auto it = sets.find(setId);
|
auto it = sets.find(setId);
|
||||||
if (it == sets.cend()
|
if (it == sets.cend()
|
||||||
|| (it->second->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
|| (it->second->flags & SetFlag::NotLoaded)) {
|
||||||
session().api().scheduleStickerSetRequest(
|
session().api().scheduleStickerSetRequest(
|
||||||
_megagroupSetInput.id,
|
_megagroupSetInput.id,
|
||||||
_megagroupSetInput.accessHash);
|
_megagroupSetInput.accessHash);
|
||||||
|
@ -2011,7 +2019,7 @@ void StickersBox::Inner::rebuild(bool masks) {
|
||||||
rebuildAppendSet(set, maxNameWidth);
|
rebuildAppendSet(set, maxNameWidth);
|
||||||
|
|
||||||
if (set->stickers.isEmpty()
|
if (set->stickers.isEmpty()
|
||||||
|| (set->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
|| (set->flags & SetFlag::NotLoaded)) {
|
||||||
session().api().scheduleStickerSetRequest(set->id, set->access);
|
session().api().scheduleStickerSetRequest(set->id, set->access);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2226,11 +2234,11 @@ void StickersBox::Inner::fillSetFlags(
|
||||||
bool *outOfficial,
|
bool *outOfficial,
|
||||||
bool *outUnread,
|
bool *outUnread,
|
||||||
bool *outArchived) {
|
bool *outArchived) {
|
||||||
*outInstalled = (set->flags & MTPDstickerSet::Flag::f_installed_date);
|
*outInstalled = (set->flags & SetFlag::Installed);
|
||||||
*outOfficial = (set->flags & MTPDstickerSet::Flag::f_official);
|
*outOfficial = (set->flags & SetFlag::Official);
|
||||||
*outArchived = (set->flags & MTPDstickerSet::Flag::f_archived);
|
*outArchived = (set->flags & SetFlag::Archived);
|
||||||
if (_section == Section::Featured) {
|
if (_section == Section::Featured) {
|
||||||
*outUnread = (set->flags & MTPDstickerSet_ClientFlag::f_unread);
|
*outUnread = (set->flags & SetFlag::Unread);
|
||||||
} else {
|
} else {
|
||||||
*outUnread = false;
|
*outUnread = false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -57,10 +57,10 @@ constexpr auto kOfficialLoadLimit = 40;
|
||||||
using Data::StickersSet;
|
using Data::StickersSet;
|
||||||
using Data::StickersPack;
|
using Data::StickersPack;
|
||||||
using Data::StickersSetThumbnailView;
|
using Data::StickersSetThumbnailView;
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
bool SetInMyList(MTPDstickerSet::Flags flags) {
|
[[nodiscard]] bool SetInMyList(Data::StickersSetFlags flags) {
|
||||||
return (flags & MTPDstickerSet::Flag::f_installed_date)
|
return (flags & SetFlag::Installed) && !(flags & SetFlag::Archived);
|
||||||
&& !(flags & MTPDstickerSet::Flag::f_archived);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
@ -218,7 +218,7 @@ auto StickersListWidget::PrepareStickers(
|
||||||
StickersListWidget::Set::Set(
|
StickersListWidget::Set::Set(
|
||||||
uint64 id,
|
uint64 id,
|
||||||
StickersSet *set,
|
StickersSet *set,
|
||||||
MTPDstickerSet::Flags flags,
|
Data::StickersSetFlags flags,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
const QString &shortName,
|
const QString &shortName,
|
||||||
int count,
|
int count,
|
||||||
|
@ -1110,7 +1110,7 @@ void StickersListWidget::readVisibleFeatured(
|
||||||
const auto rowTo = ceilclamp(visibleBottom, rowHeight, 0, _featuredSetsCount);
|
const auto rowTo = ceilclamp(visibleBottom, rowHeight, 0, _featuredSetsCount);
|
||||||
for (auto i = rowFrom; i < rowTo; ++i) {
|
for (auto i = rowFrom; i < rowTo; ++i) {
|
||||||
auto &set = _officialSets[i];
|
auto &set = _officialSets[i];
|
||||||
if (!(set.flags & MTPDstickerSet_ClientFlag::f_unread)) {
|
if (!(set.flags & SetFlag::Unread)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (i * rowHeight < visibleTop || (i + 1) * rowHeight > visibleBottom) {
|
if (i * rowHeight < visibleTop || (i + 1) * rowHeight > visibleBottom) {
|
||||||
|
@ -1604,8 +1604,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
||||||
auto &set = sets[info.section];
|
auto &set = sets[info.section];
|
||||||
if (set.externalLayout) {
|
if (set.externalLayout) {
|
||||||
const auto loadedCount = int(set.stickers.size());
|
const auto loadedCount = int(set.stickers.size());
|
||||||
const auto count = (set.flags
|
const auto count = (set.flags & SetFlag::NotLoaded)
|
||||||
& MTPDstickerSet_ClientFlag::f_not_loaded)
|
|
||||||
? set.count
|
? set.count
|
||||||
: loadedCount;
|
: loadedCount;
|
||||||
|
|
||||||
|
@ -1633,7 +1632,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
||||||
int checky = add.top() + (add.height() - st::stickersFeaturedInstalled.height()) / 2;
|
int checky = add.top() + (add.height() - st::stickersFeaturedInstalled.height()) / 2;
|
||||||
st::stickersFeaturedInstalled.paint(p, QPoint(checkx, checky), width());
|
st::stickersFeaturedInstalled.paint(p, QPoint(checkx, checky), width());
|
||||||
}
|
}
|
||||||
if (set.flags & MTPDstickerSet_ClientFlag::f_unread) {
|
if (set.flags & SetFlag::Unread) {
|
||||||
widthForTitle -= st::stickersFeaturedUnreadSize + st::stickersFeaturedUnreadSkip;
|
widthForTitle -= st::stickersFeaturedUnreadSize + st::stickersFeaturedUnreadSkip;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1647,7 +1646,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
||||||
p.setPen(st::stickersTrendingHeaderFg);
|
p.setPen(st::stickersTrendingHeaderFg);
|
||||||
p.drawTextLeft(st::emojiPanHeaderLeft - st::roundRadiusSmall, info.top + st::stickersTrendingHeaderTop, width(), titleText, titleWidth);
|
p.drawTextLeft(st::emojiPanHeaderLeft - st::roundRadiusSmall, info.top + st::stickersTrendingHeaderTop, width(), titleText, titleWidth);
|
||||||
|
|
||||||
if (set.flags & MTPDstickerSet_ClientFlag::f_unread) {
|
if (set.flags & SetFlag::Unread) {
|
||||||
p.setPen(Qt::NoPen);
|
p.setPen(Qt::NoPen);
|
||||||
p.setBrush(st::stickersFeaturedUnreadBg);
|
p.setBrush(st::stickersFeaturedUnreadBg);
|
||||||
|
|
||||||
|
@ -1709,7 +1708,7 @@ void StickersListWidget::paintStickers(Painter &p, QRect clip) {
|
||||||
paintMegagroupEmptySet(p, info.rowsTop, buttonSelected);
|
paintMegagroupEmptySet(p, info.rowsTop, buttonSelected);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
auto special = (set.flags & MTPDstickerSet::Flag::f_official) != 0;
|
auto special = (set.flags & SetFlag::Official) != 0;
|
||||||
auto fromRow = floorclamp(clip.y() - info.rowsTop, _singleSize.height(), 0, info.rowsCount);
|
auto fromRow = floorclamp(clip.y() - info.rowsTop, _singleSize.height(), 0, info.rowsCount);
|
||||||
auto toRow = ceilclamp(clip.y() + clip.height() - info.rowsTop, _singleSize.height(), 0, info.rowsCount);
|
auto toRow = ceilclamp(clip.y() + clip.height() - info.rowsTop, _singleSize.height(), 0, info.rowsCount);
|
||||||
for (int i = fromRow; i < toRow; ++i) {
|
for (int i = fromRow; i < toRow; ++i) {
|
||||||
|
@ -2024,7 +2023,7 @@ bool StickersListWidget::hasRemoveButton(int index) const {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
auto flags = set.flags;
|
auto flags = set.flags;
|
||||||
if (!(flags & MTPDstickerSet_ClientFlag::f_special)) {
|
if (!(flags & SetFlag::Special)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
if (set.id == Data::Stickers::MegagroupSetId) {
|
if (set.id == Data::Stickers::MegagroupSetId) {
|
||||||
|
@ -2458,8 +2457,8 @@ void StickersListWidget::refreshFeaturedSets() {
|
||||||
auto &set = *i;
|
auto &set = *i;
|
||||||
auto it = sets.find(set.id);
|
auto it = sets.find(set.id);
|
||||||
if (it == sets.cend()
|
if (it == sets.cend()
|
||||||
|| ((it->second->flags & MTPDstickerSet::Flag::f_installed_date)
|
|| ((it->second->flags & SetFlag::Installed)
|
||||||
&& !(it->second->flags & MTPDstickerSet::Flag::f_archived)
|
&& !(it->second->flags & SetFlag::Archived)
|
||||||
&& !_installedLocallySets.contains(set.id))) {
|
&& !_installedLocallySets.contains(set.id))) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -2492,7 +2491,7 @@ void StickersListWidget::refreshSearchSets() {
|
||||||
void StickersListWidget::refreshSearchIndex() {
|
void StickersListWidget::refreshSearchIndex() {
|
||||||
_searchIndex.clear();
|
_searchIndex.clear();
|
||||||
for (const auto &set : _mySets) {
|
for (const auto &set : _mySets) {
|
||||||
if (set.flags & MTPDstickerSet_ClientFlag::f_special) {
|
if (set.flags & SetFlag::Special) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto string = set.title + ' ' + set.shortName;
|
const auto string = set.title + ' ' + set.shortName;
|
||||||
|
@ -2544,12 +2543,12 @@ bool StickersListWidget::appendSet(
|
||||||
}
|
}
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
if ((skip == AppendSkip::Archived)
|
if ((skip == AppendSkip::Archived)
|
||||||
&& (set->flags & MTPDstickerSet::Flag::f_archived)) {
|
&& (set->flags & SetFlag::Archived)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if ((skip == AppendSkip::Installed)
|
if ((skip == AppendSkip::Installed)
|
||||||
&& (set->flags & MTPDstickerSet::Flag::f_installed_date)
|
&& (set->flags & SetFlag::Installed)
|
||||||
&& !(set->flags & MTPDstickerSet::Flag::f_archived)) {
|
&& !(set->flags & SetFlag::Archived)) {
|
||||||
if (!_installedLocallySets.contains(setId)) {
|
if (!_installedLocallySets.contains(setId)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
@ -2648,8 +2647,7 @@ void StickersListWidget::refreshRecentStickers(bool performResize) {
|
||||||
auto set = Set(
|
auto set = Set(
|
||||||
Data::Stickers::RecentSetId,
|
Data::Stickers::RecentSetId,
|
||||||
nullptr,
|
nullptr,
|
||||||
(MTPDstickerSet::Flag::f_official
|
(SetFlag::Official | SetFlag::Special),
|
||||||
| MTPDstickerSet_ClientFlag::f_special),
|
|
||||||
tr::lng_recent_stickers(tr::now),
|
tr::lng_recent_stickers(tr::now),
|
||||||
shortName,
|
shortName,
|
||||||
recentPack.size(),
|
recentPack.size(),
|
||||||
|
@ -2691,8 +2689,7 @@ void StickersListWidget::refreshFavedStickers() {
|
||||||
_mySets.insert(_mySets.begin(), Set{
|
_mySets.insert(_mySets.begin(), Set{
|
||||||
Data::Stickers::FavedSetId,
|
Data::Stickers::FavedSetId,
|
||||||
nullptr,
|
nullptr,
|
||||||
(MTPDstickerSet::Flag::f_official
|
(SetFlag::Official | SetFlag::Special),
|
||||||
| MTPDstickerSet_ClientFlag::f_special),
|
|
||||||
Lang::Hard::FavedSetTitle(),
|
Lang::Hard::FavedSetTitle(),
|
||||||
shortName,
|
shortName,
|
||||||
set->count,
|
set->count,
|
||||||
|
@ -2724,7 +2721,7 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
||||||
_mySets.emplace_back(
|
_mySets.emplace_back(
|
||||||
Data::Stickers::MegagroupSetId,
|
Data::Stickers::MegagroupSetId,
|
||||||
nullptr,
|
nullptr,
|
||||||
MTPDstickerSet_ClientFlag::f_special | 0,
|
SetFlag::Special,
|
||||||
tr::lng_group_stickers(tr::now),
|
tr::lng_group_stickers(tr::now),
|
||||||
shortName,
|
shortName,
|
||||||
count,
|
count,
|
||||||
|
@ -2752,8 +2749,8 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
||||||
const auto it = sets.find(set.id);
|
const auto it = sets.find(set.id);
|
||||||
if (it != sets.cend()) {
|
if (it != sets.cend()) {
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
auto isInstalled = (set->flags & MTPDstickerSet::Flag::f_installed_date)
|
auto isInstalled = (set->flags & SetFlag::Installed)
|
||||||
&& !(set->flags & MTPDstickerSet::Flag::f_archived);
|
&& !(set->flags & SetFlag::Archived);
|
||||||
if (isInstalled && !canEdit) {
|
if (isInstalled && !canEdit) {
|
||||||
removeHiddenForGroup();
|
removeHiddenForGroup();
|
||||||
} else if (isShownHere(hidden)) {
|
} else if (isShownHere(hidden)) {
|
||||||
|
@ -2762,7 +2759,7 @@ void StickersListWidget::refreshMegagroupStickers(GroupStickersPlace place) {
|
||||||
_mySets.emplace_back(
|
_mySets.emplace_back(
|
||||||
Data::Stickers::MegagroupSetId,
|
Data::Stickers::MegagroupSetId,
|
||||||
set,
|
set,
|
||||||
MTPDstickerSet_ClientFlag::f_special | 0,
|
SetFlag::Special,
|
||||||
tr::lng_group_stickers(tr::now),
|
tr::lng_group_stickers(tr::now),
|
||||||
shortName,
|
shortName,
|
||||||
set->count,
|
set->count,
|
||||||
|
@ -2868,7 +2865,7 @@ void StickersListWidget::updateSelected() {
|
||||||
newSelected = OverButton { section };
|
newSelected = OverButton { section };
|
||||||
} else if (featuredHasAddButton(section) && myrtlrect(featuredAddRect(section)).contains(p.x(), p.y())) {
|
} else if (featuredHasAddButton(section) && myrtlrect(featuredAddRect(section)).contains(p.x(), p.y())) {
|
||||||
newSelected = OverButton{ section };
|
newSelected = OverButton{ section };
|
||||||
} else if (!(sets[section].flags & MTPDstickerSet_ClientFlag::f_special)) {
|
} else if (!(sets[section].flags & SetFlag::Special)) {
|
||||||
newSelected = OverSet { section };
|
newSelected = OverSet { section };
|
||||||
} else if (sets[section].id == Data::Stickers::MegagroupSetId
|
} else if (sets[section].id == Data::Stickers::MegagroupSetId
|
||||||
&& (_megagroupSet->canEditStickers() || !sets[section].stickers.empty())) {
|
&& (_megagroupSet->canEditStickers() || !sets[section].stickers.empty())) {
|
||||||
|
@ -2882,7 +2879,7 @@ void StickersListWidget::updateSelected() {
|
||||||
newSelected = OverGroupAdd {};
|
newSelected = OverGroupAdd {};
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
auto special = ((set.flags & MTPDstickerSet::Flag::f_official) != 0);
|
auto special = ((set.flags & SetFlag::Official) != 0);
|
||||||
auto rowIndex = qFloor(yOffset / _singleSize.height());
|
auto rowIndex = qFloor(yOffset / _singleSize.height());
|
||||||
auto columnIndex = qFloor(sx / _singleSize.width());
|
auto columnIndex = qFloor(sx / _singleSize.width());
|
||||||
auto index = rowIndex * _columnCount + columnIndex;
|
auto index = rowIndex * _columnCount + columnIndex;
|
||||||
|
@ -3113,8 +3110,7 @@ void StickersListWidget::installSet(uint64 setId) {
|
||||||
if (it != sets.cend()) {
|
if (it != sets.cend()) {
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
const auto input = set->mtpInput();
|
const auto input = set->mtpInput();
|
||||||
if ((set->flags & MTPDstickerSet_ClientFlag::f_not_loaded)
|
if ((set->flags & SetFlag::NotLoaded) || set->stickers.empty()) {
|
||||||
|| set->stickers.empty()) {
|
|
||||||
_api.request(MTPmessages_GetStickerSet(
|
_api.request(MTPmessages_GetStickerSet(
|
||||||
input
|
input
|
||||||
)).done([=](const MTPmessages_StickerSet &result) {
|
)).done([=](const MTPmessages_StickerSet &result) {
|
||||||
|
@ -3212,13 +3208,13 @@ void StickersListWidget::removeSet(uint64 setId) {
|
||||||
++i;
|
++i;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
set->flags &= ~MTPDstickerSet::Flag::f_installed_date;
|
set->flags &= ~SetFlag::Installed;
|
||||||
set->installDate = TimeId(0);
|
set->installDate = TimeId(0);
|
||||||
//
|
//
|
||||||
// Set can be in search results.
|
// Set can be in search results.
|
||||||
//
|
//
|
||||||
//if (!(set->flags & MTPDstickerSet_ClientFlag::f_featured)
|
//if (!(set->flags & SetFlag::Featured)
|
||||||
// && !(set->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
// && !(set->flags & SetFlag::Special)) {
|
||||||
// sets.erase(it);
|
// sets.erase(it);
|
||||||
//}
|
//}
|
||||||
const auto removeIndex = defaultSetsOrder().indexOf(
|
const auto removeIndex = defaultSetsOrder().indexOf(
|
||||||
|
@ -3227,7 +3223,7 @@ void StickersListWidget::removeSet(uint64 setId) {
|
||||||
defaultSetsOrderRef().removeAt(removeIndex);
|
defaultSetsOrderRef().removeAt(removeIndex);
|
||||||
}
|
}
|
||||||
refreshStickers();
|
refreshStickers();
|
||||||
if (set->flags & MTPDstickerSet::Flag::f_masks) {
|
if (set->flags & SetFlag::Masks) {
|
||||||
session().local().writeInstalledMasks();
|
session().local().writeInstalledMasks();
|
||||||
} else {
|
} else {
|
||||||
session().local().writeInstalledStickers();
|
session().local().writeInstalledStickers();
|
||||||
|
|
|
@ -192,7 +192,7 @@ private:
|
||||||
Set(
|
Set(
|
||||||
uint64 id,
|
uint64 id,
|
||||||
Data::StickersSet *set,
|
Data::StickersSet *set,
|
||||||
MTPDstickerSet::Flags flags,
|
Data::StickersSetFlags flags,
|
||||||
const QString &title,
|
const QString &title,
|
||||||
const QString &shortName,
|
const QString &shortName,
|
||||||
int count,
|
int count,
|
||||||
|
@ -204,7 +204,7 @@ private:
|
||||||
|
|
||||||
uint64 id = 0;
|
uint64 id = 0;
|
||||||
Data::StickersSet *set = nullptr;
|
Data::StickersSet *set = nullptr;
|
||||||
MTPDstickerSet::Flags flags = MTPDstickerSet::Flags();
|
Data::StickersSetFlags flags;
|
||||||
QString title;
|
QString title;
|
||||||
QString shortName;
|
QString shortName;
|
||||||
std::vector<Sticker> stickers;
|
std::vector<Sticker> stickers;
|
||||||
|
@ -218,7 +218,7 @@ private:
|
||||||
};
|
};
|
||||||
struct FeaturedSet {
|
struct FeaturedSet {
|
||||||
uint64 id = 0;
|
uint64 id = 0;
|
||||||
MTPDstickerSet::Flags flags = MTPDstickerSet::Flags();
|
Data::StickersSetFlags flags;
|
||||||
std::vector<Sticker> stickers;
|
std::vector<Sticker> stickers;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -1051,18 +1051,20 @@ bool DocumentData::saveFromDataChecked() {
|
||||||
bool DocumentData::isStickerSetInstalled() const {
|
bool DocumentData::isStickerSetInstalled() const {
|
||||||
Expects(sticker() != nullptr);
|
Expects(sticker() != nullptr);
|
||||||
|
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
const auto &sets = _owner->stickers().sets();
|
const auto &sets = _owner->stickers().sets();
|
||||||
if (const auto id = sticker()->set.id) {
|
if (const auto id = sticker()->set.id) {
|
||||||
const auto i = sets.find(id);
|
const auto i = sets.find(id);
|
||||||
return (i != sets.cend())
|
return (i != sets.cend())
|
||||||
&& !(i->second->flags & MTPDstickerSet::Flag::f_archived)
|
&& !(i->second->flags & SetFlag::Archived)
|
||||||
&& (i->second->flags & MTPDstickerSet::Flag::f_installed_date);
|
&& (i->second->flags & SetFlag::Installed);
|
||||||
} else if (!sticker()->set.shortName.isEmpty()) {
|
} else if (!sticker()->set.shortName.isEmpty()) {
|
||||||
const auto name = sticker()->set.shortName.toLower();
|
const auto name = sticker()->set.shortName.toLower();
|
||||||
for (const auto &[id, set] : sets) {
|
for (const auto &[id, set] : sets) {
|
||||||
if (set->shortName.toLower() == name) {
|
if (set->shortName.toLower() == name) {
|
||||||
return !(set->flags & MTPDstickerSet::Flag::f_archived)
|
return !(set->flags & SetFlag::Archived)
|
||||||
&& (set->flags & MTPDstickerSet::Flag::f_installed_date);
|
&& (set->flags & SetFlag::Installed);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
|
|
@ -29,9 +29,10 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
|
||||||
#include "styles/style_chat_helpers.h"
|
#include "styles/style_chat_helpers.h"
|
||||||
|
|
||||||
namespace Data {
|
namespace Data {
|
||||||
|
|
||||||
namespace {
|
namespace {
|
||||||
|
|
||||||
|
using SetFlag = StickersSetFlag;
|
||||||
|
|
||||||
void RemoveFromSet(
|
void RemoveFromSet(
|
||||||
StickersSets &sets,
|
StickersSets &sets,
|
||||||
not_null<DocumentData*> document,
|
not_null<DocumentData*> document,
|
||||||
|
@ -130,7 +131,7 @@ void Stickers::incrementSticker(not_null<DocumentData*> document) {
|
||||||
QString(),
|
QString(),
|
||||||
0, // count
|
0, // count
|
||||||
0, // hash
|
0, // hash
|
||||||
MTPDstickerSet_ClientFlag::f_special | 0,
|
SetFlag::Special,
|
||||||
TimeId(0))).first;
|
TimeId(0))).first;
|
||||||
} else {
|
} else {
|
||||||
it->second->title = tr::lng_recent_stickers(tr::now);
|
it->second->title = tr::lng_recent_stickers(tr::now);
|
||||||
|
@ -288,7 +289,7 @@ void Stickers::applyArchivedResult(
|
||||||
if (set->stickers.isEmpty()) {
|
if (set->stickers.isEmpty()) {
|
||||||
setsToRequest.insert(set->id, set->access);
|
setsToRequest.insert(set->id, set->access);
|
||||||
}
|
}
|
||||||
const auto masks = !!(set->flags & MTPDstickerSet::Flag::f_masks);
|
const auto masks = !!(set->flags & SetFlag::Masks);
|
||||||
(masks ? masksCount : stickersCount)++;
|
(masks ? masksCount : stickersCount)++;
|
||||||
auto &order = masks ? maskSetsOrderRef() : setsOrderRef();
|
auto &order = masks ? maskSetsOrderRef() : setsOrderRef();
|
||||||
const auto index = order.indexOf(set->id);
|
const auto index = order.indexOf(set->id);
|
||||||
|
@ -325,41 +326,6 @@ void Stickers::applyArchivedResult(
|
||||||
notifyUpdated();
|
notifyUpdated();
|
||||||
}
|
}
|
||||||
|
|
||||||
// For testing: Just apply random subset or your sticker sets as archived.
|
|
||||||
bool Stickers::applyArchivedResultFake() {
|
|
||||||
auto sets = QVector<MTPStickerSetCovered>();
|
|
||||||
for (const auto &[id, set] : this->sets()) {
|
|
||||||
const auto raw = set.get();
|
|
||||||
if ((raw->flags & MTPDstickerSet::Flag::f_installed_date)
|
|
||||||
&& !(raw->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
|
||||||
if (openssl::RandomValue<uint32>() % 128 < 64) {
|
|
||||||
const auto data = MTP_stickerSet(
|
|
||||||
MTP_flags(raw->flags | MTPDstickerSet::Flag::f_archived),
|
|
||||||
MTP_int(raw->installDate),
|
|
||||||
MTP_long(raw->id),
|
|
||||||
MTP_long(raw->access),
|
|
||||||
MTP_string(raw->title),
|
|
||||||
MTP_string(raw->shortName),
|
|
||||||
MTP_vector<MTPPhotoSize>(),
|
|
||||||
MTP_int(0),
|
|
||||||
MTP_int(0),
|
|
||||||
MTP_int(raw->count),
|
|
||||||
MTP_int(raw->hash));
|
|
||||||
sets.push_back(MTP_stickerSetCovered(
|
|
||||||
data,
|
|
||||||
MTP_documentEmpty(MTP_long(0))));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (sets.size() > 3) {
|
|
||||||
sets = sets.mid(0, 3);
|
|
||||||
}
|
|
||||||
auto result = MTP_messages_stickerSetInstallResultArchive(
|
|
||||||
MTP_vector<MTPStickerSetCovered>(sets));
|
|
||||||
applyArchivedResult(result.c_messages_stickerSetInstallResultArchive());
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Stickers::installLocally(uint64 setId) {
|
void Stickers::installLocally(uint64 setId) {
|
||||||
auto &sets = setsRef();
|
auto &sets = setsRef();
|
||||||
auto it = sets.find(setId);
|
auto it = sets.find(setId);
|
||||||
|
@ -369,13 +335,12 @@ 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
|
set->flags &= ~(SetFlag::Archived | SetFlag::Unread);
|
||||||
| MTPDstickerSet_ClientFlag::f_unread);
|
set->flags |= SetFlag::Installed;
|
||||||
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;
|
||||||
|
|
||||||
const auto masks = !!(flags & MTPDstickerSet::Flag::f_masks);
|
const auto masks = !!(flags & SetFlag::Masks);
|
||||||
auto &order = masks ? maskSetsOrderRef() : setsOrderRef();
|
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) {
|
||||||
|
@ -397,10 +362,10 @@ void Stickers::installLocally(uint64 setId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session().local().writeInstalledStickers();
|
session().local().writeInstalledStickers();
|
||||||
if (changedFlags & MTPDstickerSet_ClientFlag::f_unread) {
|
if (changedFlags & SetFlag::Unread) {
|
||||||
session().local().writeFeaturedStickers();
|
session().local().writeFeaturedStickers();
|
||||||
}
|
}
|
||||||
if (changedFlags & MTPDstickerSet::Flag::f_archived) {
|
if (changedFlags & SetFlag::Archived) {
|
||||||
auto &archivedOrder = masks
|
auto &archivedOrder = masks
|
||||||
? archivedMaskSetsOrderRef()
|
? archivedMaskSetsOrderRef()
|
||||||
: archivedSetsOrderRef();
|
: archivedSetsOrderRef();
|
||||||
|
@ -425,7 +390,7 @@ void Stickers::undoInstallLocally(uint64 setId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
set->flags &= ~MTPDstickerSet::Flag::f_installed_date;
|
set->flags &= ~SetFlag::Installed;
|
||||||
set->installDate = TimeId(0);
|
set->installDate = TimeId(0);
|
||||||
|
|
||||||
auto &order = setsOrderRef();
|
auto &order = setsOrderRef();
|
||||||
|
@ -519,7 +484,7 @@ void Stickers::setIsFaved(
|
||||||
QString(),
|
QString(),
|
||||||
0, // count
|
0, // count
|
||||||
0, // hash
|
0, // hash
|
||||||
MTPDstickerSet_ClientFlag::f_special | 0,
|
SetFlag::Special,
|
||||||
TimeId(0))).first;
|
TimeId(0))).first;
|
||||||
}
|
}
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
|
@ -610,17 +575,14 @@ void Stickers::setsReceived(const QVector<MTPStickerSet> &data, int32 hash) {
|
||||||
: setsOrderRef();
|
: setsOrderRef();
|
||||||
setsOrder.clear();
|
setsOrder.clear();
|
||||||
|
|
||||||
using Flag = MTPDstickerSet::Flag;
|
|
||||||
using ClientFlag = MTPDstickerSet_ClientFlag;
|
|
||||||
|
|
||||||
auto &sets = setsRef();
|
auto &sets = setsRef();
|
||||||
QMap<uint64, uint64> setsToRequest;
|
QMap<uint64, uint64> setsToRequest;
|
||||||
for (auto &[id, set] : sets) {
|
for (auto &[id, set] : sets) {
|
||||||
const auto archived = !!(set->flags & Flag::f_archived);
|
const auto archived = !!(set->flags & SetFlag::Archived);
|
||||||
const auto masks = !!(set->flags & MTPDstickerSet::Flag::f_masks);
|
const auto masks = !!(set->flags & SetFlag::Masks);
|
||||||
if (!archived && (masksReceived == masks)) {
|
if (!archived && (masksReceived == masks)) {
|
||||||
// Mark for removing.
|
// Mark for removing.
|
||||||
set->flags &= ~Flag::f_installed_date;
|
set->flags &= ~SetFlag::Installed;
|
||||||
set->installDate = 0;
|
set->installDate = 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -629,11 +591,11 @@ void Stickers::setsReceived(const QVector<MTPStickerSet> &data, int32 hash) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto set = feedSet(setData.c_stickerSet());
|
const auto set = feedSet(setData.c_stickerSet());
|
||||||
if (!(set->flags & Flag::f_archived)
|
if (!(set->flags & SetFlag::Archived)
|
||||||
|| (set->flags & Flag::f_official)) {
|
|| (set->flags & SetFlag::Official)) {
|
||||||
setsOrder.push_back(set->id);
|
setsOrder.push_back(set->id);
|
||||||
if (set->stickers.isEmpty()
|
if (set->stickers.isEmpty()
|
||||||
|| (set->flags & ClientFlag::f_not_loaded)) {
|
|| (set->flags & SetFlag::NotLoaded)) {
|
||||||
setsToRequest.insert(set->id, set->access);
|
setsToRequest.insert(set->id, set->access);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -642,10 +604,10 @@ void Stickers::setsReceived(const QVector<MTPStickerSet> &data, int32 hash) {
|
||||||
auto &recent = getRecentPack();
|
auto &recent = getRecentPack();
|
||||||
for (auto it = sets.begin(); it != sets.end();) {
|
for (auto it = sets.begin(); it != sets.end();) {
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
const auto installed = !!(set->flags & Flag::f_installed_date);
|
const auto installed = !!(set->flags & SetFlag::Installed);
|
||||||
const auto featured = !!(set->flags & ClientFlag::f_featured);
|
const auto featured = !!(set->flags & SetFlag::Featured);
|
||||||
const auto special = !!(set->flags & ClientFlag::f_special);
|
const auto special = !!(set->flags & SetFlag::Special);
|
||||||
const auto archived = !!(set->flags & Flag::f_archived);
|
const auto archived = !!(set->flags & SetFlag::Archived);
|
||||||
if (!installed) { // remove not mine sets from recent stickers
|
if (!installed) { // remove not mine sets from recent stickers
|
||||||
for (auto i = recent.begin(); i != recent.cend();) {
|
for (auto i = recent.begin(); i != recent.cend();) {
|
||||||
if (set->stickers.indexOf(i->first) >= 0) {
|
if (set->stickers.indexOf(i->first) >= 0) {
|
||||||
|
@ -742,7 +704,7 @@ void Stickers::specialSetReceived(
|
||||||
QString(),
|
QString(),
|
||||||
0, // count
|
0, // count
|
||||||
0, // hash
|
0, // hash
|
||||||
MTPDstickerSet_ClientFlag::f_special | 0,
|
SetFlag::Special,
|
||||||
TimeId(0))).first;
|
TimeId(0))).first;
|
||||||
} else {
|
} else {
|
||||||
it->second->title = setTitle;
|
it->second->title = setTitle;
|
||||||
|
@ -864,7 +826,7 @@ void Stickers::featuredSetsReceived(
|
||||||
auto setsToRequest = base::flat_map<uint64, uint64>();
|
auto setsToRequest = base::flat_map<uint64, uint64>();
|
||||||
for (auto &[id, set] : sets) {
|
for (auto &[id, set] : sets) {
|
||||||
// Mark for removing.
|
// Mark for removing.
|
||||||
set->flags &= ~MTPDstickerSet_ClientFlag::f_featured;
|
set->flags &= ~SetFlag::Featured;
|
||||||
}
|
}
|
||||||
for (const auto &entry : list) {
|
for (const auto &entry : list) {
|
||||||
const auto data = entry.match([&](const auto &data) {
|
const auto data = entry.match([&](const auto &data) {
|
||||||
|
@ -889,12 +851,12 @@ void Stickers::featuredSetsReceived(
|
||||||
}
|
}
|
||||||
return ImageWithLocation();
|
return ImageWithLocation();
|
||||||
}();
|
}();
|
||||||
|
const auto flags = SetFlag::Featured
|
||||||
|
| (unreadMap.contains(data->vid().v)
|
||||||
|
? SetFlag::Unread
|
||||||
|
: SetFlag())
|
||||||
|
| ParseStickersSetFlags(*data);
|
||||||
if (it == sets.cend()) {
|
if (it == sets.cend()) {
|
||||||
auto setClientFlags = MTPDstickerSet_ClientFlag::f_featured
|
|
||||||
| MTPDstickerSet_ClientFlag::f_not_loaded;
|
|
||||||
if (unreadMap.contains(data->vid().v)) {
|
|
||||||
setClientFlags |= MTPDstickerSet_ClientFlag::f_unread;
|
|
||||||
}
|
|
||||||
it = sets.emplace(data->vid().v, std::make_unique<StickersSet>(
|
it = sets.emplace(data->vid().v, std::make_unique<StickersSet>(
|
||||||
&owner(),
|
&owner(),
|
||||||
data->vid().v,
|
data->vid().v,
|
||||||
|
@ -903,7 +865,7 @@ void Stickers::featuredSetsReceived(
|
||||||
qs(data->vshort_name()),
|
qs(data->vshort_name()),
|
||||||
data->vcount().v,
|
data->vcount().v,
|
||||||
data->vhash().v,
|
data->vhash().v,
|
||||||
data->vflags().v | setClientFlags,
|
flags | SetFlag::NotLoaded,
|
||||||
installDate)).first;
|
installDate)).first;
|
||||||
it->second->setThumbnail(thumbnail);
|
it->second->setThumbnail(thumbnail);
|
||||||
} else {
|
} else {
|
||||||
|
@ -911,25 +873,19 @@ void Stickers::featuredSetsReceived(
|
||||||
set->access = data->vaccess_hash().v;
|
set->access = data->vaccess_hash().v;
|
||||||
set->title = title;
|
set->title = title;
|
||||||
set->shortName = qs(data->vshort_name());
|
set->shortName = qs(data->vshort_name());
|
||||||
auto clientFlags = set->flags & (MTPDstickerSet_ClientFlag::f_featured | MTPDstickerSet_ClientFlag::f_unread | MTPDstickerSet_ClientFlag::f_not_loaded | MTPDstickerSet_ClientFlag::f_special);
|
set->flags = flags
|
||||||
set->flags = data->vflags().v | clientFlags;
|
| (set->flags & (SetFlag::NotLoaded | SetFlag::Special));
|
||||||
set->flags |= MTPDstickerSet_ClientFlag::f_featured;
|
|
||||||
set->installDate = installDate;
|
set->installDate = installDate;
|
||||||
set->setThumbnail(thumbnail);
|
set->setThumbnail(thumbnail);
|
||||||
if (unreadMap.contains(set->id)) {
|
|
||||||
set->flags |= MTPDstickerSet_ClientFlag::f_unread;
|
|
||||||
} else {
|
|
||||||
set->flags &= ~MTPDstickerSet_ClientFlag::f_unread;
|
|
||||||
}
|
|
||||||
if (set->count != data->vcount().v || set->hash != data->vhash().v || set->emoji.isEmpty()) {
|
if (set->count != data->vcount().v || set->hash != data->vhash().v || set->emoji.isEmpty()) {
|
||||||
set->count = data->vcount().v;
|
set->count = data->vcount().v;
|
||||||
set->hash = data->vhash().v;
|
set->hash = data->vhash().v;
|
||||||
set->flags |= MTPDstickerSet_ClientFlag::f_not_loaded; // need to request this set
|
set->flags |= SetFlag::NotLoaded; // need to request this set
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
setsOrder.push_back(data->vid().v);
|
setsOrder.push_back(data->vid().v);
|
||||||
if (it->second->stickers.isEmpty()
|
if (it->second->stickers.isEmpty()
|
||||||
|| (it->second->flags & MTPDstickerSet_ClientFlag::f_not_loaded)) {
|
|| (it->second->flags & SetFlag::NotLoaded)) {
|
||||||
setsToRequest.emplace(data->vid().v, data->vaccess_hash().v);
|
setsToRequest.emplace(data->vid().v, data->vaccess_hash().v);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -937,12 +893,12 @@ void Stickers::featuredSetsReceived(
|
||||||
auto unreadCount = 0;
|
auto unreadCount = 0;
|
||||||
for (auto it = sets.begin(); it != sets.end();) {
|
for (auto it = sets.begin(); it != sets.end();) {
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
bool installed = (set->flags & MTPDstickerSet::Flag::f_installed_date);
|
bool installed = (set->flags & SetFlag::Installed);
|
||||||
bool featured = (set->flags & MTPDstickerSet_ClientFlag::f_featured);
|
bool featured = (set->flags & SetFlag::Featured);
|
||||||
bool special = (set->flags & MTPDstickerSet_ClientFlag::f_special);
|
bool special = (set->flags & SetFlag::Special);
|
||||||
bool archived = (set->flags & MTPDstickerSet::Flag::f_archived);
|
bool archived = (set->flags & SetFlag::Archived);
|
||||||
if (installed || featured || special || archived) {
|
if (installed || featured || special || archived) {
|
||||||
if (featured && (set->flags & MTPDstickerSet_ClientFlag::f_unread)) {
|
if (featured && (set->flags & SetFlag::Unread)) {
|
||||||
++unreadCount;
|
++unreadCount;
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
|
@ -1097,7 +1053,7 @@ std::vector<not_null<DocumentData*>> Stickers::getListByEmoji(
|
||||||
}
|
}
|
||||||
const auto addList = [&](
|
const auto addList = [&](
|
||||||
const StickersSetsOrder &order,
|
const StickersSetsOrder &order,
|
||||||
MTPDstickerSet::Flag skip) {
|
SetFlag skip) {
|
||||||
for (const auto setId : order) {
|
for (const auto setId : order) {
|
||||||
auto it = sets.find(setId);
|
auto it = sets.find(setId);
|
||||||
if (it == sets.cend() || (it->second->flags & skip)) {
|
if (it == sets.cend() || (it->second->flags & skip)) {
|
||||||
|
@ -1106,14 +1062,14 @@ std::vector<not_null<DocumentData*>> Stickers::getListByEmoji(
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
if (set->emoji.isEmpty()) {
|
if (set->emoji.isEmpty()) {
|
||||||
setsToRequest.emplace(set->id, set->access);
|
setsToRequest.emplace(set->id, set->access);
|
||||||
set->flags |= MTPDstickerSet_ClientFlag::f_not_loaded;
|
set->flags |= SetFlag::NotLoaded;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
auto i = set->emoji.constFind(original);
|
auto i = set->emoji.constFind(original);
|
||||||
if (i == set->emoji.cend()) {
|
if (i == set->emoji.cend()) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
const auto my = (set->flags & MTPDstickerSet::Flag::f_installed_date);
|
const auto my = (set->flags & SetFlag::Installed);
|
||||||
result.reserve(result.size() + i->size());
|
result.reserve(result.size() + i->size());
|
||||||
for (const auto document : *i) {
|
for (const auto document : *i) {
|
||||||
const auto installDate = my ? set->installDate : TimeId(0);
|
const auto installDate = my ? set->installDate : TimeId(0);
|
||||||
|
@ -1127,12 +1083,8 @@ std::vector<not_null<DocumentData*>> Stickers::getListByEmoji(
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
addList(
|
addList(setsOrder(), SetFlag::Archived);
|
||||||
setsOrder(),
|
//addList(featuredSetsOrder(), SetFlag::Installed);
|
||||||
MTPDstickerSet::Flag::f_archived);
|
|
||||||
//addList(
|
|
||||||
// featuredSetsOrder(),
|
|
||||||
// MTPDstickerSet::Flag::f_installed_date);
|
|
||||||
|
|
||||||
if (!setsToRequest.empty()) {
|
if (!setsToRequest.empty()) {
|
||||||
for (const auto &[setId, accessHash] : setsToRequest) {
|
for (const auto &[setId, accessHash] : setsToRequest) {
|
||||||
|
@ -1195,7 +1147,7 @@ StickersSet *Stickers::feedSet(const MTPDstickerSet &data) {
|
||||||
auto &sets = setsRef();
|
auto &sets = setsRef();
|
||||||
auto it = sets.find(data.vid().v);
|
auto it = sets.find(data.vid().v);
|
||||||
auto title = getSetTitle(data);
|
auto title = getSetTitle(data);
|
||||||
auto flags = MTPDstickerSet::Flags(0);
|
auto oldFlags = StickersSetFlags(0);
|
||||||
const auto thumbnail = [&] {
|
const auto thumbnail = [&] {
|
||||||
if (const auto thumbs = data.vthumbs()) {
|
if (const auto thumbs = data.vthumbs()) {
|
||||||
for (const auto &thumb : thumbs->v) {
|
for (const auto &thumb : thumbs->v) {
|
||||||
|
@ -1210,6 +1162,7 @@ StickersSet *Stickers::feedSet(const MTPDstickerSet &data) {
|
||||||
}
|
}
|
||||||
return ImageWithLocation();
|
return ImageWithLocation();
|
||||||
}();
|
}();
|
||||||
|
const auto flags = ParseStickersSetFlags(data);
|
||||||
if (it == sets.cend()) {
|
if (it == sets.cend()) {
|
||||||
it = sets.emplace(data.vid().v, std::make_unique<StickersSet>(
|
it = sets.emplace(data.vid().v, std::make_unique<StickersSet>(
|
||||||
&owner(),
|
&owner(),
|
||||||
|
@ -1219,7 +1172,7 @@ StickersSet *Stickers::feedSet(const MTPDstickerSet &data) {
|
||||||
qs(data.vshort_name()),
|
qs(data.vshort_name()),
|
||||||
data.vcount().v,
|
data.vcount().v,
|
||||||
data.vhash().v,
|
data.vhash().v,
|
||||||
data.vflags().v | MTPDstickerSet_ClientFlag::f_not_loaded,
|
flags | SetFlag::NotLoaded,
|
||||||
data.vinstalled_date().value_or_empty())).first;
|
data.vinstalled_date().value_or_empty())).first;
|
||||||
it->second->setThumbnail(thumbnail);
|
it->second->setThumbnail(thumbnail);
|
||||||
} else {
|
} else {
|
||||||
|
@ -1227,13 +1180,13 @@ StickersSet *Stickers::feedSet(const MTPDstickerSet &data) {
|
||||||
set->access = data.vaccess_hash().v;
|
set->access = data.vaccess_hash().v;
|
||||||
set->title = title;
|
set->title = title;
|
||||||
set->shortName = qs(data.vshort_name());
|
set->shortName = qs(data.vshort_name());
|
||||||
flags = set->flags;
|
oldFlags = set->flags;
|
||||||
auto clientFlags = set->flags
|
const auto clientFlags = set->flags
|
||||||
& (MTPDstickerSet_ClientFlag::f_featured
|
& (SetFlag::Featured
|
||||||
| MTPDstickerSet_ClientFlag::f_unread
|
| SetFlag::Unread
|
||||||
| MTPDstickerSet_ClientFlag::f_not_loaded
|
| SetFlag::NotLoaded
|
||||||
| MTPDstickerSet_ClientFlag::f_special);
|
| SetFlag::Special);
|
||||||
set->flags = data.vflags().v | clientFlags;
|
set->flags = flags | clientFlags;
|
||||||
const auto installDate = data.vinstalled_date();
|
const auto installDate = data.vinstalled_date();
|
||||||
set->installDate = installDate
|
set->installDate = installDate
|
||||||
? (installDate->v ? installDate->v : base::unixtime::now())
|
? (installDate->v ? installDate->v : base::unixtime::now())
|
||||||
|
@ -1245,18 +1198,18 @@ StickersSet *Stickers::feedSet(const MTPDstickerSet &data) {
|
||||||
// Need to request this data.
|
// Need to request this data.
|
||||||
set->count = data.vcount().v;
|
set->count = data.vcount().v;
|
||||||
set->hash = data.vhash().v;
|
set->hash = data.vhash().v;
|
||||||
set->flags |= MTPDstickerSet_ClientFlag::f_not_loaded;
|
set->flags |= SetFlag::NotLoaded;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
auto changedFlags = (flags ^ set->flags);
|
auto changedFlags = (oldFlags ^ set->flags);
|
||||||
if (changedFlags & MTPDstickerSet::Flag::f_archived) {
|
if (changedFlags & SetFlag::Archived) {
|
||||||
const auto masks = !!(set->flags & MTPDstickerSet::Flag::f_masks);
|
const auto masks = !!(set->flags & SetFlag::Masks);
|
||||||
auto &archivedOrder = masks
|
auto &archivedOrder = masks
|
||||||
? archivedMaskSetsOrderRef()
|
? archivedMaskSetsOrderRef()
|
||||||
: archivedSetsOrderRef();
|
: archivedSetsOrderRef();
|
||||||
const auto index = archivedOrder.indexOf(set->id);
|
const auto index = archivedOrder.indexOf(set->id);
|
||||||
if (set->flags & MTPDstickerSet::Flag::f_archived) {
|
if (set->flags & SetFlag::Archived) {
|
||||||
if (index < 0) {
|
if (index < 0) {
|
||||||
archivedOrder.push_front(set->id);
|
archivedOrder.push_front(set->id);
|
||||||
}
|
}
|
||||||
|
@ -1278,12 +1231,12 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) {
|
||||||
const auto wasArchived = [&] {
|
const auto wasArchived = [&] {
|
||||||
auto it = sets.find(s.vid().v);
|
auto it = sets.find(s.vid().v);
|
||||||
return (it != sets.end())
|
return (it != sets.end())
|
||||||
&& (it->second->flags & MTPDstickerSet::Flag::f_archived);
|
&& (it->second->flags & SetFlag::Archived);
|
||||||
}();
|
}();
|
||||||
|
|
||||||
auto set = feedSet(s);
|
auto set = feedSet(s);
|
||||||
|
|
||||||
set->flags &= ~MTPDstickerSet_ClientFlag::f_not_loaded;
|
set->flags &= ~SetFlag::NotLoaded;
|
||||||
|
|
||||||
const auto &d_docs = d.vdocuments().v;
|
const auto &d_docs = d.vdocuments().v;
|
||||||
auto customIt = sets.find(Stickers::CustomSetId);
|
auto customIt = sets.find(Stickers::CustomSetId);
|
||||||
|
@ -1323,7 +1276,7 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto isMasks = !!(set->flags & MTPDstickerSet::Flag::f_masks);
|
const auto isMasks = !!(set->flags & SetFlag::Masks);
|
||||||
if (pack.isEmpty()) {
|
if (pack.isEmpty()) {
|
||||||
const auto removeIndex = (isMasks
|
const auto removeIndex = (isMasks
|
||||||
? maskSetsOrder()
|
? maskSetsOrder()
|
||||||
|
@ -1365,15 +1318,15 @@ StickersSet *Stickers::feedSetFull(const MTPmessages_StickerSet &data) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (set) {
|
if (set) {
|
||||||
const auto isArchived = !!(set->flags & MTPDstickerSet::Flag::f_archived);
|
const auto isArchived = !!(set->flags & SetFlag::Archived);
|
||||||
if (isMasks) {
|
if (isMasks) {
|
||||||
session().local().writeInstalledMasks();
|
session().local().writeInstalledMasks();
|
||||||
} else if (set->flags & MTPDstickerSet::Flag::f_installed_date) {
|
} else if (set->flags & SetFlag::Installed) {
|
||||||
if (!isArchived) {
|
if (!isArchived) {
|
||||||
session().local().writeInstalledStickers();
|
session().local().writeInstalledStickers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (set->flags & MTPDstickerSet_ClientFlag::f_featured) {
|
if (set->flags & SetFlag::Featured) {
|
||||||
session().local().writeFeaturedStickers();
|
session().local().writeFeaturedStickers();
|
||||||
}
|
}
|
||||||
if (wasArchived != isArchived) {
|
if (wasArchived != isArchived) {
|
||||||
|
|
|
@ -45,6 +45,14 @@ QByteArray StickersSetThumbnailView::content() const {
|
||||||
return _content;
|
return _content;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
StickersSetFlags ParseStickersSetFlags(const MTPDstickerSet &data) {
|
||||||
|
using Flag = StickersSetFlag;
|
||||||
|
return (data.is_archived() ? Flag::Archived : Flag())
|
||||||
|
| (data.is_official() ? Flag::Official : Flag())
|
||||||
|
| (data.is_masks() ? Flag::Masks : Flag())
|
||||||
|
| (data.vinstalled_date() ? Flag::Installed : Flag());
|
||||||
|
}
|
||||||
|
|
||||||
StickersSet::StickersSet(
|
StickersSet::StickersSet(
|
||||||
not_null<Data::Session*> owner,
|
not_null<Data::Session*> owner,
|
||||||
uint64 id,
|
uint64 id,
|
||||||
|
@ -53,7 +61,7 @@ StickersSet::StickersSet(
|
||||||
const QString &shortName,
|
const QString &shortName,
|
||||||
int count,
|
int count,
|
||||||
int32 hash,
|
int32 hash,
|
||||||
MTPDstickerSet::Flags flags,
|
StickersSetFlags flags,
|
||||||
TimeId installDate)
|
TimeId installDate)
|
||||||
: id(id)
|
: id(id)
|
||||||
, access(access)
|
, access(access)
|
||||||
|
|
|
@ -45,6 +45,22 @@ private:
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
enum class StickersSetFlag {
|
||||||
|
Installed = (1 << 0),
|
||||||
|
Archived = (1 << 1),
|
||||||
|
Masks = (1 << 2),
|
||||||
|
Official = (1 << 3),
|
||||||
|
NotLoaded = (1 << 4),
|
||||||
|
Featured = (1 << 5),
|
||||||
|
Unread = (1 << 6),
|
||||||
|
Special = (1 << 7),
|
||||||
|
};
|
||||||
|
inline constexpr bool is_flag_type(StickersSetFlag) { return true; };
|
||||||
|
using StickersSetFlags = base::flags<StickersSetFlag>;
|
||||||
|
|
||||||
|
[[nodiscard]] StickersSetFlags ParseStickersSetFlags(
|
||||||
|
const MTPDstickerSet &data);
|
||||||
|
|
||||||
class StickersSet final {
|
class StickersSet final {
|
||||||
public:
|
public:
|
||||||
StickersSet(
|
StickersSet(
|
||||||
|
@ -55,7 +71,7 @@ public:
|
||||||
const QString &shortName,
|
const QString &shortName,
|
||||||
int count,
|
int count,
|
||||||
int32 hash,
|
int32 hash,
|
||||||
MTPDstickerSet::Flags flags,
|
StickersSetFlags flags,
|
||||||
TimeId installDate);
|
TimeId installDate);
|
||||||
|
|
||||||
[[nodiscard]] Data::Session &owner() const;
|
[[nodiscard]] Data::Session &owner() const;
|
||||||
|
@ -81,7 +97,7 @@ public:
|
||||||
QString title, shortName;
|
QString title, shortName;
|
||||||
int count = 0;
|
int count = 0;
|
||||||
int32 hash = 0;
|
int32 hash = 0;
|
||||||
MTPDstickerSet::Flags flags;
|
StickersSetFlags flags;
|
||||||
TimeId installDate = 0;
|
TimeId installDate = 0;
|
||||||
StickersPack covers;
|
StickersPack covers;
|
||||||
StickersPack stickers;
|
StickersPack stickers;
|
||||||
|
|
|
@ -94,21 +94,3 @@ enum class MTPDreplyKeyboardMarkup_ClientFlag : uint32 {
|
||||||
MIN_FIELD = (1U << 27),
|
MIN_FIELD = (1U << 27),
|
||||||
};
|
};
|
||||||
DEFINE_MTP_CLIENT_FLAGS(MTPDreplyKeyboardMarkup)
|
DEFINE_MTP_CLIENT_FLAGS(MTPDreplyKeyboardMarkup)
|
||||||
|
|
||||||
enum class MTPDstickerSet_ClientFlag : uint32 {
|
|
||||||
// sticker set is not yet loaded
|
|
||||||
f_not_loaded = (1U << 30),
|
|
||||||
|
|
||||||
// sticker set is one of featured (should be saved locally)
|
|
||||||
f_featured = (1U << 29),
|
|
||||||
|
|
||||||
// sticker set is an unread featured set
|
|
||||||
f_unread = (1U << 28),
|
|
||||||
|
|
||||||
// special set like recent or custom stickers
|
|
||||||
f_special = (1U << 27),
|
|
||||||
|
|
||||||
// update this when adding new client side flags
|
|
||||||
MIN_FIELD = (1U << 27),
|
|
||||||
};
|
|
||||||
DEFINE_MTP_CLIENT_FLAGS(MTPDstickerSet)
|
|
||||||
|
|
|
@ -206,10 +206,10 @@ void AppendStickerSet(
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
if (set->flags & MTPDstickerSet::Flag::f_archived) {
|
if (set->flags & Data::StickersSetFlag::Archived) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!(set->flags & MTPDstickerSet::Flag::f_installed_date)) {
|
if (!(set->flags & Data::StickersSetFlag::Installed)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1511,6 +1511,7 @@ Cache::Database::Settings Account::cacheBigFileSettings() const {
|
||||||
void Account::writeStickerSet(
|
void Account::writeStickerSet(
|
||||||
QDataStream &stream,
|
QDataStream &stream,
|
||||||
const Data::StickersSet &set) {
|
const Data::StickersSet &set) {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
const auto writeInfo = [&](int count) {
|
const auto writeInfo = [&](int count) {
|
||||||
stream
|
stream
|
||||||
<< quint64(set.id)
|
<< quint64(set.id)
|
||||||
|
@ -1523,7 +1524,7 @@ void Account::writeStickerSet(
|
||||||
<< qint32(set.installDate);
|
<< qint32(set.installDate);
|
||||||
Serialize::writeImageLocation(stream, set.thumbnailLocation());
|
Serialize::writeImageLocation(stream, set.thumbnailLocation());
|
||||||
};
|
};
|
||||||
if (set.flags & MTPDstickerSet_ClientFlag::f_not_loaded) {
|
if (set.flags & SetFlag::NotLoaded) {
|
||||||
writeInfo(-set.count);
|
writeInfo(-set.count);
|
||||||
return;
|
return;
|
||||||
} else if (set.stickers.isEmpty()) {
|
} else if (set.stickers.isEmpty()) {
|
||||||
|
@ -1564,6 +1565,8 @@ void Account::writeStickerSets(
|
||||||
FileKey &stickersKey,
|
FileKey &stickersKey,
|
||||||
CheckSet checkSet,
|
CheckSet checkSet,
|
||||||
const Data::StickersSetsOrder &order) {
|
const Data::StickersSetsOrder &order) {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
const auto &sets = _owner->session().data().stickers().sets();
|
const auto &sets = _owner->session().data().stickers().sets();
|
||||||
if (sets.empty()) {
|
if (sets.empty()) {
|
||||||
if (stickersKey) {
|
if (stickersKey) {
|
||||||
|
@ -1593,7 +1596,7 @@ void Account::writeStickerSets(
|
||||||
+ Serialize::stringSize(raw->shortName)
|
+ Serialize::stringSize(raw->shortName)
|
||||||
+ sizeof(qint32) * 4
|
+ sizeof(qint32) * 4
|
||||||
+ Serialize::imageLocationSize(raw->thumbnailLocation());
|
+ Serialize::imageLocationSize(raw->thumbnailLocation());
|
||||||
if (raw->flags & MTPDstickerSet_ClientFlag::f_not_loaded) {
|
if (raw->flags & SetFlag::NotLoaded) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1651,7 +1654,9 @@ void Account::writeStickerSets(
|
||||||
void Account::readStickerSets(
|
void Account::readStickerSets(
|
||||||
FileKey &stickersKey,
|
FileKey &stickersKey,
|
||||||
Data::StickersSetsOrder *outOrder,
|
Data::StickersSetsOrder *outOrder,
|
||||||
MTPDstickerSet::Flags readingFlags) {
|
Data::StickersSetFlags readingFlags) {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
FileReadDescriptor stickers;
|
FileReadDescriptor stickers;
|
||||||
if (!ReadEncryptedFile(stickers, stickersKey, _basePath, _localKey)) {
|
if (!ReadEncryptedFile(stickers, stickersKey, _basePath, _localKey)) {
|
||||||
ClearKey(stickersKey, _basePath);
|
ClearKey(stickersKey, _basePath);
|
||||||
|
@ -1689,7 +1694,7 @@ void Account::readStickerSets(
|
||||||
qint32 scnt = 0;
|
qint32 scnt = 0;
|
||||||
qint32 setInstallDate = 0;
|
qint32 setInstallDate = 0;
|
||||||
qint32 setHash = 0;
|
qint32 setHash = 0;
|
||||||
MTPDstickerSet::Flags setFlags = 0;
|
Data::StickersSetFlags setFlags = 0;
|
||||||
qint32 setFlagsValue = 0;
|
qint32 setFlagsValue = 0;
|
||||||
ImageLocation setThumbnail;
|
ImageLocation setThumbnail;
|
||||||
|
|
||||||
|
@ -1714,20 +1719,47 @@ void Account::readStickerSets(
|
||||||
setThumbnail = *thumbnail;
|
setThumbnail = *thumbnail;
|
||||||
}
|
}
|
||||||
|
|
||||||
setFlags = MTPDstickerSet::Flags::from_raw(setFlagsValue);
|
if (stickers.version >= 2008007) {
|
||||||
|
setFlags = Data::StickersSetFlags::from_raw(setFlagsValue);
|
||||||
|
} else {
|
||||||
|
using Saved = MTPDstickerSet::Flag;
|
||||||
|
using Flag = SetFlag;
|
||||||
|
struct Conversion {
|
||||||
|
Saved saved;
|
||||||
|
Flag flag;
|
||||||
|
};
|
||||||
|
const auto conversions = {
|
||||||
|
Conversion{ Saved::f_archived, Flag::Archived },
|
||||||
|
Conversion{ Saved::f_installed_date, Flag::Installed },
|
||||||
|
Conversion{ Saved::f_masks, Flag::Masks },
|
||||||
|
Conversion{ Saved::f_official, Flag::Official },
|
||||||
|
Conversion{ Saved(1U << 30), Flag::NotLoaded },
|
||||||
|
Conversion{ Saved(1U << 29), Flag::Featured },
|
||||||
|
Conversion{ Saved(1U << 28), Flag::Unread },
|
||||||
|
Conversion{ Saved(1U << 27), Flag::Special },
|
||||||
|
};
|
||||||
|
auto flagsSet = Flag() | 0;
|
||||||
|
for (const auto &conversion : conversions) {
|
||||||
|
if (setFlagsValue & int(conversion.saved)) {
|
||||||
|
flagsSet |= conversion.flag;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
setFlags = flagsSet;
|
||||||
|
}
|
||||||
|
|
||||||
if (setId == Data::Stickers::DefaultSetId) {
|
if (setId == Data::Stickers::DefaultSetId) {
|
||||||
setTitle = tr::lng_stickers_default_set(tr::now);
|
setTitle = tr::lng_stickers_default_set(tr::now);
|
||||||
setFlags |= MTPDstickerSet::Flag::f_official | MTPDstickerSet_ClientFlag::f_special;
|
setFlags |= SetFlag::Official | SetFlag::Special;
|
||||||
} else if (setId == Data::Stickers::CustomSetId) {
|
} else if (setId == Data::Stickers::CustomSetId) {
|
||||||
setTitle = qsl("Custom stickers");
|
setTitle = qsl("Custom stickers");
|
||||||
setFlags |= MTPDstickerSet_ClientFlag::f_special;
|
setFlags |= SetFlag::Special;
|
||||||
} else if ((setId == Data::Stickers::CloudRecentSetId)
|
} else if ((setId == Data::Stickers::CloudRecentSetId)
|
||||||
|| (setId == Data::Stickers::CloudRecentAttachedSetId)) {
|
|| (setId == Data::Stickers::CloudRecentAttachedSetId)) {
|
||||||
setTitle = tr::lng_recent_stickers(tr::now);
|
setTitle = tr::lng_recent_stickers(tr::now);
|
||||||
setFlags |= MTPDstickerSet_ClientFlag::f_special;
|
setFlags |= SetFlag::Special;
|
||||||
} else if (setId == Data::Stickers::FavedSetId) {
|
} else if (setId == Data::Stickers::FavedSetId) {
|
||||||
setTitle = Lang::Hard::FavedSetTitle();
|
setTitle = Lang::Hard::FavedSetTitle();
|
||||||
setFlags |= MTPDstickerSet_ClientFlag::f_special;
|
setFlags |= SetFlag::Special;
|
||||||
} else if (!setId) {
|
} else if (!setId) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
@ -1735,7 +1767,7 @@ void Account::readStickerSets(
|
||||||
auto it = sets.find(setId);
|
auto it = sets.find(setId);
|
||||||
if (it == sets.cend()) {
|
if (it == sets.cend()) {
|
||||||
// We will set this flags from order lists when reading those stickers.
|
// We will set this flags from order lists when reading those stickers.
|
||||||
setFlags &= ~(MTPDstickerSet::Flag::f_installed_date | MTPDstickerSet_ClientFlag::f_featured);
|
setFlags &= ~(SetFlag::Installed | SetFlag::Featured);
|
||||||
it = sets.emplace(setId, std::make_unique<Data::StickersSet>(
|
it = sets.emplace(setId, std::make_unique<Data::StickersSet>(
|
||||||
&_owner->session().data(),
|
&_owner->session().data(),
|
||||||
setId,
|
setId,
|
||||||
|
@ -1744,7 +1776,7 @@ void Account::readStickerSets(
|
||||||
setShortName,
|
setShortName,
|
||||||
0,
|
0,
|
||||||
setHash,
|
setHash,
|
||||||
MTPDstickerSet::Flags(setFlags),
|
setFlags,
|
||||||
setInstallDate)).first;
|
setInstallDate)).first;
|
||||||
it->second->setThumbnail(
|
it->second->setThumbnail(
|
||||||
ImageWithLocation{ .location = setThumbnail });
|
ImageWithLocation{ .location = setThumbnail });
|
||||||
|
@ -1782,7 +1814,7 @@ void Account::readStickerSets(
|
||||||
read.emplace(document->id);
|
read.emplace(document->id);
|
||||||
if (fillStickers) {
|
if (fillStickers) {
|
||||||
set->stickers.push_back(document);
|
set->stickers.push_back(document);
|
||||||
if (!(set->flags & MTPDstickerSet_ClientFlag::f_special)) {
|
if (!(set->flags & SetFlag::Special)) {
|
||||||
if (!document->sticker()->set.id) {
|
if (!document->sticker()->set.id) {
|
||||||
document->sticker()->set = inputSet;
|
document->sticker()->set = inputSet;
|
||||||
}
|
}
|
||||||
|
@ -1871,7 +1903,7 @@ void Account::readStickerSets(
|
||||||
if (it != sets.cend()) {
|
if (it != sets.cend()) {
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
set->flags |= readingFlags;
|
set->flags |= readingFlags;
|
||||||
if ((readingFlags == MTPDstickerSet::Flag::f_installed_date)
|
if ((readingFlags == SetFlag::Installed)
|
||||||
&& !set->installDate) {
|
&& !set->installDate) {
|
||||||
set->installDate = kDefaultStickerInstallDate;
|
set->installDate = kDefaultStickerInstallDate;
|
||||||
}
|
}
|
||||||
|
@ -1881,20 +1913,25 @@ void Account::readStickerSets(
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::writeInstalledStickers() {
|
void Account::writeInstalledStickers() {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
writeStickerSets(_installedStickersKey, [](const Data::StickersSet &set) {
|
writeStickerSets(_installedStickersKey, [](const Data::StickersSet &set) {
|
||||||
if (set.id == Data::Stickers::CloudRecentSetId
|
if (set.id == Data::Stickers::CloudRecentSetId
|
||||||
|| set.id == Data::Stickers::FavedSetId
|
|| set.id == Data::Stickers::FavedSetId
|
||||||
|| set.id == Data::Stickers::CloudRecentAttachedSetId) { // separate files for them
|
|| set.id == Data::Stickers::CloudRecentAttachedSetId) {
|
||||||
|
// separate files for them
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
} else if (set.flags & MTPDstickerSet_ClientFlag::f_special) {
|
} else if (set.flags & SetFlag::Special) {
|
||||||
if (set.stickers.isEmpty()) { // all other special are "installed"
|
if (set.stickers.isEmpty()) { // all other special are "installed"
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
}
|
}
|
||||||
} else if (!(set.flags & MTPDstickerSet::Flag::f_installed_date) || (set.flags & MTPDstickerSet::Flag::f_archived)) {
|
} else if (!(set.flags & SetFlag::Installed)
|
||||||
|
|| (set.flags & SetFlag::Archived)) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
} else if (set.flags & MTPDstickerSet::Flag::f_masks) {
|
} else if (set.flags & SetFlag::Masks) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
} else if (set.flags & MTPDstickerSet_ClientFlag::f_not_loaded) { // waiting to receive
|
} else if (set.flags & SetFlag::NotLoaded) {
|
||||||
|
// waiting to receive
|
||||||
return StickerSetCheckResult::Abort;
|
return StickerSetCheckResult::Abort;
|
||||||
} else if (set.stickers.isEmpty()) {
|
} else if (set.stickers.isEmpty()) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
|
@ -1904,16 +1941,19 @@ void Account::writeInstalledStickers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::writeFeaturedStickers() {
|
void Account::writeFeaturedStickers() {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
writeStickerSets(_featuredStickersKey, [](const Data::StickersSet &set) {
|
writeStickerSets(_featuredStickersKey, [](const Data::StickersSet &set) {
|
||||||
if (set.id == Data::Stickers::CloudRecentSetId
|
if (set.id == Data::Stickers::CloudRecentSetId
|
||||||
|| set.id == Data::Stickers::FavedSetId
|
|| set.id == Data::Stickers::FavedSetId
|
||||||
|| set.id == Data::Stickers::CloudRecentAttachedSetId) { // separate files for them
|
|| set.id == Data::Stickers::CloudRecentAttachedSetId) {
|
||||||
|
// separate files for them
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
} else if (set.flags & MTPDstickerSet_ClientFlag::f_special) {
|
} else if (set.flags & SetFlag::Special) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
} else if (!(set.flags & MTPDstickerSet_ClientFlag::f_featured)) {
|
} else if (!(set.flags & SetFlag::Featured)) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
} else if (set.flags & MTPDstickerSet_ClientFlag::f_not_loaded) { // waiting to receive
|
} else if (set.flags & SetFlag::NotLoaded) { // waiting to receive
|
||||||
return StickerSetCheckResult::Abort;
|
return StickerSetCheckResult::Abort;
|
||||||
} else if (set.stickers.isEmpty()) {
|
} else if (set.stickers.isEmpty()) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
|
@ -1924,7 +1964,8 @@ void Account::writeFeaturedStickers() {
|
||||||
|
|
||||||
void Account::writeRecentStickers() {
|
void Account::writeRecentStickers() {
|
||||||
writeStickerSets(_recentStickersKey, [](const Data::StickersSet &set) {
|
writeStickerSets(_recentStickersKey, [](const Data::StickersSet &set) {
|
||||||
if (set.id != Data::Stickers::CloudRecentSetId || set.stickers.isEmpty()) {
|
if (set.id != Data::Stickers::CloudRecentSetId
|
||||||
|
|| set.stickers.isEmpty()) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
}
|
}
|
||||||
return StickerSetCheckResult::Write;
|
return StickerSetCheckResult::Write;
|
||||||
|
@ -1941,11 +1982,14 @@ void Account::writeFavedStickers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::writeArchivedStickers() {
|
void Account::writeArchivedStickers() {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
writeStickerSets(_archivedStickersKey, [](const Data::StickersSet &set) {
|
writeStickerSets(_archivedStickersKey, [](const Data::StickersSet &set) {
|
||||||
if (set.flags & MTPDstickerSet::Flag::f_masks) {
|
if (set.flags & SetFlag::Masks) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
}
|
}
|
||||||
if (!(set.flags & MTPDstickerSet::Flag::f_archived) || set.stickers.isEmpty()) {
|
if (!(set.flags & SetFlag::Archived)
|
||||||
|
|| set.stickers.isEmpty()) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
}
|
}
|
||||||
return StickerSetCheckResult::Write;
|
return StickerSetCheckResult::Write;
|
||||||
|
@ -1953,11 +1997,13 @@ void Account::writeArchivedStickers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::writeArchivedMasks() {
|
void Account::writeArchivedMasks() {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
writeStickerSets(_archivedStickersKey, [](const Data::StickersSet &set) {
|
writeStickerSets(_archivedStickersKey, [](const Data::StickersSet &set) {
|
||||||
if (!(set.flags & MTPDstickerSet::Flag::f_masks)) {
|
if (!(set.flags & SetFlag::Masks)) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
}
|
}
|
||||||
if (!(set.flags & MTPDstickerSet::Flag::f_archived) || set.stickers.isEmpty()) {
|
if (!(set.flags & SetFlag::Archived) || set.stickers.isEmpty()) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
}
|
}
|
||||||
return StickerSetCheckResult::Write;
|
return StickerSetCheckResult::Write;
|
||||||
|
@ -1965,8 +2011,10 @@ void Account::writeArchivedMasks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::writeInstalledMasks() {
|
void Account::writeInstalledMasks() {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
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 & SetFlag::Masks) || set.stickers.isEmpty()) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
}
|
}
|
||||||
return StickerSetCheckResult::Write;
|
return StickerSetCheckResult::Write;
|
||||||
|
@ -1984,6 +2032,8 @@ void Account::writeRecentMasks() {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::importOldRecentStickers() {
|
void Account::importOldRecentStickers() {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
if (!_recentStickersKeyOld) {
|
if (!_recentStickersKeyOld) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -2015,9 +2065,7 @@ void Account::importOldRecentStickers() {
|
||||||
QString(),
|
QString(),
|
||||||
0, // count
|
0, // count
|
||||||
0, // hash
|
0, // hash
|
||||||
(MTPDstickerSet::Flag::f_official
|
(SetFlag::Official | SetFlag::Installed | SetFlag::Special),
|
||||||
| MTPDstickerSet::Flag::f_installed_date
|
|
||||||
| MTPDstickerSet_ClientFlag::f_special),
|
|
||||||
kDefaultStickerInstallDate)).first->second.get();
|
kDefaultStickerInstallDate)).first->second.get();
|
||||||
const auto custom = sets.emplace(
|
const auto custom = sets.emplace(
|
||||||
Data::Stickers::CustomSetId,
|
Data::Stickers::CustomSetId,
|
||||||
|
@ -2029,8 +2077,7 @@ void Account::importOldRecentStickers() {
|
||||||
QString(),
|
QString(),
|
||||||
0, // count
|
0, // count
|
||||||
0, // hash
|
0, // hash
|
||||||
(MTPDstickerSet::Flag::f_installed_date
|
(SetFlag::Installed | SetFlag::Special),
|
||||||
| MTPDstickerSet_ClientFlag::f_special),
|
|
||||||
kDefaultStickerInstallDate)).first->second.get();
|
kDefaultStickerInstallDate)).first->second.get();
|
||||||
|
|
||||||
QMap<uint64, bool> read;
|
QMap<uint64, bool> read;
|
||||||
|
@ -2112,14 +2159,14 @@ void Account::readInstalledStickers() {
|
||||||
readStickerSets(
|
readStickerSets(
|
||||||
_installedStickersKey,
|
_installedStickersKey,
|
||||||
&_owner->session().data().stickers().setsOrderRef(),
|
&_owner->session().data().stickers().setsOrderRef(),
|
||||||
MTPDstickerSet::Flag::f_installed_date);
|
Data::StickersSetFlag::Installed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::readFeaturedStickers() {
|
void Account::readFeaturedStickers() {
|
||||||
readStickerSets(
|
readStickerSets(
|
||||||
_featuredStickersKey,
|
_featuredStickersKey,
|
||||||
&_owner->session().data().stickers().featuredSetsOrderRef(),
|
&_owner->session().data().stickers().featuredSetsOrderRef(),
|
||||||
MTPDstickerSet::Flags() | MTPDstickerSet_ClientFlag::f_featured);
|
Data::StickersSetFlag::Featured);
|
||||||
|
|
||||||
const auto &sets = _owner->session().data().stickers().sets();
|
const auto &sets = _owner->session().data().stickers().sets();
|
||||||
const auto &order = _owner->session().data().stickers().featuredSetsOrder();
|
const auto &order = _owner->session().data().stickers().featuredSetsOrder();
|
||||||
|
@ -2127,7 +2174,7 @@ void Account::readFeaturedStickers() {
|
||||||
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()
|
||||||
&& (it->second->flags & MTPDstickerSet_ClientFlag::f_unread)) {
|
&& (it->second->flags & Data::StickersSetFlag::Unread)) {
|
||||||
++unreadCount;
|
++unreadCount;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2172,7 +2219,7 @@ void Account::readInstalledMasks() {
|
||||||
readStickerSets(
|
readStickerSets(
|
||||||
_installedMasksKey,
|
_installedMasksKey,
|
||||||
&_owner->session().data().stickers().maskSetsOrderRef(),
|
&_owner->session().data().stickers().maskSetsOrderRef(),
|
||||||
MTPDstickerSet::Flag::f_installed_date);
|
Data::StickersSetFlag::Installed);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Account::writeSavedGifs() {
|
void Account::writeSavedGifs() {
|
||||||
|
|
|
@ -220,7 +220,7 @@ private:
|
||||||
void readStickerSets(
|
void readStickerSets(
|
||||||
FileKey &stickersKey,
|
FileKey &stickersKey,
|
||||||
Data::StickersSetsOrder *outOrder = nullptr,
|
Data::StickersSetsOrder *outOrder = nullptr,
|
||||||
MTPDstickerSet::Flags readingFlags = 0);
|
Data::StickersSetFlags readingFlags = 0);
|
||||||
void importOldRecentStickers();
|
void importOldRecentStickers();
|
||||||
|
|
||||||
void readTrustedBots();
|
void readTrustedBots();
|
||||||
|
|
Loading…
Add table
Reference in a new issue