mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Track only strings in BotCommand struct.
This commit is contained in:
@@ -24,32 +24,6 @@ using UpdateFlag = Data::PeerUpdate::Flag;
|
||||
|
||||
} // namespace
|
||||
|
||||
BotCommand::BotCommand(
|
||||
const QString &command,
|
||||
const QString &description)
|
||||
: command(command)
|
||||
, _description(description) {
|
||||
}
|
||||
|
||||
bool BotCommand::setDescription(const QString &description) {
|
||||
if (_description != description) {
|
||||
_description = description;
|
||||
_descriptionText = Ui::Text::String();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
const Ui::Text::String &BotCommand::descriptionText() const {
|
||||
if (_descriptionText.isEmpty() && !_description.isEmpty()) {
|
||||
_descriptionText.setText(
|
||||
st::defaultTextStyle,
|
||||
_description,
|
||||
Ui::NameTextOptions());
|
||||
}
|
||||
return _descriptionText;
|
||||
}
|
||||
|
||||
UserData::UserData(not_null<Data::Session*> owner, PeerId id)
|
||||
: PeerData(owner, id) {
|
||||
}
|
||||
@@ -132,7 +106,7 @@ void UserData::setBotInfoVersion(int version) {
|
||||
botInfo->version = version;
|
||||
owner().userIsBotChanged(this);
|
||||
} else if (botInfo->version < version) {
|
||||
if (!botInfo->commands.isEmpty()) {
|
||||
if (!botInfo->commands.empty()) {
|
||||
botInfo->commands.clear();
|
||||
owner().botCommandsChanged(this);
|
||||
}
|
||||
@@ -162,17 +136,21 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
|
||||
int32 j = 0;
|
||||
for (const auto &command : v) {
|
||||
command.match([&](const MTPDbotCommand &data) {
|
||||
const auto cmd = qs(data.vcommand());
|
||||
const auto desc = qs(data.vdescription());
|
||||
const auto command = qs(data.vcommand());
|
||||
const auto description = qs(data.vdescription());
|
||||
if (botInfo->commands.size() <= j) {
|
||||
botInfo->commands.push_back(BotCommand(cmd, desc));
|
||||
botInfo->commands.push_back({
|
||||
.command = command,
|
||||
.description = description,
|
||||
});
|
||||
changedCommands = true;
|
||||
} else {
|
||||
if (botInfo->commands[j].command != cmd) {
|
||||
botInfo->commands[j].command = cmd;
|
||||
if (botInfo->commands[j].command != command) {
|
||||
botInfo->commands[j].command = command;
|
||||
changedCommands = true;
|
||||
}
|
||||
if (botInfo->commands[j].setDescription(desc)) {
|
||||
if (botInfo->commands[j].description != description) {
|
||||
botInfo->commands[j].description = description;
|
||||
changedCommands = true;
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user