mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-07 15:43:55 +02:00
Request and cache featured emoji sets.
This commit is contained in:
parent
b31a3ba5a3
commit
b4b55973b5
10 changed files with 185 additions and 70 deletions
|
@ -60,6 +60,23 @@ namespace {
|
||||||
: 0;
|
: 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
[[nodiscard]] uint64 CountFeaturedHash(
|
||||||
|
not_null<Main::Session*> session,
|
||||||
|
const Data::StickersSetsOrder &order) {
|
||||||
|
auto result = HashInit();
|
||||||
|
const auto &sets = session->data().stickers().sets();
|
||||||
|
for (const auto setId : order) {
|
||||||
|
HashUpdate(result, setId);
|
||||||
|
|
||||||
|
const auto it = sets.find(setId);
|
||||||
|
if (it != sets.cend()
|
||||||
|
&& (it->second->flags & Data::StickersSetFlag::Unread)) {
|
||||||
|
HashUpdate(result, 1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return HashFinalize(result);
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace
|
} // namespace
|
||||||
|
|
||||||
uint64 CountStickersHash(
|
uint64 CountStickersHash(
|
||||||
|
@ -104,19 +121,15 @@ uint64 CountFavedStickersHash(not_null<Main::Session*> session) {
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 CountFeaturedStickersHash(not_null<Main::Session*> session) {
|
uint64 CountFeaturedStickersHash(not_null<Main::Session*> session) {
|
||||||
auto result = HashInit();
|
return CountFeaturedHash(
|
||||||
const auto &sets = session->data().stickers().sets();
|
session,
|
||||||
const auto &featured = session->data().stickers().featuredSetsOrder();
|
session->data().stickers().featuredSetsOrder());
|
||||||
for (const auto setId : featured) {
|
}
|
||||||
HashUpdate(result, setId);
|
|
||||||
|
|
||||||
const auto it = sets.find(setId);
|
uint64 CountFeaturedEmojiHash(not_null<Main::Session*> session) {
|
||||||
if (it != sets.cend()
|
return CountFeaturedHash(
|
||||||
&& (it->second->flags & Data::StickersSetFlag::Unread)) {
|
session,
|
||||||
HashUpdate(result, 1);
|
session->data().stickers().featuredEmojiSetsOrder());
|
||||||
}
|
|
||||||
}
|
|
||||||
return HashFinalize(result);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint64 CountSavedGifsHash(not_null<Main::Session*> session) {
|
uint64 CountSavedGifsHash(not_null<Main::Session*> session) {
|
||||||
|
|
|
@ -25,9 +25,12 @@ namespace Api {
|
||||||
[[nodiscard]] uint64 CountRecentStickersHash(
|
[[nodiscard]] uint64 CountRecentStickersHash(
|
||||||
not_null<Main::Session*> session,
|
not_null<Main::Session*> session,
|
||||||
bool attached = false);
|
bool attached = false);
|
||||||
[[nodiscard]] uint64 CountFavedStickersHash(not_null<Main::Session*> session);
|
[[nodiscard]] uint64 CountFavedStickersHash(
|
||||||
|
not_null<Main::Session*> session);
|
||||||
[[nodiscard]] uint64 CountFeaturedStickersHash(
|
[[nodiscard]] uint64 CountFeaturedStickersHash(
|
||||||
not_null<Main::Session*> session);
|
not_null<Main::Session*> session);
|
||||||
|
[[nodiscard]] uint64 CountFeaturedEmojiHash(
|
||||||
|
not_null<Main::Session*> session);
|
||||||
[[nodiscard]] uint64 CountSavedGifsHash(not_null<Main::Session*> session);
|
[[nodiscard]] uint64 CountSavedGifsHash(not_null<Main::Session*> session);
|
||||||
|
|
||||||
[[nodiscard]] inline uint64 HashInit() {
|
[[nodiscard]] inline uint64 HashInit() {
|
||||||
|
|
|
@ -2526,6 +2526,7 @@ void ApiWrap::updateStickers() {
|
||||||
requestRecentStickers(now);
|
requestRecentStickers(now);
|
||||||
requestFavedStickers(now);
|
requestFavedStickers(now);
|
||||||
requestFeaturedStickers(now);
|
requestFeaturedStickers(now);
|
||||||
|
requestFeaturedEmoji(now);
|
||||||
requestSavedGifs(now);
|
requestSavedGifs(now);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2778,28 +2779,33 @@ void ApiWrap::requestFeaturedStickers(TimeId now) {
|
||||||
_featuredStickersUpdateRequest = request(MTPmessages_GetFeaturedStickers(
|
_featuredStickersUpdateRequest = request(MTPmessages_GetFeaturedStickers(
|
||||||
MTP_long(Api::CountFeaturedStickersHash(_session))
|
MTP_long(Api::CountFeaturedStickersHash(_session))
|
||||||
)).done([=](const MTPmessages_FeaturedStickers &result) {
|
)).done([=](const MTPmessages_FeaturedStickers &result) {
|
||||||
_session->data().stickers().setLastFeaturedUpdate(crl::now());
|
|
||||||
_featuredStickersUpdateRequest = 0;
|
_featuredStickersUpdateRequest = 0;
|
||||||
|
_session->data().stickers().featuredSetsReceived(result);
|
||||||
switch (result.type()) {
|
|
||||||
case mtpc_messages_featuredStickersNotModified: return;
|
|
||||||
case mtpc_messages_featuredStickers: {
|
|
||||||
auto &d = result.c_messages_featuredStickers();
|
|
||||||
_session->data().stickers().featuredSetsReceived(
|
|
||||||
d.vsets().v,
|
|
||||||
d.vunread().v,
|
|
||||||
d.vhash().v);
|
|
||||||
} return;
|
|
||||||
default: Unexpected("Type in ApiWrap::featuredStickersDone()");
|
|
||||||
}
|
|
||||||
}).fail([=] {
|
}).fail([=] {
|
||||||
_session->data().stickers().setLastFeaturedUpdate(crl::now());
|
|
||||||
_featuredStickersUpdateRequest = 0;
|
_featuredStickersUpdateRequest = 0;
|
||||||
|
_session->data().stickers().setLastFeaturedUpdate(crl::now());
|
||||||
LOG(("App Fail: Failed to get featured stickers!"));
|
LOG(("App Fail: Failed to get featured stickers!"));
|
||||||
}).send();
|
}).send();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ApiWrap::requestFeaturedEmoji(TimeId now) {
|
||||||
|
if (!_session->data().stickers().featuredEmojiUpdateNeeded(now)
|
||||||
|
|| _featuredEmojiUpdateRequest) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
_featuredEmojiUpdateRequest = request(
|
||||||
|
MTPmessages_GetFeaturedEmojiStickers(
|
||||||
|
MTP_long(Api::CountFeaturedStickersHash(_session)))
|
||||||
|
).done([=](const MTPmessages_FeaturedStickers &result) {
|
||||||
|
_featuredEmojiUpdateRequest = 0;
|
||||||
|
_session->data().stickers().featuredEmojiSetsReceived(result);
|
||||||
|
}).fail([=] {
|
||||||
|
_featuredEmojiUpdateRequest = 0;
|
||||||
|
_session->data().stickers().setLastFeaturedEmojiUpdate(crl::now());
|
||||||
|
LOG(("App Fail: Failed to get featured emoji!"));
|
||||||
|
}).send();
|
||||||
|
}
|
||||||
|
|
||||||
void ApiWrap::requestSavedGifs(TimeId now) {
|
void ApiWrap::requestSavedGifs(TimeId now) {
|
||||||
if (!_session->data().stickers().savedGifsUpdateNeeded(now)
|
if (!_session->data().stickers().savedGifsUpdateNeeded(now)
|
||||||
|| _savedGifsUpdateRequest) {
|
|| _savedGifsUpdateRequest) {
|
||||||
|
|
|
@ -445,6 +445,7 @@ private:
|
||||||
void requestRecentStickersWithHash(uint64 hash, bool attached = false);
|
void requestRecentStickersWithHash(uint64 hash, bool attached = false);
|
||||||
void requestFavedStickers(TimeId now);
|
void requestFavedStickers(TimeId now);
|
||||||
void requestFeaturedStickers(TimeId now);
|
void requestFeaturedStickers(TimeId now);
|
||||||
|
void requestFeaturedEmoji(TimeId now);
|
||||||
void requestSavedGifs(TimeId now);
|
void requestSavedGifs(TimeId now);
|
||||||
void readFeaturedSets();
|
void readFeaturedSets();
|
||||||
|
|
||||||
|
@ -564,6 +565,7 @@ private:
|
||||||
mtpRequestId _recentAttachedStickersUpdateRequest = 0;
|
mtpRequestId _recentAttachedStickersUpdateRequest = 0;
|
||||||
mtpRequestId _favedStickersUpdateRequest = 0;
|
mtpRequestId _favedStickersUpdateRequest = 0;
|
||||||
mtpRequestId _featuredStickersUpdateRequest = 0;
|
mtpRequestId _featuredStickersUpdateRequest = 0;
|
||||||
|
mtpRequestId _featuredEmojiUpdateRequest = 0;
|
||||||
mtpRequestId _savedGifsUpdateRequest = 0;
|
mtpRequestId _savedGifsUpdateRequest = 0;
|
||||||
|
|
||||||
base::Timer _featuredSetsReadTimer;
|
base::Timer _featuredSetsReadTimer;
|
||||||
|
|
|
@ -392,10 +392,12 @@ EmojiListWidget::EmojiListWidget(
|
||||||
resizeToWidth(width());
|
resizeToWidth(width());
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
|
|
||||||
Data::AmPremiumValue(
|
rpl::combine(
|
||||||
&controller->session()
|
Data::AmPremiumValue(&controller->session()),
|
||||||
) | rpl::start_with_next([=] {
|
controller->session().premiumPossibleValue()
|
||||||
update();
|
) | rpl::skip(1) | rpl::start_with_next([=] {
|
||||||
|
refreshCustom();
|
||||||
|
resizeToWidth(width());
|
||||||
}, lifetime());
|
}, lifetime());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1221,8 +1223,9 @@ void EmojiListWidget::refreshCustom() {
|
||||||
auto old = base::take(_custom);
|
auto old = base::take(_custom);
|
||||||
const auto owner = &controller()->session().data();
|
const auto owner = &controller()->session().data();
|
||||||
const auto &order = owner->stickers().emojiSetsOrder();
|
const auto &order = owner->stickers().emojiSetsOrder();
|
||||||
|
const auto &featured = owner->stickers().featuredEmojiSetsOrder();
|
||||||
const auto &sets = owner->stickers().sets();
|
const auto &sets = owner->stickers().sets();
|
||||||
for (const auto setId : order) {
|
for (const auto setId : ranges::views::concat(order, featured)) {
|
||||||
auto it = sets.find(setId);
|
auto it = sets.find(setId);
|
||||||
if (it == sets.cend() || it->second->stickers.isEmpty()) {
|
if (it == sets.cend() || it->second->stickers.isEmpty()) {
|
||||||
continue;
|
continue;
|
||||||
|
|
|
@ -401,14 +401,19 @@ void Stickers::installLocally(uint64 setId) {
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto set = it->second.get();
|
const auto set = it->second.get();
|
||||||
auto flags = set->flags;
|
const auto flags = set->flags;
|
||||||
set->flags &= ~(SetFlag::Archived | SetFlag::Unread);
|
set->flags &= ~(SetFlag::Archived | SetFlag::Unread);
|
||||||
set->flags |= SetFlag::Installed;
|
set->flags |= SetFlag::Installed;
|
||||||
set->installDate = base::unixtime::now();
|
set->installDate = base::unixtime::now();
|
||||||
auto changedFlags = flags ^ set->flags;
|
auto changedFlags = flags ^ set->flags;
|
||||||
|
|
||||||
const auto masks = !!(flags & SetFlag::Masks);
|
const auto isMasks = (set->type() == StickersType::Masks);
|
||||||
auto &order = masks ? maskSetsOrderRef() : setsOrderRef();
|
const auto isEmoji = (set->type() == StickersType::Emoji);
|
||||||
|
auto &order = isEmoji
|
||||||
|
? emojiSetsOrderRef()
|
||||||
|
: isMasks
|
||||||
|
? 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) {
|
||||||
|
@ -429,17 +434,21 @@ void Stickers::installLocally(uint64 setId) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
session().local().writeInstalledStickers();
|
session().local().writeInstalledStickers();
|
||||||
if (changedFlags & SetFlag::Unread) {
|
if (!isMasks && (changedFlags & SetFlag::Unread)) {
|
||||||
session().local().writeFeaturedStickers();
|
if (isEmoji) {
|
||||||
|
session().local().writeFeaturedCustomEmoji();
|
||||||
|
} else {
|
||||||
|
session().local().writeFeaturedStickers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (changedFlags & SetFlag::Archived) {
|
if (!isEmoji && (changedFlags & SetFlag::Archived)) {
|
||||||
auto &archivedOrder = masks
|
auto &archivedOrder = isMasks
|
||||||
? archivedMaskSetsOrderRef()
|
? archivedMaskSetsOrderRef()
|
||||||
: archivedSetsOrderRef();
|
: archivedSetsOrderRef();
|
||||||
const auto index = archivedOrder.indexOf(setId);
|
const auto index = archivedOrder.indexOf(setId);
|
||||||
if (index >= 0) {
|
if (index >= 0) {
|
||||||
archivedOrder.removeAt(index);
|
archivedOrder.removeAt(index);
|
||||||
if (masks) {
|
if (isMasks) {
|
||||||
session().local().writeArchivedMasks();
|
session().local().writeArchivedMasks();
|
||||||
} else {
|
} else {
|
||||||
session().local().writeArchivedStickers();
|
session().local().writeArchivedStickers();
|
||||||
|
@ -922,27 +931,51 @@ void Stickers::specialSetReceived(
|
||||||
}
|
}
|
||||||
|
|
||||||
void Stickers::featuredSetsReceived(
|
void Stickers::featuredSetsReceived(
|
||||||
const QVector<MTPStickerSetCovered> &list,
|
const MTPmessages_FeaturedStickers &result) {
|
||||||
const QVector<MTPlong> &unread,
|
setLastFeaturedUpdate(crl::now());
|
||||||
uint64 hash) {
|
result.match([](const MTPDmessages_featuredStickersNotModified &) {
|
||||||
|
}, [&](const MTPDmessages_featuredStickers &data) {
|
||||||
|
featuredReceived(data, StickersType::Stickers);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stickers::featuredEmojiSetsReceived(
|
||||||
|
const MTPmessages_FeaturedStickers &result) {
|
||||||
|
setLastFeaturedEmojiUpdate(crl::now());
|
||||||
|
result.match([](const MTPDmessages_featuredStickersNotModified &) {
|
||||||
|
}, [&](const MTPDmessages_featuredStickers &data) {
|
||||||
|
featuredReceived(data, StickersType::Emoji);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
void Stickers::featuredReceived(
|
||||||
|
const MTPDmessages_featuredStickers &data,
|
||||||
|
StickersType type) {
|
||||||
|
const auto &list = data.vsets().v;
|
||||||
|
const auto &unread = data.vunread().v;
|
||||||
|
const auto hash = data.vhash().v;
|
||||||
|
|
||||||
auto &&unreadIds = ranges::views::all(
|
auto &&unreadIds = ranges::views::all(
|
||||||
unread
|
unread
|
||||||
) | ranges::views::transform([](const MTPlong &id) {
|
) | ranges::views::transform(&MTPlong::v);
|
||||||
return id.v;
|
|
||||||
});
|
|
||||||
const auto unreadMap = base::flat_set<uint64>{
|
const auto unreadMap = base::flat_set<uint64>{
|
||||||
unreadIds.begin(),
|
unreadIds.begin(),
|
||||||
unreadIds.end()
|
unreadIds.end()
|
||||||
};
|
};
|
||||||
|
|
||||||
auto &setsOrder = featuredSetsOrderRef();
|
const auto isEmoji = (type == StickersType::Emoji);
|
||||||
|
auto &setsOrder = isEmoji
|
||||||
|
? featuredEmojiSetsOrderRef()
|
||||||
|
: featuredSetsOrderRef();
|
||||||
setsOrder.clear();
|
setsOrder.clear();
|
||||||
|
|
||||||
auto &sets = setsRef();
|
auto &sets = setsRef();
|
||||||
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 &= ~SetFlag::Featured;
|
if (set->type() == type) {
|
||||||
|
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) {
|
||||||
|
@ -1015,7 +1048,9 @@ void Stickers::featuredSetsReceived(
|
||||||
bool archived = (set->flags & SetFlag::Archived);
|
bool archived = (set->flags & SetFlag::Archived);
|
||||||
if (installed || featured || special || archived) {
|
if (installed || featured || special || archived) {
|
||||||
if (featured && (set->flags & SetFlag::Unread)) {
|
if (featured && (set->flags & SetFlag::Unread)) {
|
||||||
++unreadCount;
|
if (!(set->flags & SetFlag::Emoji)) {
|
||||||
|
++unreadCount;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
++it;
|
++it;
|
||||||
} else {
|
} else {
|
||||||
|
@ -1024,7 +1059,9 @@ void Stickers::featuredSetsReceived(
|
||||||
}
|
}
|
||||||
setFeaturedSetsUnreadCount(unreadCount);
|
setFeaturedSetsUnreadCount(unreadCount);
|
||||||
|
|
||||||
const auto counted = Api::CountFeaturedStickersHash(&session());
|
const auto counted = isEmoji
|
||||||
|
? Api::CountFeaturedEmojiHash(&session())
|
||||||
|
: Api::CountFeaturedStickersHash(&session());
|
||||||
if (counted != hash) {
|
if (counted != hash) {
|
||||||
LOG(("API Error: "
|
LOG(("API Error: "
|
||||||
"received featured stickers hash %1 while counted hash is %2"
|
"received featured stickers hash %1 while counted hash is %2"
|
||||||
|
@ -1039,8 +1076,11 @@ void Stickers::featuredSetsReceived(
|
||||||
}
|
}
|
||||||
api.requestStickerSets();
|
api.requestStickerSets();
|
||||||
}
|
}
|
||||||
|
if (isEmoji) {
|
||||||
session().local().writeFeaturedStickers();
|
session().local().writeFeaturedCustomEmoji();
|
||||||
|
} else {
|
||||||
|
session().local().writeFeaturedStickers();
|
||||||
|
}
|
||||||
|
|
||||||
notifyUpdated();
|
notifyUpdated();
|
||||||
}
|
}
|
||||||
|
@ -1411,8 +1451,8 @@ void Stickers::feedSetStickers(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
const auto isEmoji = !!(set->flags & SetFlag::Emoji);
|
const auto isEmoji = (set->type() == StickersType::Emoji);
|
||||||
const auto isMasks = !!(set->flags & SetFlag::Masks);
|
const auto isMasks = (set->type() == StickersType::Masks);
|
||||||
set->stickers = pack;
|
set->stickers = pack;
|
||||||
set->emoji.clear();
|
set->emoji.clear();
|
||||||
for (auto i = 0, l = int(packs.size()); i != l; ++i) {
|
for (auto i = 0, l = int(packs.size()); i != l; ++i) {
|
||||||
|
@ -1449,7 +1489,12 @@ void Stickers::feedSetStickers(
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (set->flags & SetFlag::Featured) {
|
if (set->flags & SetFlag::Featured) {
|
||||||
session().local().writeFeaturedStickers();
|
if (isEmoji) {
|
||||||
|
session().local().writeFeaturedCustomEmoji();
|
||||||
|
} else if (isMasks) {
|
||||||
|
} else {
|
||||||
|
session().local().writeFeaturedStickers();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (wasArchived != isArchived) {
|
if (wasArchived != isArchived) {
|
||||||
if (isEmoji) {
|
if (isEmoji) {
|
||||||
|
|
|
@ -126,6 +126,12 @@ public:
|
||||||
void setLastFeaturedUpdate(crl::time update) {
|
void setLastFeaturedUpdate(crl::time update) {
|
||||||
_lastFeaturedUpdate = update;
|
_lastFeaturedUpdate = update;
|
||||||
}
|
}
|
||||||
|
bool featuredEmojiUpdateNeeded(crl::time now) const {
|
||||||
|
return updateNeeded(_lastFeaturedEmojiUpdate, now);
|
||||||
|
}
|
||||||
|
void setLastFeaturedEmojiUpdate(crl::time update) {
|
||||||
|
_lastFeaturedEmojiUpdate = update;
|
||||||
|
}
|
||||||
bool savedGifsUpdateNeeded(crl::time now) const {
|
bool savedGifsUpdateNeeded(crl::time now) const {
|
||||||
return updateNeeded(_lastSavedGifsUpdate, now);
|
return updateNeeded(_lastSavedGifsUpdate, now);
|
||||||
}
|
}
|
||||||
|
@ -171,6 +177,12 @@ public:
|
||||||
StickersSetsOrder &featuredSetsOrderRef() {
|
StickersSetsOrder &featuredSetsOrderRef() {
|
||||||
return _featuredSetsOrder;
|
return _featuredSetsOrder;
|
||||||
}
|
}
|
||||||
|
const StickersSetsOrder &featuredEmojiSetsOrder() const {
|
||||||
|
return _featuredEmojiSetsOrder;
|
||||||
|
}
|
||||||
|
StickersSetsOrder &featuredEmojiSetsOrderRef() {
|
||||||
|
return _featuredEmojiSetsOrder;
|
||||||
|
}
|
||||||
const StickersSetsOrder &archivedSetsOrder() const {
|
const StickersSetsOrder &archivedSetsOrder() const {
|
||||||
return _archivedSetsOrder;
|
return _archivedSetsOrder;
|
||||||
}
|
}
|
||||||
|
@ -216,10 +228,9 @@ public:
|
||||||
uint64 hash,
|
uint64 hash,
|
||||||
const QVector<MTPStickerPack> &packs = QVector<MTPStickerPack>(),
|
const QVector<MTPStickerPack> &packs = QVector<MTPStickerPack>(),
|
||||||
const QVector<MTPint> &usageDates = QVector<MTPint>());
|
const QVector<MTPint> &usageDates = QVector<MTPint>());
|
||||||
void featuredSetsReceived(
|
void featuredSetsReceived(const MTPmessages_FeaturedStickers &result);
|
||||||
const QVector<MTPStickerSetCovered> &list,
|
void featuredEmojiSetsReceived(
|
||||||
const QVector<MTPlong> &unread,
|
const MTPmessages_FeaturedStickers &result);
|
||||||
uint64 hash);
|
|
||||||
void gifsReceived(const QVector<MTPDocument> &items, uint64 hash);
|
void gifsReceived(const QVector<MTPDocument> &items, uint64 hash);
|
||||||
|
|
||||||
std::vector<not_null<DocumentData*>> getListByEmoji(
|
std::vector<not_null<DocumentData*>> getListByEmoji(
|
||||||
|
@ -277,6 +288,9 @@ private:
|
||||||
const QVector<MTPStickerSet> &list,
|
const QVector<MTPStickerSet> &list,
|
||||||
uint64 hash,
|
uint64 hash,
|
||||||
StickersType type);
|
StickersType type);
|
||||||
|
void featuredReceived(
|
||||||
|
const MTPDmessages_featuredStickers &data,
|
||||||
|
StickersType type);
|
||||||
|
|
||||||
const not_null<Session*> _owner;
|
const not_null<Session*> _owner;
|
||||||
rpl::event_stream<> _updated;
|
rpl::event_stream<> _updated;
|
||||||
|
@ -291,6 +305,7 @@ private:
|
||||||
crl::time _lastSavedGifsUpdate = 0;
|
crl::time _lastSavedGifsUpdate = 0;
|
||||||
crl::time _lastMasksUpdate = 0;
|
crl::time _lastMasksUpdate = 0;
|
||||||
crl::time _lastEmojiUpdate = 0;
|
crl::time _lastEmojiUpdate = 0;
|
||||||
|
crl::time _lastFeaturedEmojiUpdate = 0;
|
||||||
crl::time _lastRecentAttachedUpdate = 0;
|
crl::time _lastRecentAttachedUpdate = 0;
|
||||||
rpl::variable<int> _featuredSetsUnreadCount = 0;
|
rpl::variable<int> _featuredSetsUnreadCount = 0;
|
||||||
StickersSets _sets;
|
StickersSets _sets;
|
||||||
|
@ -298,6 +313,7 @@ private:
|
||||||
StickersSetsOrder _maskSetsOrder;
|
StickersSetsOrder _maskSetsOrder;
|
||||||
StickersSetsOrder _emojiSetsOrder;
|
StickersSetsOrder _emojiSetsOrder;
|
||||||
StickersSetsOrder _featuredSetsOrder;
|
StickersSetsOrder _featuredSetsOrder;
|
||||||
|
StickersSetsOrder _featuredEmojiSetsOrder;
|
||||||
StickersSetsOrder _archivedSetsOrder;
|
StickersSetsOrder _archivedSetsOrder;
|
||||||
StickersSetsOrder _archivedMaskSetsOrder;
|
StickersSetsOrder _archivedMaskSetsOrder;
|
||||||
SavedGifs _savedGifs;
|
SavedGifs _savedGifs;
|
||||||
|
|
|
@ -159,6 +159,7 @@ Session::Session(
|
||||||
local().readInstalledMasks();
|
local().readInstalledMasks();
|
||||||
local().readInstalledCustomEmoji();
|
local().readInstalledCustomEmoji();
|
||||||
local().readFeaturedStickers();
|
local().readFeaturedStickers();
|
||||||
|
local().readFeaturedCustomEmoji();
|
||||||
local().readRecentStickers();
|
local().readRecentStickers();
|
||||||
local().readRecentMasks();
|
local().readRecentMasks();
|
||||||
local().readFavedStickers();
|
local().readFavedStickers();
|
||||||
|
|
|
@ -205,7 +205,7 @@ base::flat_set<QString> Account::collectGoodNames() const {
|
||||||
_recentMasksKey,
|
_recentMasksKey,
|
||||||
_archivedMasksKey,
|
_archivedMasksKey,
|
||||||
_installedCustomEmojiKey,
|
_installedCustomEmojiKey,
|
||||||
_recentCustomEmojiKey,
|
_featuredCustomEmojiKey,
|
||||||
_archivedCustomEmojiKey,
|
_archivedCustomEmojiKey,
|
||||||
};
|
};
|
||||||
auto result = base::flat_set<QString>{
|
auto result = base::flat_set<QString>{
|
||||||
|
@ -288,7 +288,7 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
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, archivedMasksKey = 0;
|
quint64 installedMasksKey = 0, recentMasksKey = 0, archivedMasksKey = 0;
|
||||||
quint64 installedCustomEmojiKey = 0, recentCustomEmojiKey = 0, archivedCustomEmojiKey = 0;
|
quint64 installedCustomEmojiKey = 0, featuredCustomEmojiKey = 0, archivedCustomEmojiKey = 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;
|
||||||
|
@ -394,7 +394,7 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
case lskCustomEmojiKeys: {
|
case lskCustomEmojiKeys: {
|
||||||
map.stream
|
map.stream
|
||||||
>> installedCustomEmojiKey
|
>> installedCustomEmojiKey
|
||||||
>> recentCustomEmojiKey
|
>> featuredCustomEmojiKey
|
||||||
>> archivedCustomEmojiKey;
|
>> archivedCustomEmojiKey;
|
||||||
} break;
|
} break;
|
||||||
default:
|
default:
|
||||||
|
@ -425,7 +425,7 @@ Account::ReadMapResult Account::readMapWith(
|
||||||
_recentMasksKey = recentMasksKey;
|
_recentMasksKey = recentMasksKey;
|
||||||
_archivedMasksKey = archivedMasksKey;
|
_archivedMasksKey = archivedMasksKey;
|
||||||
_installedCustomEmojiKey = installedCustomEmojiKey;
|
_installedCustomEmojiKey = installedCustomEmojiKey;
|
||||||
_recentCustomEmojiKey = recentCustomEmojiKey;
|
_featuredCustomEmojiKey = featuredCustomEmojiKey;
|
||||||
_archivedCustomEmojiKey = archivedCustomEmojiKey;
|
_archivedCustomEmojiKey = archivedCustomEmojiKey;
|
||||||
_legacyBackgroundKeyDay = legacyBackgroundKeyDay;
|
_legacyBackgroundKeyDay = legacyBackgroundKeyDay;
|
||||||
_legacyBackgroundKeyNight = legacyBackgroundKeyNight;
|
_legacyBackgroundKeyNight = legacyBackgroundKeyNight;
|
||||||
|
@ -534,7 +534,7 @@ void Account::writeMap() {
|
||||||
if (_installedMasksKey || _recentMasksKey || _archivedMasksKey) {
|
if (_installedMasksKey || _recentMasksKey || _archivedMasksKey) {
|
||||||
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
||||||
}
|
}
|
||||||
if (_installedCustomEmojiKey || _recentCustomEmojiKey || _archivedCustomEmojiKey) {
|
if (_installedCustomEmojiKey || _featuredCustomEmojiKey || _archivedCustomEmojiKey) {
|
||||||
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
mapSize += sizeof(quint32) + 3 * sizeof(quint64);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -589,11 +589,11 @@ void Account::writeMap() {
|
||||||
<< quint64(_recentMasksKey)
|
<< quint64(_recentMasksKey)
|
||||||
<< quint64(_archivedMasksKey);
|
<< quint64(_archivedMasksKey);
|
||||||
}
|
}
|
||||||
if (_installedCustomEmojiKey || _recentCustomEmojiKey || _archivedCustomEmojiKey) {
|
if (_installedCustomEmojiKey || _featuredCustomEmojiKey || _archivedCustomEmojiKey) {
|
||||||
mapData.stream << quint32(lskCustomEmojiKeys);
|
mapData.stream << quint32(lskCustomEmojiKeys);
|
||||||
mapData.stream
|
mapData.stream
|
||||||
<< quint64(_installedCustomEmojiKey)
|
<< quint64(_installedCustomEmojiKey)
|
||||||
<< quint64(_recentCustomEmojiKey)
|
<< quint64(_featuredCustomEmojiKey)
|
||||||
<< quint64(_archivedCustomEmojiKey);
|
<< quint64(_archivedCustomEmojiKey);
|
||||||
}
|
}
|
||||||
map.writeEncrypted(mapData, _localKey);
|
map.writeEncrypted(mapData, _localKey);
|
||||||
|
@ -618,7 +618,7 @@ void Account::reset() {
|
||||||
_recentMasksKey = 0;
|
_recentMasksKey = 0;
|
||||||
_archivedMasksKey = 0;
|
_archivedMasksKey = 0;
|
||||||
_installedCustomEmojiKey = 0;
|
_installedCustomEmojiKey = 0;
|
||||||
_recentCustomEmojiKey = 0;
|
_featuredCustomEmojiKey = 0;
|
||||||
_archivedCustomEmojiKey = 0;
|
_archivedCustomEmojiKey = 0;
|
||||||
_legacyBackgroundKeyDay = _legacyBackgroundKeyNight = 0;
|
_legacyBackgroundKeyDay = _legacyBackgroundKeyNight = 0;
|
||||||
_settingsKey = _recentHashtagsAndBotsKey = _exportSettingsKey = 0;
|
_settingsKey = _recentHashtagsAndBotsKey = _exportSettingsKey = 0;
|
||||||
|
@ -2042,7 +2042,7 @@ void Account::writeFeaturedStickers() {
|
||||||
|| set.id == Data::Stickers::CloudRecentAttachedSetId) {
|
|| set.id == Data::Stickers::CloudRecentAttachedSetId) {
|
||||||
// separate files for them
|
// separate files for them
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
} else if (set.flags & SetFlag::Special) {
|
} else if (set.flags & (SetFlag::Special | SetFlag::Emoji)) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
} else if (!(set.flags & SetFlag::Featured)) {
|
} else if (!(set.flags & SetFlag::Featured)) {
|
||||||
return StickerSetCheckResult::Skip;
|
return StickerSetCheckResult::Skip;
|
||||||
|
@ -2055,6 +2055,23 @@ void Account::writeFeaturedStickers() {
|
||||||
}, _owner->session().data().stickers().featuredSetsOrder());
|
}, _owner->session().data().stickers().featuredSetsOrder());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Account::writeFeaturedCustomEmoji() {
|
||||||
|
using SetFlag = Data::StickersSetFlag;
|
||||||
|
|
||||||
|
writeStickerSets(_featuredCustomEmojiKey, [](const Data::StickersSet &set) {
|
||||||
|
if (!(set.flags & SetFlag::Emoji)) {
|
||||||
|
return StickerSetCheckResult::Skip;
|
||||||
|
} else if (!(set.flags & SetFlag::Featured)) {
|
||||||
|
return StickerSetCheckResult::Skip;
|
||||||
|
} else if (set.flags & SetFlag::NotLoaded) { // waiting to receive
|
||||||
|
return StickerSetCheckResult::Abort;
|
||||||
|
} else if (set.stickers.isEmpty()) {
|
||||||
|
return StickerSetCheckResult::Skip;
|
||||||
|
}
|
||||||
|
return StickerSetCheckResult::Write;
|
||||||
|
}, _owner->session().data().stickers().featuredEmojiSetsOrder());
|
||||||
|
}
|
||||||
|
|
||||||
void Account::writeRecentStickers() {
|
void Account::writeRecentStickers() {
|
||||||
writeStickerSets(_recentStickersKey, [](const Data::StickersSet &set) {
|
writeStickerSets(_recentStickersKey, [](const Data::StickersSet &set) {
|
||||||
if (set.id != Data::Stickers::CloudRecentSetId
|
if (set.id != Data::Stickers::CloudRecentSetId
|
||||||
|
@ -2293,6 +2310,13 @@ void Account::readFeaturedStickers() {
|
||||||
_owner->session().data().stickers().setFeaturedSetsUnreadCount(unreadCount);
|
_owner->session().data().stickers().setFeaturedSetsUnreadCount(unreadCount);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Account::readFeaturedCustomEmoji() {
|
||||||
|
readStickerSets(
|
||||||
|
_featuredCustomEmojiKey,
|
||||||
|
&_owner->session().data().stickers().featuredEmojiSetsOrderRef(),
|
||||||
|
Data::StickersSetFlag::Featured);
|
||||||
|
}
|
||||||
|
|
||||||
void Account::readRecentStickers() {
|
void Account::readRecentStickers() {
|
||||||
readStickerSets(_recentStickersKey);
|
readStickerSets(_recentStickersKey);
|
||||||
}
|
}
|
||||||
|
|
|
@ -136,7 +136,9 @@ public:
|
||||||
void readInstalledMasks();
|
void readInstalledMasks();
|
||||||
void readRecentMasks();
|
void readRecentMasks();
|
||||||
void writeInstalledCustomEmoji();
|
void writeInstalledCustomEmoji();
|
||||||
|
void writeFeaturedCustomEmoji();
|
||||||
void readInstalledCustomEmoji();
|
void readInstalledCustomEmoji();
|
||||||
|
void readFeaturedCustomEmoji();
|
||||||
|
|
||||||
void writeRecentHashtagsAndBots();
|
void writeRecentHashtagsAndBots();
|
||||||
void readRecentHashtagsAndBots();
|
void readRecentHashtagsAndBots();
|
||||||
|
@ -287,7 +289,7 @@ private:
|
||||||
FileKey _installedMasksKey = 0;
|
FileKey _installedMasksKey = 0;
|
||||||
FileKey _recentMasksKey = 0;
|
FileKey _recentMasksKey = 0;
|
||||||
FileKey _installedCustomEmojiKey = 0;
|
FileKey _installedCustomEmojiKey = 0;
|
||||||
FileKey _recentCustomEmojiKey = 0;
|
FileKey _featuredCustomEmojiKey = 0;
|
||||||
FileKey _archivedCustomEmojiKey = 0;
|
FileKey _archivedCustomEmojiKey = 0;
|
||||||
|
|
||||||
qint64 _cacheTotalSizeLimit = 0;
|
qint64 _cacheTotalSizeLimit = 0;
|
||||||
|
|
Loading…
Add table
Reference in a new issue