Locally move sticker set to top.
This commit is contained in:
parent
17bb58d8bb
commit
c5040d9fcd
@ -5933,15 +5933,37 @@ void add_message_content_dependencies(Dependencies &dependencies, const MessageC
|
||||
void on_sent_message_content(Td *td, const MessageContent *content) {
|
||||
switch (content->get_type()) {
|
||||
case MessageContentType::Animation:
|
||||
return td->animations_manager_->add_saved_animation_by_id(get_message_content_any_file_id(content));
|
||||
return td->animations_manager_->add_saved_animation_by_id(get_message_content_upload_file_id(content));
|
||||
case MessageContentType::Sticker:
|
||||
return td->stickers_manager_->add_recent_sticker_by_id(false, get_message_content_any_file_id(content));
|
||||
return td->stickers_manager_->add_recent_sticker_by_id(false, get_message_content_upload_file_id(content));
|
||||
default:
|
||||
// nothing to do
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void move_message_content_sticker_set_to_top(Td *td, const MessageContent *content) {
|
||||
CHECK(content != nullptr);
|
||||
if (content->get_type() == MessageContentType::Sticker) {
|
||||
td->stickers_manager_->move_sticker_set_to_top_by_sticker_id(get_message_content_upload_file_id(content));
|
||||
return;
|
||||
}
|
||||
|
||||
auto text = get_message_content_text(content);
|
||||
if (text == nullptr) {
|
||||
return;
|
||||
}
|
||||
vector<int64> custom_emoji_ids;
|
||||
for (auto &entity : text->entities) {
|
||||
if (entity.type == MessageEntity::Type::CustomEmoji) {
|
||||
custom_emoji_ids.push_back(entity.document_id);
|
||||
}
|
||||
}
|
||||
if (!custom_emoji_ids.empty()) {
|
||||
td->stickers_manager_->move_sticker_set_to_top_by_custom_emoji_ids(custom_emoji_ids);
|
||||
}
|
||||
}
|
||||
|
||||
bool is_unsent_animated_emoji_click(Td *td, DialogId dialog_id, const DialogAction &action) {
|
||||
auto emoji = action.get_watching_animations_emoji();
|
||||
if (emoji.empty()) {
|
||||
|
@ -246,6 +246,8 @@ void add_message_content_dependencies(Dependencies &dependencies, const MessageC
|
||||
|
||||
void on_sent_message_content(Td *td, const MessageContent *content);
|
||||
|
||||
void move_message_content_sticker_set_to_top(Td *td, const MessageContent *content);
|
||||
|
||||
bool is_unsent_animated_emoji_click(Td *td, DialogId dialog_id, const DialogAction &action);
|
||||
|
||||
void init_stickers_manager(Td *td);
|
||||
|
@ -25098,6 +25098,9 @@ MessagesManager::Message *MessagesManager::get_message_to_send(
|
||||
if (result->message_id.is_scheduled()) {
|
||||
send_update_chat_has_scheduled_messages(d, false);
|
||||
}
|
||||
if (options.update_stickersets_order && !td_->auth_manager_->is_bot()) {
|
||||
move_message_content_sticker_set_to_top(td_, result->content.get());
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
|
@ -6742,6 +6742,7 @@ void StickersManager::on_update_sticker_sets_order(StickerType sticker_type,
|
||||
|
||||
// -1 - sticker set can't be moved to top, 0 - order wasn't changed, 1 - sticker set was moved to top
|
||||
int StickersManager::move_installed_sticker_set_to_top(StickerType sticker_type, StickerSetId sticker_set_id) {
|
||||
LOG(INFO) << "Move " << sticker_set_id << " to top of " << sticker_type;
|
||||
auto type = static_cast<int32>(sticker_type);
|
||||
if (!are_installed_sticker_sets_loaded_[type]) {
|
||||
return -1;
|
||||
@ -6788,6 +6789,47 @@ void StickersManager::reorder_installed_sticker_sets(StickerType sticker_type,
|
||||
promise.set_value(Unit());
|
||||
}
|
||||
|
||||
void StickersManager::move_sticker_set_to_top_by_sticker_id(FileId sticker_id) {
|
||||
LOG(INFO) << "Move to top sticker set of " << sticker_id;
|
||||
const auto *s = get_sticker(sticker_id);
|
||||
if (s == nullptr || !s->set_id_.is_valid()) {
|
||||
return;
|
||||
}
|
||||
if (s->type_ == StickerType::CustomEmoji) {
|
||||
// just in case
|
||||
return;
|
||||
}
|
||||
if (move_installed_sticker_set_to_top(s->type_, s->set_id_) > 0) {
|
||||
send_update_installed_sticker_sets();
|
||||
}
|
||||
}
|
||||
|
||||
void StickersManager::move_sticker_set_to_top_by_custom_emoji_ids(const vector<int64> &custom_emoji_ids) {
|
||||
LOG(INFO) << "Move to top sticker set of " << custom_emoji_ids;
|
||||
StickerSetId sticker_set_id;
|
||||
for (auto custom_emoji_id : custom_emoji_ids) {
|
||||
auto sticker_id = custom_emoji_to_sticker_id_.get(custom_emoji_id);
|
||||
if (!sticker_id.is_valid()) {
|
||||
return;
|
||||
}
|
||||
const auto *s = get_sticker(sticker_id);
|
||||
if (s == nullptr || !s->set_id_.is_valid()) {
|
||||
return;
|
||||
}
|
||||
CHECK(s->type_ == StickerType::CustomEmoji);
|
||||
if (s->set_id_ != sticker_set_id) {
|
||||
if (sticker_set_id.is_valid()) {
|
||||
return;
|
||||
}
|
||||
sticker_set_id = s->set_id_;
|
||||
}
|
||||
}
|
||||
CHECK(sticker_set_id.is_valid());
|
||||
if (move_installed_sticker_set_to_top(StickerType::CustomEmoji, sticker_set_id) > 0) {
|
||||
send_update_installed_sticker_sets();
|
||||
}
|
||||
}
|
||||
|
||||
Result<std::tuple<FileId, bool, bool, StickerFormat>> StickersManager::prepare_input_sticker(
|
||||
td_api::inputSticker *sticker, StickerType sticker_type) {
|
||||
if (sticker == nullptr) {
|
||||
|
@ -240,6 +240,10 @@ class StickersManager final : public Actor {
|
||||
void reorder_installed_sticker_sets(StickerType sticker_type, const vector<StickerSetId> &sticker_set_ids,
|
||||
Promise<Unit> &&promise);
|
||||
|
||||
void move_sticker_set_to_top_by_sticker_id(FileId sticker_id);
|
||||
|
||||
void move_sticker_set_to_top_by_custom_emoji_ids(const vector<int64> &custom_emoji_ids);
|
||||
|
||||
FileId upload_sticker_file(UserId user_id, tl_object_ptr<td_api::inputSticker> &&sticker, Promise<Unit> &&promise);
|
||||
|
||||
void get_suggested_sticker_set_name(string title, Promise<string> &&promise);
|
||||
|
Loading…
Reference in New Issue
Block a user