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,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;