Reload sticker sets once to get actual thumbnail.
GitOrigin-RevId: f910afa02095e2f098ca28bb0304a14775e08f93
This commit is contained in:
parent
c72f7e4eee
commit
df10fcfdd9
@ -290,12 +290,12 @@ Variant<PhotoSize, string> get_photo_size(FileManager *file_manager, FileType fi
|
||||
std::string upload_file_reference, DialogId owner_dialog_id,
|
||||
tl_object_ptr<telegram_api::PhotoSize> &&size_ptr, bool is_webp,
|
||||
bool is_png) {
|
||||
CHECK(size_ptr != nullptr);
|
||||
|
||||
tl_object_ptr<telegram_api::FileLocation> location_ptr;
|
||||
string type;
|
||||
|
||||
PhotoSize res;
|
||||
BufferSlice content;
|
||||
|
||||
switch (size_ptr->get_id()) {
|
||||
case telegram_api::photoSizeEmpty::ID:
|
||||
return std::move(res);
|
||||
|
@ -1622,19 +1622,22 @@ int64 StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::stickerSet
|
||||
bool is_official = (set->flags_ & telegram_api::stickerSet::OFFICIAL_MASK) != 0;
|
||||
bool is_masks = (set->flags_ & telegram_api::stickerSet::MASKS_MASK) != 0;
|
||||
|
||||
PhotoSize thumbnail;
|
||||
if (set->thumb_ != nullptr) {
|
||||
auto photo_size = get_photo_size(td_->file_manager_.get(), FileType::Thumbnail, 0, 0, "", DialogId(),
|
||||
std::move(set->thumb_), true, false);
|
||||
PhotoSize thumbnail;
|
||||
if (photo_size.get_offset() == 0) {
|
||||
thumbnail = std::move(photo_size.get<0>());
|
||||
} else {
|
||||
LOG(ERROR) << "Receive minithumbnail for a sticker set " << set_id;
|
||||
}
|
||||
}
|
||||
if (!s->is_inited) {
|
||||
s->is_inited = true;
|
||||
s->title = std::move(set->title_);
|
||||
s->short_name = std::move(set->short_name_);
|
||||
s->thumbnail = std::move(thumbnail);
|
||||
s->is_thumbnail_reloaded = true;
|
||||
s->sticker_count = set->count_;
|
||||
s->hash = set->hash_;
|
||||
s->is_official = is_official;
|
||||
@ -1672,6 +1675,10 @@ int64 StickersManager::on_get_sticker_set(tl_object_ptr<telegram_api::stickerSet
|
||||
s->thumbnail = std::move(thumbnail);
|
||||
s->is_changed = true;
|
||||
}
|
||||
if (!s->is_thumbnail_reloaded) {
|
||||
s->is_thumbnail_reloaded = true;
|
||||
s->is_changed = true;
|
||||
}
|
||||
|
||||
if (s->sticker_count != set->count_ || s->hash != set->hash_) {
|
||||
s->is_loaded = false;
|
||||
@ -2770,6 +2777,9 @@ void StickersManager::on_load_sticker_set_from_database(int64 sticker_set_id, bo
|
||||
}
|
||||
status.ensure();
|
||||
}
|
||||
if (!sticker_set->is_thumbnail_reloaded) {
|
||||
reload_sticker_set(sticker_set_id, get_input_sticker_set(sticker_set), Auto());
|
||||
}
|
||||
|
||||
if (with_stickers && old_sticker_count < 5 && old_sticker_count < sticker_set->sticker_ids.size()) {
|
||||
sticker_set->is_changed = true;
|
||||
|
@ -287,6 +287,7 @@ class StickersManager : public Actor {
|
||||
bool is_official = false;
|
||||
bool is_masks = false;
|
||||
bool is_viewed = true;
|
||||
bool is_thumbnail_reloaded = false;
|
||||
bool is_changed = true;
|
||||
|
||||
vector<uint32> load_requests;
|
||||
|
@ -122,6 +122,7 @@ void StickersManager::store_sticker_set(const StickerSet *sticker_set, bool with
|
||||
STORE_FLAG(sticker_set->is_viewed);
|
||||
STORE_FLAG(has_expires_at);
|
||||
STORE_FLAG(has_thumbnail);
|
||||
STORE_FLAG(sticker_set->is_thumbnail_reloaded);
|
||||
END_STORE_FLAGS();
|
||||
store(sticker_set->id, storer);
|
||||
store(sticker_set->access_hash, storer);
|
||||
@ -177,6 +178,7 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser
|
||||
PARSE_FLAG(sticker_set->is_viewed);
|
||||
PARSE_FLAG(has_expires_at);
|
||||
PARSE_FLAG(has_thumbnail);
|
||||
PARSE_FLAG(sticker_set->is_thumbnail_reloaded);
|
||||
END_PARSE_FLAGS();
|
||||
int64 sticker_set_id;
|
||||
int64 access_hash;
|
||||
|
Reference in New Issue
Block a user