Use langpack-ed about for Verification Codes.

This commit is contained in:
John Preston 2024-11-29 11:44:26 +04:00
parent 9822c56f1a
commit b3c8a79946
3 changed files with 34 additions and 7 deletions

View file

@ -3376,6 +3376,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
"lng_replies_no_comments" = "No comments here yet..."; "lng_replies_no_comments" = "No comments here yet...";
"lng_verification_codes" = "Verification Codes"; "lng_verification_codes" = "Verification Codes";
"lng_verification_codes_about" = "Third-party services, like websites and stores, can send verification codes to your phone number via Telegram instead of SMS. Such codes will appear in this chat.\n\nIf you didn't request any codes — don't worry! Most likely, someone made a mistake when entering their number.";
"lng_archived_name" = "Archived chats"; "lng_archived_name" = "Archived chats";
"lng_archived_add" = "Archive"; "lng_archived_add" = "Archive";

View file

@ -241,6 +241,13 @@ HistoryItem *AboutView::item() const {
} }
bool AboutView::refresh() { bool AboutView::refresh() {
if (_history->peer->isVerifyCodes()) {
if (_item) {
return false;
}
setItem(makeAboutVerifyCodes(), nullptr);
return true;
}
const auto user = _history->peer->asUser(); const auto user = _history->peer->asUser();
const auto info = user ? user->botInfo.get() : nullptr; const auto info = user ? user->botInfo.get() : nullptr;
if (!info) { if (!info) {
@ -359,10 +366,24 @@ void AboutView::setItem(AdminLog::OwnedItem item, DocumentData *sticker) {
toggleStickerRegistered(true); toggleStickerRegistered(true);
} }
AdminLog::OwnedItem AboutView::makeAboutVerifyCodes() {
return makeAboutSimple(
tr::lng_verification_codes_about(tr::now, Ui::Text::RichLangValue));
}
AdminLog::OwnedItem AboutView::makeAboutBot(not_null<BotInfo*> info) { AdminLog::OwnedItem AboutView::makeAboutBot(not_null<BotInfo*> info) {
const auto textWithEntities = TextUtilities::ParseEntities( return makeAboutSimple(
info->description, TextUtilities::ParseEntities(
Ui::ItemTextBotNoMonoOptions().flags); info->description,
Ui::ItemTextBotNoMonoOptions().flags),
info->document,
info->photo);
}
AdminLog::OwnedItem AboutView::makeAboutSimple(
TextWithEntities textWithEntities,
DocumentData *document,
PhotoData *photo) {
const auto make = [&](auto &&...args) { const auto make = [&](auto &&...args) {
return _history->makeMessage({ return _history->makeMessage({
.id = _history->nextNonHistoryEntryId(), .id = _history->nextNonHistoryEntryId(),
@ -372,10 +393,10 @@ AdminLog::OwnedItem AboutView::makeAboutBot(not_null<BotInfo*> info) {
.from = _history->peer->id, .from = _history->peer->id,
}, std::forward<decltype(args)>(args)...); }, std::forward<decltype(args)>(args)...);
}; };
const auto item = info->document const auto item = document
? make(info->document, textWithEntities) ? make(document, textWithEntities)
: info->photo : photo
? make(info->photo, textWithEntities) ? make(photo, textWithEntities)
: make(textWithEntities, MTP_messageMediaEmpty()); : make(textWithEntities, MTP_messageMediaEmpty());
return AdminLog::OwnedItem(_delegate, item); return AdminLog::OwnedItem(_delegate, item);
} }

View file

@ -34,7 +34,12 @@ public:
int height = 0; int height = 0;
private: private:
[[nodiscard]] AdminLog::OwnedItem makeAboutVerifyCodes();
[[nodiscard]] AdminLog::OwnedItem makeAboutBot(not_null<BotInfo*> info); [[nodiscard]] AdminLog::OwnedItem makeAboutBot(not_null<BotInfo*> info);
[[nodiscard]] AdminLog::OwnedItem makeAboutSimple(
TextWithEntities textWithEntities,
DocumentData *document = nullptr,
PhotoData *photo = nullptr);
[[nodiscard]] AdminLog::OwnedItem makePremiumRequired(); [[nodiscard]] AdminLog::OwnedItem makePremiumRequired();
[[nodiscard]] AdminLog::OwnedItem makeBlocked(); [[nodiscard]] AdminLog::OwnedItem makeBlocked();
void makeIntro(not_null<UserData*> user); void makeIntro(not_null<UserData*> user);