Improve sticker file reference refreshing.

This commit is contained in:
John Preston 2018-09-26 21:08:11 +03:00
parent 131f7ec5bb
commit a7772b922c
6 changed files with 25 additions and 12 deletions

View File

@ -2505,9 +2505,11 @@ void ApiWrap::refreshFileReference(
if (additional) {
const auto i = _fileReferenceHandlers.find(origin);
Assert(i != end(_fileReferenceHandlers));
i->second.push_back([=](auto&&) {
additional();
});
if (i->second.size() == 1) {
i->second.push_back([=](auto&&) {
additional();
});
}
}
};
const auto fail = [&] {

View File

@ -20,7 +20,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "core/update_checker.h"
AboutBox::AboutBox(QWidget *parent)
: _version(this, lng_about_version(lt_version, QString::fromLatin1(AppVersionStr.c_str()) + (AppBetaVersion ? " beta" : "") + (cAlphaVersion() ? qsl(" alpha %1").arg(cAlphaVersion()) : QString())), st::aboutVersionLink)
: _version(this, lng_about_version(lt_version, QString::fromLatin1(AppVersionStr.c_str()) + (cAlphaVersion() ? qsl(" alpha %1").arg(cAlphaVersion()) : (AppBetaVersion ? " beta" : ""))), st::aboutVersionLink)
, _text1(this, lang(lng_about_text_1), Ui::FlatLabel::InitType::Rich, st::aboutLabel)
, _text2(this, lang(lng_about_text_2), Ui::FlatLabel::InitType::Rich, st::aboutLabel)
, _text3(this, st::aboutLabel) {
@ -99,11 +99,10 @@ QString telegramFaqLink() {
QString currentVersionText() {
auto result = QString::fromLatin1(AppVersionStr.c_str());
if (AppBetaVersion) {
result += " beta";
}
if (cAlphaVersion()) {
result += qsl(" alpha %1").arg(cAlphaVersion() % 1000);
} else if (AppBetaVersion) {
result += " beta";
}
return result;
}

View File

@ -1071,6 +1071,15 @@ void DocumentData::refreshFileReference(const QByteArray &value) {
_fileReference = value;
}
void DocumentData::refreshStickerThumbFileReference() {
if (const auto data = sticker()) {
if (thumb->loading()) {
data->loc.refreshFileReference(
thumb->location().fileReference());
}
}
}
QString DocumentData::filename() const {
return _filename;
}

View File

@ -166,6 +166,7 @@ public:
MTPInputDocument mtpInput() const;
QByteArray fileReference() const;
void refreshFileReference(const QByteArray &value);
void refreshStickerThumbFileReference();
// When we have some client-side generated document
// (for example for displaying an external inline bot result)

View File

@ -25,8 +25,9 @@ namespace {
void SendToBannedHelp(const QString &phone) {
const auto version = QString::fromLatin1(AppVersionStr.c_str())
+ (AppBetaVersion ? " beta" : "")
+ (cAlphaVersion() ? qsl(" alpha %1").arg(cAlphaVersion()) : QString());
+ (cAlphaVersion()
? qsl(" alpha %1").arg(cAlphaVersion())
: (AppBetaVersion ? " beta" : ""));
const auto subject = qsl("Banned phone number: ") + phone;

View File

@ -3210,7 +3210,7 @@ template <typename CheckSet>
void _writeStickerSets(FileKey &stickersKey, CheckSet checkSet, const Stickers::Order &order) {
if (!_working()) return;
auto &sets = Auth().data().stickerSets();
const auto &sets = Auth().data().stickerSets();
if (sets.isEmpty()) {
if (stickersKey) {
clearKey(stickersKey);
@ -3223,7 +3223,7 @@ void _writeStickerSets(FileKey &stickersKey, CheckSet checkSet, const Stickers::
int32 setsCount = 0;
QByteArray hashToWrite;
quint32 size = sizeof(quint32) + Serialize::bytearraySize(hashToWrite);
for_const (auto &set, sets) {
for (const auto &set : sets) {
auto result = checkSet(set);
if (result == StickerSetCheckResult::Abort) {
return;
@ -3233,7 +3233,8 @@ void _writeStickerSets(FileKey &stickersKey, CheckSet checkSet, const Stickers::
// id + access + title + shortName + stickersCount + hash + flags + installDate
size += sizeof(quint64) * 2 + Serialize::stringSize(set.title) + Serialize::stringSize(set.shortName) + sizeof(quint32) + sizeof(qint32) * 3;
for_const (auto &sticker, set.stickers) {
for (const auto sticker : std::as_const(set.stickers)) {
sticker->refreshStickerThumbFileReference();
size += Serialize::Document::sizeInStream(sticker);
}
size += sizeof(qint32); // dates count