mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-04-13 04:37:11 +02:00
Added external link to username field when it is available for purchase.
This commit is contained in:
parent
32d3b90cdc
commit
42842619b0
4 changed files with 33 additions and 22 deletions
|
@ -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.";
|
||||
|
|
|
@ -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());
|
||||
}
|
||||
|
|
|
@ -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<Ui::RpWidget*>, not_null<PeerData*> 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<PeerData*> 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 },
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,11 +19,14 @@ void UsernamesBox(
|
|||
not_null<PeerData*> peer);
|
||||
|
||||
struct UsernameCheckInfo final {
|
||||
[[nodiscard]] static UsernameCheckInfo PurchaseAvailable(
|
||||
const QString &username,
|
||||
not_null<PeerData*> peer);
|
||||
|
||||
enum class Type {
|
||||
Good,
|
||||
Error,
|
||||
Default,
|
||||
PurchaseAvailable,
|
||||
};
|
||||
Type type;
|
||||
TextWithEntities text;
|
||||
|
|
Loading…
Add table
Reference in a new issue