2
0
mirror of https://github.com/kotatogram/kotatogram-desktop synced 2025-08-31 06:35:14 +00:00

Support media covers for bot descriptions.

For that replace custom handling of _botAbout by a fake message.
This commit is contained in:
John Preston
2023-03-03 20:52:21 +04:00
parent 59c66d1f49
commit 221b0d19c7
10 changed files with 325 additions and 205 deletions

View File

@@ -32,8 +32,7 @@ using UpdateFlag = Data::PeerUpdate::Flag;
} // namespace
BotInfo::BotInfo() : text(st::msgMinWidth) {
}
BotInfo::BotInfo() = default;
UserData::UserData(not_null<Data::Session*> owner, PeerId id)
: PeerData(owner, id)
@@ -188,10 +187,30 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
return;
}
QString desc = qs(d.vdescription().value_or_empty());
if (botInfo->description != desc) {
botInfo->description = desc;
botInfo->text = Ui::Text::String(st::msgMinWidth);
const auto description = qs(d.vdescription().value_or_empty());
if (botInfo->description != description) {
botInfo->description = description;
++botInfo->descriptionVersion;
}
if (const auto photo = d.vdescription_photo()) {
const auto parsed = owner().processPhoto(*photo);
if (botInfo->photo != parsed) {
botInfo->photo = parsed;
++botInfo->descriptionVersion;
}
} else if (botInfo->photo) {
botInfo->photo = nullptr;
++botInfo->descriptionVersion;
}
if (const auto document = d.vdescription_document()) {
const auto parsed = owner().processDocument(*document);
if (botInfo->document != parsed) {
botInfo->document = parsed;
++botInfo->descriptionVersion;
}
} else if (botInfo->document) {
botInfo->document = nullptr;
++botInfo->descriptionVersion;
}
auto commands = d.vcommands()