2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 14:38:15 +00:00

Receive and track recent sticker usage date.

This commit is contained in:
John Preston
2018-03-07 20:43:26 +03:00
parent f0a95032a5
commit ccef155f7a
6 changed files with 70 additions and 11 deletions

View File

@@ -3216,6 +3216,15 @@ void _writeStickerSet(QDataStream &stream, const Stickers::Set &set) {
for (auto j = set.stickers.cbegin(), e = set.stickers.cend(); j != e; ++j) {
Serialize::Document::writeToStream(stream, *j);
}
if (AppVersion > 1002008) {
stream << qint32(set.dates.size());
if (!set.dates.empty()) {
Assert(set.dates.size() == set.stickers.size());
for (const auto date : set.dates) {
stream << qint32(date);
}
}
}
if (AppVersion > 9018) {
stream << qint32(set.emoji.size());
@@ -3267,6 +3276,11 @@ void _writeStickerSets(FileKey &stickersKey, CheckSet checkSet, const Stickers::
for_const (auto &sticker, set.stickers) {
size += Serialize::Document::sizeInStream(sticker);
}
size += sizeof(qint32); // dates count
if (!set.dates.empty()) {
Assert(set.stickers.size() == set.dates.size());
size += set.dates.size() * sizeof(qint32);
}
size += sizeof(qint32); // emojiCount
for (auto j = set.emoji.cbegin(), e = set.emoji.cend(); j != e; ++j) {
@@ -3432,6 +3446,23 @@ void _readStickerSets(FileKey &stickersKey, Stickers::Order *outOrder = nullptr,
}
}
if (stickers.version > 1002008) {
auto datesCount = qint32(0);
stickers.stream >> datesCount;
if (datesCount > 0) {
if (datesCount != scnt) {
// Bad file.
return;
}
set.dates.reserve(datesCount);
for (auto i = 0; i != datesCount; ++i) {
auto date = qint32();
stickers.stream >> date;
set.dates.push_back(TimeId(date));
}
}
}
if (stickers.version > 9018) {
qint32 emojiCount;
stickers.stream >> emojiCount;