Don't add back deleted shortcuts.

This commit is contained in:
levlam 2024-02-24 03:06:20 +03:00
parent 44366bd208
commit 274720f395
2 changed files with 9 additions and 0 deletions

View File

@ -573,6 +573,9 @@ void QuickReplyManager::on_reload_quick_reply_shortcuts(
LOG(ERROR) << "Receive duplicate " << to_string(quick_reply);
continue;
}
if (deleted_shortcut_ids_.count(quick_reply->shortcut_id_)) {
continue;
}
added_shortcut_ids.insert(quick_reply->shortcut_id_);
added_shortcut_names.insert(quick_reply->shortcut_);
@ -590,6 +593,7 @@ void QuickReplyManager::on_reload_quick_reply_shortcuts(
if (message->shortcut_id != quick_reply->shortcut_id_) {
LOG(ERROR) << "Receive message from shortcut " << message->shortcut_id << " instead of "
<< quick_reply->shortcut_id_;
continue;
}
auto shortcut = td::make_unique<Shortcut>();
@ -688,6 +692,7 @@ void QuickReplyManager::delete_quick_reply_shortcut(const string &name, Promise<
auto shortcut_id = s->shortcut_id_;
td::remove_if(shortcuts_.shortcuts_,
[shortcut_id](const unique_ptr<Shortcut> &shortcut) { return shortcut->shortcut_id_ == shortcut_id; });
deleted_shortcut_ids_.insert(shortcut_id);
td_->create_handler<DeleteQuickReplyShortcutQuery>(std::move(promise))->send(shortcut_id);
}

View File

@ -14,6 +14,8 @@
#include "td/actor/actor.h"
#include "td/utils/common.h"
#include "td/utils/FlatHashSet.h"
#include "td/utils/Promise.h"
#include <utility>
@ -196,6 +198,8 @@ class QuickReplyManager final : public Actor {
Shortcuts shortcuts_;
FlatHashSet<int32> deleted_shortcut_ids_;
Td *td_;
ActorShared<> parent_;
};