From 9cd859d313cb2f20fdf361e8fb4c04ecc6918311 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 15 May 2023 15:27:23 +0300 Subject: [PATCH] Resave sticker set without stickers only if it has already been inited. --- td/telegram/StickersManager.cpp | 3 ++- td/telegram/StickersManager.hpp | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/td/telegram/StickersManager.cpp b/td/telegram/StickersManager.cpp index 1a16201d5..36beff992 100644 --- a/td/telegram/StickersManager.cpp +++ b/td/telegram/StickersManager.cpp @@ -5745,6 +5745,7 @@ void StickersManager::on_load_sticker_set_from_database(StickerSetId sticker_set LOG(INFO) << "Successfully loaded " << sticker_set_id << " with" << (with_stickers ? "" : "out") << " stickers of size " << value.size() << " from database"; + auto was_inited = sticker_set->is_inited_; auto old_sticker_count = sticker_set->sticker_ids_.size(); { @@ -5771,7 +5772,7 @@ void StickersManager::on_load_sticker_set_from_database(StickerSetId sticker_set "on_load_sticker_set_from_database 2"); } - if (with_stickers && old_sticker_count < get_max_featured_sticker_count(sticker_set->sticker_type_) && + if (with_stickers && was_inited && old_sticker_count < get_max_featured_sticker_count(sticker_set->sticker_type_) && old_sticker_count < sticker_set->sticker_ids_.size()) { sticker_set->need_save_to_database_ = true; } diff --git a/td/telegram/StickersManager.hpp b/td/telegram/StickersManager.hpp index 2e82cb82d..674f2e4e5 100644 --- a/td/telegram/StickersManager.hpp +++ b/td/telegram/StickersManager.hpp @@ -364,7 +364,7 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser << sticker_set->short_name_ << "\""; sticker_set->is_changed_ = true; } - if (sticker_set->sticker_count_ != sticker_count || sticker_set->hash_ != hash) { + if (sticker_set->is_loaded_ && (sticker_set->sticker_count_ != sticker_count || sticker_set->hash_ != hash)) { sticker_set->is_loaded_ = false; sticker_set->is_changed_ = true; }