Skip to content

Commit

Permalink
Fix bug in ChatBotCommands::update when commands empty (#28631)
Browse files Browse the repository at this point in the history
  • Loading branch information
ziplantil authored Nov 14, 2024
1 parent 7e2e510 commit 074bb1e
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions Telegram/SourceFiles/data/data_peer_bot_commands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,16 @@ ChatBotCommands::Changed ChatBotCommands::update(
clear();
} else {
for (const auto &commands : list) {
auto &value = operator[](commands.userId);
changed |= commands.commands.empty()
? remove(commands.userId)
: !ranges::equal(value, commands.commands);
value = commands.commands;
if (commands.commands.empty()) {
changed |= remove(commands.userId);
} else {
auto &value = operator[](commands.userId);
const auto isEqual = ranges::equal(value, commands.commands);
changed |= !isEqual;
if (!isEqual) {
value = commands.commands;
}
}
}
}
return changed;
Expand Down

0 comments on commit 074bb1e

Please sign in to comment.