Improve sticker file reference refreshing.
This commit is contained in:
parent
131f7ec5bb
commit
a7772b922c
|
@ -2505,10 +2505,12 @@ void ApiWrap::refreshFileReference(
|
|||
if (additional) {
|
||||
const auto i = _fileReferenceHandlers.find(origin);
|
||||
Assert(i != end(_fileReferenceHandlers));
|
||||
if (i->second.size() == 1) {
|
||||
i->second.push_back([=](auto&&) {
|
||||
additional();
|
||||
});
|
||||
}
|
||||
}
|
||||
};
|
||||
const auto fail = [&] {
|
||||
handler(Data::UpdatedFileReferences());
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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)
|
||||
|
|
|
@ -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;
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in New Issue