Add get_sticker_type function.
This commit is contained in:
parent
e3da366e2b
commit
c92f741a83
@ -8,6 +8,16 @@
|
|||||||
|
|
||||||
namespace td {
|
namespace td {
|
||||||
|
|
||||||
|
StickerType get_sticker_type(bool is_mask, bool is_custom_emoji) {
|
||||||
|
if (is_custom_emoji) {
|
||||||
|
return StickerType::CustomEmoji;
|
||||||
|
}
|
||||||
|
if (is_mask) {
|
||||||
|
return StickerType::Mask;
|
||||||
|
}
|
||||||
|
return StickerType::Regular;
|
||||||
|
}
|
||||||
|
|
||||||
StickerType get_sticker_type(const td_api::object_ptr<td_api::StickerType> &type) {
|
StickerType get_sticker_type(const td_api::object_ptr<td_api::StickerType> &type) {
|
||||||
if (type == nullptr) {
|
if (type == nullptr) {
|
||||||
return StickerType::Regular;
|
return StickerType::Regular;
|
||||||
|
@ -18,6 +18,8 @@ enum class StickerType : int32 { Regular, Mask, CustomEmoji };
|
|||||||
|
|
||||||
static constexpr int32 MAX_STICKER_TYPE = 3;
|
static constexpr int32 MAX_STICKER_TYPE = 3;
|
||||||
|
|
||||||
|
StickerType get_sticker_type(bool is_mask, bool is_custom_emoji);
|
||||||
|
|
||||||
StickerType get_sticker_type(const td_api::object_ptr<td_api::StickerType> &type);
|
StickerType get_sticker_type(const td_api::object_ptr<td_api::StickerType> &type);
|
||||||
|
|
||||||
td_api::object_ptr<td_api::StickerType> get_sticker_type_object(StickerType sticker_type);
|
td_api::object_ptr<td_api::StickerType> get_sticker_type_object(StickerType sticker_type);
|
||||||
|
@ -113,13 +113,7 @@ FileId StickersManager::parse_sticker(bool in_sticker_set, ParserT &parser) {
|
|||||||
} else {
|
} else {
|
||||||
sticker->format_ = StickerFormat::Webp;
|
sticker->format_ = StickerFormat::Webp;
|
||||||
}
|
}
|
||||||
if (is_emoji) {
|
sticker->type_ = ::td::get_sticker_type(is_mask, is_emoji);
|
||||||
sticker->type_ = StickerType::CustomEmoji;
|
|
||||||
} else if (is_mask) {
|
|
||||||
sticker->type_ = StickerType::Mask;
|
|
||||||
} else {
|
|
||||||
sticker->type_ = StickerType::Regular;
|
|
||||||
}
|
|
||||||
if (in_sticker_set_stored != in_sticker_set) {
|
if (in_sticker_set_stored != in_sticker_set) {
|
||||||
Slice data = parser.template fetch_string_raw<Slice>(parser.get_left_len());
|
Slice data = parser.template fetch_string_raw<Slice>(parser.get_left_len());
|
||||||
for (auto c : data) {
|
for (auto c : data) {
|
||||||
@ -299,12 +293,7 @@ void StickersManager::parse_sticker_set(StickerSet *sticker_set, ParserT &parser
|
|||||||
} else {
|
} else {
|
||||||
sticker_format = StickerFormat::Webp;
|
sticker_format = StickerFormat::Webp;
|
||||||
}
|
}
|
||||||
StickerType sticker_type = StickerType::Regular;
|
auto sticker_type = ::td::get_sticker_type(is_masks, is_emojis);
|
||||||
if (is_emojis) {
|
|
||||||
sticker_type = StickerType::CustomEmoji;
|
|
||||||
} else if (is_masks) {
|
|
||||||
sticker_type = StickerType::Mask;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (sticker_set->is_inited_) {
|
if (sticker_set->is_inited_) {
|
||||||
string title;
|
string title;
|
||||||
|
@ -3368,23 +3368,13 @@ void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateNewStickerSet>
|
|||||||
}
|
}
|
||||||
|
|
||||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateStickerSets> update, Promise<Unit> &&promise) {
|
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateStickerSets> update, Promise<Unit> &&promise) {
|
||||||
StickerType sticker_type = StickerType::Regular;
|
auto sticker_type = get_sticker_type(update->masks_, update->emojis_);
|
||||||
if (update->emojis_) {
|
|
||||||
sticker_type = StickerType::CustomEmoji;
|
|
||||||
} else if (update->masks_) {
|
|
||||||
sticker_type = StickerType::Mask;
|
|
||||||
}
|
|
||||||
td_->stickers_manager_->on_update_sticker_sets(sticker_type);
|
td_->stickers_manager_->on_update_sticker_sets(sticker_type);
|
||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
}
|
}
|
||||||
|
|
||||||
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateStickerSetsOrder> update, Promise<Unit> &&promise) {
|
void UpdatesManager::on_update(tl_object_ptr<telegram_api::updateStickerSetsOrder> update, Promise<Unit> &&promise) {
|
||||||
StickerType sticker_type = StickerType::Regular;
|
auto sticker_type = get_sticker_type(update->masks_, update->emojis_);
|
||||||
if (update->emojis_) {
|
|
||||||
sticker_type = StickerType::CustomEmoji;
|
|
||||||
} else if (update->masks_) {
|
|
||||||
sticker_type = StickerType::Mask;
|
|
||||||
}
|
|
||||||
td_->stickers_manager_->on_update_sticker_sets_order(sticker_type,
|
td_->stickers_manager_->on_update_sticker_sets_order(sticker_type,
|
||||||
StickersManager::convert_sticker_set_ids(update->order_));
|
StickersManager::convert_sticker_set_ids(update->order_));
|
||||||
promise.set_value(Unit());
|
promise.set_value(Unit());
|
||||||
|
Loading…
Reference in New Issue
Block a user