From 7476ff34de4fda3dd92b61b553788467b46d04e1 Mon Sep 17 00:00:00 2001 From: levlam Date: Mon, 26 Feb 2024 13:48:19 +0300 Subject: [PATCH] Combine local and server shortcuts by name. --- td/telegram/QuickReplyManager.cpp | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/td/telegram/QuickReplyManager.cpp b/td/telegram/QuickReplyManager.cpp index 426ec67b7..446b678a2 100644 --- a/td/telegram/QuickReplyManager.cpp +++ b/td/telegram/QuickReplyManager.cpp @@ -654,6 +654,23 @@ void QuickReplyManager::on_reload_quick_reply_shortcuts( send_update_quick_reply_shortcut_deleted(old_shortcut); } else { // some local messages has left + if (added_shortcut_names.count(old_shortcut->name_)) { + // a local shortcut has been created server-side + for (auto &shortcut : new_shortcuts) { + if (shortcut->name_ == old_shortcut->name_) { + CHECK(shortcut->local_total_count_ == 0); + shortcut->local_total_count_ = static_cast(old_shortcut->messages_.size()); + append(shortcut->messages_, std::move(old_shortcut->messages_)); + sort_quick_reply_messages(shortcut->messages_); + send_update_quick_reply_shortcut_deleted(old_shortcut); + if (!td::contains(changed_shortcut_ids, shortcut->shortcut_id_)) { + changed_shortcut_ids.push_back(shortcut->shortcut_id_); + } + } + } + continue; + } + auto shortcut = td::make_unique(); shortcut->name_ = std::move(old_shortcut->name_); shortcut->shortcut_id_ = old_shortcut->shortcut_id_;