Fix bug in ChatBotCommands::update when commands empty (#28631)

This commit is contained in:
ziplantil 2024-11-14 09:35:57 +02:00 committed by GitHub
parent 7e2e510d8a
commit 074bb1e66e
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -17,13 +17,18 @@ ChatBotCommands::Changed ChatBotCommands::update(
clear(); clear();
} else { } else {
for (const auto &commands : list) { for (const auto &commands : list) {
if (commands.commands.empty()) {
changed |= remove(commands.userId);
} else {
auto &value = operator[](commands.userId); auto &value = operator[](commands.userId);
changed |= commands.commands.empty() const auto isEqual = ranges::equal(value, commands.commands);
? remove(commands.userId) changed |= !isEqual;
: !ranges::equal(value, commands.commands); if (!isEqual) {
value = commands.commands; value = commands.commands;
} }
} }
}
}
return changed; return changed;
} }