diff --git a/Telegram/Resources/langs/lang.strings b/Telegram/Resources/langs/lang.strings index 2fca05c05..4cd748139 100644 --- a/Telegram/Resources/langs/lang.strings +++ b/Telegram/Resources/langs/lang.strings @@ -433,7 +433,8 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL "lng_username_invalid" = "This username is invalid."; "lng_username_occupied" = "This username is already occupied."; "lng_username_too_short" = "This username is too short."; -"lng_username_purchase_available" = "Sorry, this link is occupied by someone. But it's available for purchase through\nofficial {link}."; +"lng_username_purchase_available" = "**This username is already taken.** However, it is currently available for purchase. {link}"; +"lng_username_purchase_available_link" = "Learn more..."; "lng_username_bad_symbols" = "Only a-z, 0-9, and underscores allowed."; "lng_username_available" = "This username is available."; "lng_username_not_found" = "User @{user} not found."; diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp index 5e5dee319..46fb2619c 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_type_box.cpp @@ -585,9 +585,8 @@ void Controller::checkUsernameAvailability() { showUsernameError(tr::lng_create_channel_link_invalid()); } else if (type == u"USERNAME_PURCHASE_AVAILABLE"_q) { _goodUsername = false; - _usernameCheckInfo.fire({ - .type = UsernameCheckInfo::Type::PurchaseAvailable, - }); + _usernameCheckInfo.fire( + UsernameCheckInfo::PurchaseAvailable(checking, _peer)); } else if (type == u"USERNAME_OCCUPIED"_q && checking != username) { showUsernameError(tr::lng_create_channel_link_occupied()); } diff --git a/Telegram/SourceFiles/boxes/username_box.cpp b/Telegram/SourceFiles/boxes/username_box.cpp index 52c08b684..7df856d8d 100644 --- a/Telegram/SourceFiles/boxes/username_box.cpp +++ b/Telegram/SourceFiles/boxes/username_box.cpp @@ -33,17 +33,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace { -[[nodiscard]] TextWithEntities PurchaseAvailableText() { - constexpr auto kUsernameAuction = "auction"; - return tr::lng_username_purchase_available( - tr::now, - lt_link, - Ui::Text::Link( - '@' + QString(kUsernameAuction), - u"https://t.me/"_q + kUsernameAuction), - Ui::Text::RichLangValue); -} - class UsernameEditor final : public Ui::RpWidget { public: UsernameEditor(not_null, not_null peer); @@ -268,9 +257,8 @@ void UsernameEditor::checkInfoPurchaseAvailable() { _username->showError(); _errorText = u".bad."_q; - _checkInfoChanged.fire({ - .type = UsernameCheckInfo::Type::PurchaseAvailable, - }); + _checkInfoChanged.fire( + UsernameCheckInfo::PurchaseAvailable(_checkUsername, _peer)); } void UsernameEditor::updateFail(const QString &error) { @@ -424,9 +412,7 @@ void AddUsernameCheckLabel( container->widthValue() ) | rpl::start_with_next([=](const UsernameCheckInfo &info, int w) { using Type = UsernameCheckInfo::Type; - label->setMarkedText((info.type == Type::PurchaseAvailable) - ? PurchaseAvailableText() - : info.text); + label->setMarkedText(info.text); const auto &color = (info.type == Type::Good) ? st::boxTextFgGood : (info.type == Type::Error) @@ -437,3 +423,25 @@ void AddUsernameCheckLabel( }, label->lifetime()); Ui::AddSkip(container, skip); } + +UsernameCheckInfo UsernameCheckInfo::PurchaseAvailable( + const QString &username, + not_null peer) { + if (const auto fragmentLink = AppConfig::FragmentLink(&peer->session())) { + return { + .type = UsernameCheckInfo::Type::Default, + .text = tr::lng_username_purchase_available( + tr::now, + lt_link, + Ui::Text::Link( + tr::lng_username_purchase_available_link(tr::now), + (*fragmentLink) + u"/username/"_q + username), + Ui::Text::RichLangValue), + }; + } else { + return { + .type = UsernameCheckInfo::Type::Error, + .text = { u"INTERNAL_SERVER_ERROR"_q }, + }; + } +} diff --git a/Telegram/SourceFiles/boxes/username_box.h b/Telegram/SourceFiles/boxes/username_box.h index 423631dd1..9a845279f 100644 --- a/Telegram/SourceFiles/boxes/username_box.h +++ b/Telegram/SourceFiles/boxes/username_box.h @@ -19,11 +19,14 @@ void UsernamesBox( not_null peer); struct UsernameCheckInfo final { + [[nodiscard]] static UsernameCheckInfo PurchaseAvailable( + const QString &username, + not_null peer); + enum class Type { Good, Error, Default, - PurchaseAvailable, }; Type type; TextWithEntities text;