mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2025-06-05 06:33:57 +02:00
Removed username from public data members of UserData.
This commit is contained in:
parent
9b7329b378
commit
5751d29c47
26 changed files with 112 additions and 61 deletions
|
@ -418,7 +418,7 @@ void ActivateBotCommand(ClickHandlerContext context, int row, int column) {
|
||||||
}();
|
}();
|
||||||
if (!fastSwitchDone) {
|
if (!fastSwitchDone) {
|
||||||
controller->content()->inlineSwitchLayer('@'
|
controller->content()->inlineSwitchLayer('@'
|
||||||
+ bot->username
|
+ bot->username()
|
||||||
+ ' '
|
+ ' '
|
||||||
+ QString::fromUtf8(button->data));
|
+ QString::fromUtf8(button->data));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1953,7 +1953,7 @@ void Updates::feedUpdate(const MTPUpdate &update) {
|
||||||
|| user->phone().isEmpty())
|
|| user->phone().isEmpty())
|
||||||
? QString()
|
? QString()
|
||||||
: Ui::FormatPhone(user->phone())),
|
: Ui::FormatPhone(user->phone())),
|
||||||
user->username);
|
user->username());
|
||||||
|
|
||||||
session().changes().peerUpdated(
|
session().changes().peerUpdated(
|
||||||
user,
|
user,
|
||||||
|
|
|
@ -3559,7 +3559,7 @@ void ApiWrap::sendBotStart(
|
||||||
: bot.get())));
|
: bot.get())));
|
||||||
message.textWithTags = { u"/start"_q, TextWithTags::Tags() };
|
message.textWithTags = { u"/start"_q, TextWithTags::Tags() };
|
||||||
if (chat) {
|
if (chat) {
|
||||||
message.textWithTags.text += '@' + bot->username;
|
message.textWithTags.text += '@' + bot->username();
|
||||||
}
|
}
|
||||||
sendMessage(std::move(message));
|
sendMessage(std::move(message));
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1446,7 +1446,7 @@ void EditNameBox::saveSelfFail(const QString &error) {
|
||||||
TextUtilities::SingleLine(_first->getLastText().trimmed()),
|
TextUtilities::SingleLine(_first->getLastText().trimmed()),
|
||||||
TextUtilities::SingleLine(_last->getLastText().trimmed()),
|
TextUtilities::SingleLine(_last->getLastText().trimmed()),
|
||||||
QString(),
|
QString(),
|
||||||
TextUtilities::SingleLine(_user->username));
|
TextUtilities::SingleLine(_user->username()));
|
||||||
closeBox();
|
closeBox();
|
||||||
} else if (error == "FIRSTNAME_INVALID") {
|
} else if (error == "FIRSTNAME_INVALID") {
|
||||||
_first->setFocus();
|
_first->setFocus();
|
||||||
|
|
|
@ -57,7 +57,7 @@ void SendRequest(
|
||||||
first,
|
first,
|
||||||
last,
|
last,
|
||||||
user->nameOrPhone,
|
user->nameOrPhone,
|
||||||
user->username);
|
user->username());
|
||||||
user->session().api().applyUpdates(result);
|
user->session().api().applyUpdates(result);
|
||||||
if (const auto settings = user->settings()) {
|
if (const auto settings = user->settings()) {
|
||||||
const auto flags = PeerSetting::AddContact
|
const auto flags = PeerSetting::AddContact
|
||||||
|
|
|
@ -1266,7 +1266,7 @@ void FastShareMessage(
|
||||||
if (const auto media = item->media()) {
|
if (const auto media = item->media()) {
|
||||||
if (const auto game = media->game()) {
|
if (const auto game = media->game()) {
|
||||||
const auto link = session->createInternalLinkFull(
|
const auto link = session->createInternalLinkFull(
|
||||||
bot->username + qsl("?game=") + game->shortName);
|
bot->username() + qsl("?game=") + game->shortName);
|
||||||
|
|
||||||
QGuiApplication::clipboard()->setText(link);
|
QGuiApplication::clipboard()->setText(link);
|
||||||
|
|
||||||
|
|
|
@ -34,7 +34,7 @@ UsernameBox::UsernameBox(QWidget*, not_null<Main::Session*> session)
|
||||||
this,
|
this,
|
||||||
st::defaultInputField,
|
st::defaultInputField,
|
||||||
rpl::single(qsl("@username")),
|
rpl::single(qsl("@username")),
|
||||||
session->user()->username,
|
session->user()->username(),
|
||||||
QString())
|
QString())
|
||||||
, _about(
|
, _about(
|
||||||
this,
|
this,
|
||||||
|
@ -45,7 +45,7 @@ UsernameBox::UsernameBox(QWidget*, not_null<Main::Session*> session)
|
||||||
}
|
}
|
||||||
|
|
||||||
void UsernameBox::prepare() {
|
void UsernameBox::prepare() {
|
||||||
_goodText = _session->user()->username.isEmpty()
|
_goodText = _session->user()->username().isEmpty()
|
||||||
? QString()
|
? QString()
|
||||||
: tr::lng_username_available(tr::now);
|
: tr::lng_username_available(tr::now);
|
||||||
|
|
||||||
|
@ -196,7 +196,7 @@ void UsernameBox::check() {
|
||||||
_checkRequestId = 0;
|
_checkRequestId = 0;
|
||||||
|
|
||||||
_errorText = (mtpIsTrue(result)
|
_errorText = (mtpIsTrue(result)
|
||||||
|| _checkUsername == _session->user()->username)
|
|| _checkUsername == _session->user()->username())
|
||||||
? QString()
|
? QString()
|
||||||
: tr::lng_username_occupied(tr::now);
|
: tr::lng_username_occupied(tr::now);
|
||||||
_goodText = _errorText.isEmpty()
|
_goodText = _errorText.isEmpty()
|
||||||
|
@ -263,7 +263,7 @@ void UsernameBox::linkClick() {
|
||||||
void UsernameBox::updateFail(const QString &error) {
|
void UsernameBox::updateFail(const QString &error) {
|
||||||
const auto self = _session->user();
|
const auto self = _session->user();
|
||||||
if ((error == qstr("USERNAME_NOT_MODIFIED"))
|
if ((error == qstr("USERNAME_NOT_MODIFIED"))
|
||||||
|| (_sentUsername == self->username)) {
|
|| (_sentUsername == self->username())) {
|
||||||
self->setName(
|
self->setName(
|
||||||
TextUtilities::SingleLine(self->firstName),
|
TextUtilities::SingleLine(self->firstName),
|
||||||
TextUtilities::SingleLine(self->lastName),
|
TextUtilities::SingleLine(self->lastName),
|
||||||
|
@ -291,7 +291,7 @@ void UsernameBox::checkFail(const QString &error) {
|
||||||
_errorText = tr::lng_username_invalid(tr::now);
|
_errorText = tr::lng_username_invalid(tr::now);
|
||||||
update();
|
update();
|
||||||
} else if ((error == qstr("USERNAME_OCCUPIED"))
|
} else if ((error == qstr("USERNAME_OCCUPIED"))
|
||||||
&& (_checkUsername != _session->user()->username)) {
|
&& (_checkUsername != _session->user()->username())) {
|
||||||
_errorText = tr::lng_username_occupied(tr::now);
|
_errorText = tr::lng_username_occupied(tr::now);
|
||||||
update();
|
update();
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -33,7 +33,7 @@ QString WrapCommandInChat(
|
||||||
not_null<PeerData*> peer,
|
not_null<PeerData*> peer,
|
||||||
const QString &command,
|
const QString &command,
|
||||||
not_null<UserData*> bot) {
|
not_null<UserData*> bot) {
|
||||||
if (!bot->isBot() || bot->username.isEmpty()) {
|
if (!bot->isBot() || bot->username().isEmpty()) {
|
||||||
return command;
|
return command;
|
||||||
}
|
}
|
||||||
const auto botStatus = peer->isChat()
|
const auto botStatus = peer->isChat()
|
||||||
|
@ -42,7 +42,7 @@ QString WrapCommandInChat(
|
||||||
? peer->asChannel()->mgInfo->botStatus
|
? peer->asChannel()->mgInfo->botStatus
|
||||||
: -1;
|
: -1;
|
||||||
return ((command.indexOf('@') < 2) && (botStatus == 0 || botStatus == 2))
|
return ((command.indexOf('@') < 2) && (botStatus == 0 || botStatus == 2))
|
||||||
? command + '@' + bot->username
|
? command + '@' + bot->username()
|
||||||
: command;
|
: command;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -396,8 +396,9 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
|
||||||
}
|
}
|
||||||
|
|
||||||
auto filterNotPassedByUsername = [this](UserData *user) -> bool {
|
auto filterNotPassedByUsername = [this](UserData *user) -> bool {
|
||||||
if (user->username.startsWith(_filter, Qt::CaseInsensitive)) {
|
if (user->username().startsWith(_filter, Qt::CaseInsensitive)) {
|
||||||
bool exactUsername = (user->username.size() == _filter.size());
|
const auto exactUsername =
|
||||||
|
(user->username().size() == _filter.size());
|
||||||
return exactUsername;
|
return exactUsername;
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
|
@ -405,7 +406,8 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
|
||||||
auto filterNotPassedByName = [&](UserData *user) -> bool {
|
auto filterNotPassedByName = [&](UserData *user) -> bool {
|
||||||
for (const auto &nameWord : user->nameWords()) {
|
for (const auto &nameWord : user->nameWords()) {
|
||||||
if (nameWord.startsWith(_filter, Qt::CaseInsensitive)) {
|
if (nameWord.startsWith(_filter, Qt::CaseInsensitive)) {
|
||||||
auto exactUsername = (user->username.compare(_filter, Qt::CaseInsensitive) == 0);
|
const auto exactUsername =
|
||||||
|
(user->username().compare(_filter, Qt::CaseInsensitive) == 0);
|
||||||
return exactUsername;
|
return exactUsername;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -554,7 +556,7 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
|
||||||
for (const auto &command : *i->second) {
|
for (const auto &command : *i->second) {
|
||||||
if (!listAllSuggestions) {
|
if (!listAllSuggestions) {
|
||||||
auto toFilter = (hasUsername || botStatus == 0 || botStatus == 2)
|
auto toFilter = (hasUsername || botStatus == 0 || botStatus == 2)
|
||||||
? command.command + '@' + user->username
|
? command.command + '@' + user->username()
|
||||||
: command.command;
|
: command.command;
|
||||||
if (!toFilter.startsWith(_filter, Qt::CaseInsensitive)/* || toFilter.size() == _filter.size()*/) {
|
if (!toFilter.startsWith(_filter, Qt::CaseInsensitive)/* || toFilter.size() == _filter.size()*/) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -570,7 +572,11 @@ void FieldAutocomplete::updateFiltered(bool resetScroll) {
|
||||||
const auto user = i->first;
|
const auto user = i->first;
|
||||||
for (const auto &command : *i->second) {
|
for (const auto &command : *i->second) {
|
||||||
if (!listAllSuggestions) {
|
if (!listAllSuggestions) {
|
||||||
QString toFilter = (hasUsername || botStatus == 0 || botStatus == 2) ? command.command + '@' + user->username : command.command;
|
const auto toFilter = (hasUsername
|
||||||
|
|| botStatus == 0
|
||||||
|
|| botStatus == 2)
|
||||||
|
? command.command + '@' + user->username()
|
||||||
|
: command.command;
|
||||||
if (!toFilter.startsWith(_filter, Qt::CaseInsensitive)/* || toFilter.size() == _filter.size()*/) continue;
|
if (!toFilter.startsWith(_filter, Qt::CaseInsensitive)/* || toFilter.size() == _filter.size()*/) continue;
|
||||||
}
|
}
|
||||||
brows.push_back(make(user, command));
|
brows.push_back(make(user, command));
|
||||||
|
@ -934,8 +940,17 @@ void FieldAutocomplete::Inner::paintEvent(QPaintEvent *e) {
|
||||||
if (!_mrows->empty()) {
|
if (!_mrows->empty()) {
|
||||||
auto &row = _mrows->at(i);
|
auto &row = _mrows->at(i);
|
||||||
const auto user = row.user;
|
const auto user = row.user;
|
||||||
auto first = (!filterIsEmpty && user->username.startsWith(filter, Qt::CaseInsensitive)) ? ('@' + user->username.mid(0, filterSize)) : QString();
|
auto first = (!filterIsEmpty
|
||||||
auto second = first.isEmpty() ? (user->username.isEmpty() ? QString() : ('@' + user->username)) : user->username.mid(filterSize);
|
&& user->username().startsWith(
|
||||||
|
filter,
|
||||||
|
Qt::CaseInsensitive))
|
||||||
|
? ('@' + user->username().mid(0, filterSize))
|
||||||
|
: QString();
|
||||||
|
auto second = first.isEmpty()
|
||||||
|
? (user->username().isEmpty()
|
||||||
|
? QString()
|
||||||
|
: ('@' + user->username()))
|
||||||
|
: user->username().mid(filterSize);
|
||||||
auto firstwidth = st::mentionFont->width(first);
|
auto firstwidth = st::mentionFont->width(first);
|
||||||
auto secondwidth = st::mentionFont->width(second);
|
auto secondwidth = st::mentionFont->width(second);
|
||||||
auto unamewidth = firstwidth + secondwidth;
|
auto unamewidth = firstwidth + secondwidth;
|
||||||
|
@ -1000,7 +1015,7 @@ void FieldAutocomplete::Inner::paintEvent(QPaintEvent *e) {
|
||||||
auto toHighlight = row.command;
|
auto toHighlight = row.command;
|
||||||
int32 botStatus = _parent->chat() ? _parent->chat()->botStatus : ((_parent->channel() && _parent->channel()->isMegagroup()) ? _parent->channel()->mgInfo->botStatus : -1);
|
int32 botStatus = _parent->chat() ? _parent->chat()->botStatus : ((_parent->channel() && _parent->channel()->isMegagroup()) ? _parent->channel()->mgInfo->botStatus : -1);
|
||||||
if (hasUsername || botStatus == 0 || botStatus == 2) {
|
if (hasUsername || botStatus == 0 || botStatus == 2) {
|
||||||
toHighlight += '@' + user->username;
|
toHighlight += '@' + user->username();
|
||||||
}
|
}
|
||||||
user->loadUserpic();
|
user->loadUserpic();
|
||||||
user->paintUserpicLeft(p, row.userpic, st::mentionPadding.left(), i * st::mentionHeight + st::mentionPadding.top(), width(), st::mentionPhotoSize);
|
user->paintUserpicLeft(p, row.userpic, st::mentionPadding.left(), i * st::mentionHeight + st::mentionPadding.top(), width(), st::mentionPhotoSize);
|
||||||
|
@ -1157,7 +1172,7 @@ bool FieldAutocomplete::Inner::chooseAtIndex(
|
||||||
|| _parent->filter().indexOf('@') > 0);
|
|| _parent->filter().indexOf('@') > 0);
|
||||||
const auto commandString = QString("/%1%2").arg(
|
const auto commandString = QString("/%1%2").arg(
|
||||||
command,
|
command,
|
||||||
insertUsername ? ('@' + user->username) : QString());
|
insertUsername ? ('@' + user->username()) : QString());
|
||||||
|
|
||||||
_botCommandChosen.fire({ commandString, method });
|
_botCommandChosen.fire({ commandString, method });
|
||||||
return true;
|
return true;
|
||||||
|
|
|
@ -198,7 +198,7 @@ void PeerData::updateNameDelayed(
|
||||||
if (_name == newName && _nameVersion > 1) {
|
if (_name == newName && _nameVersion > 1) {
|
||||||
if (isUser()) {
|
if (isUser()) {
|
||||||
if (asUser()->nameOrPhone == newNameOrPhone
|
if (asUser()->nameOrPhone == newNameOrPhone
|
||||||
&& asUser()->username == newUsername) {
|
&& asUser()->username() == newUsername) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} else if (isChannel()) {
|
} else if (isChannel()) {
|
||||||
|
@ -220,8 +220,8 @@ void PeerData::updateNameDelayed(
|
||||||
flags |= UpdateFlag::Name;
|
flags |= UpdateFlag::Name;
|
||||||
}
|
}
|
||||||
if (isUser()) {
|
if (isUser()) {
|
||||||
if (asUser()->username != newUsername) {
|
if (asUser()->username() != newUsername) {
|
||||||
asUser()->username = newUsername;
|
asUser()->setUsername(newUsername);
|
||||||
flags |= UpdateFlag::Username;
|
flags |= UpdateFlag::Username;
|
||||||
}
|
}
|
||||||
asUser()->setNameOrPhone(newNameOrPhone);
|
asUser()->setNameOrPhone(newNameOrPhone);
|
||||||
|
@ -631,7 +631,7 @@ void PeerData::fillNames() {
|
||||||
if (user->nameOrPhone != name()) {
|
if (user->nameOrPhone != name()) {
|
||||||
appendToIndex(user->nameOrPhone);
|
appendToIndex(user->nameOrPhone);
|
||||||
}
|
}
|
||||||
appendToIndex(user->username);
|
appendToIndex(user->username());
|
||||||
if (isSelf()) {
|
if (isSelf()) {
|
||||||
const auto english = qsl("Saved messages");
|
const auto english = qsl("Saved messages");
|
||||||
const auto localized = tr::lng_saved_messages(tr::now);
|
const auto localized = tr::lng_saved_messages(tr::now);
|
||||||
|
@ -820,7 +820,7 @@ const QString &PeerData::shortName() const {
|
||||||
|
|
||||||
QString PeerData::userName() const {
|
QString PeerData::userName() const {
|
||||||
if (const auto user = asUser()) {
|
if (const auto user = asUser()) {
|
||||||
return user->username;
|
return user->username();
|
||||||
} else if (const auto channel = asChannel()) {
|
} else if (const auto channel = asChannel()) {
|
||||||
return channel->username();
|
return channel->username();
|
||||||
}
|
}
|
||||||
|
|
|
@ -517,12 +517,24 @@ not_null<UserData*> Session::processUser(const MTPUser &data) {
|
||||||
} else {
|
} else {
|
||||||
// apply first_name and last_name from minimal user only if we don't have
|
// apply first_name and last_name from minimal user only if we don't have
|
||||||
// local values for first name and last name already, otherwise skip
|
// local values for first name and last name already, otherwise skip
|
||||||
bool noLocalName = result->firstName.isEmpty() && result->lastName.isEmpty();
|
const auto noLocalName = result->firstName.isEmpty()
|
||||||
QString fname = (!minimal || noLocalName) ? TextUtilities::SingleLine(qs(data.vfirst_name().value_or_empty())) : result->firstName;
|
&& result->lastName.isEmpty();
|
||||||
QString lname = (!minimal || noLocalName) ? TextUtilities::SingleLine(qs(data.vlast_name().value_or_empty())) : result->lastName;
|
const auto fname = (!minimal || noLocalName)
|
||||||
|
? TextUtilities::SingleLine(
|
||||||
|
qs(data.vfirst_name().value_or_empty()))
|
||||||
|
: result->firstName;
|
||||||
|
const auto lname = (!minimal || noLocalName)
|
||||||
|
? TextUtilities::SingleLine(
|
||||||
|
qs(data.vlast_name().value_or_empty()))
|
||||||
|
: result->lastName;
|
||||||
|
|
||||||
QString phone = minimal ? result->phone() : qs(data.vphone().value_or_empty());
|
const auto phone = minimal
|
||||||
QString uname = minimal ? result->username : TextUtilities::SingleLine(qs(data.vusername().value_or_empty()));
|
? result->phone()
|
||||||
|
: qs(data.vphone().value_or_empty());
|
||||||
|
const auto uname = minimal
|
||||||
|
? result->username()
|
||||||
|
: TextUtilities::SingleLine(
|
||||||
|
qs(data.vusername().value_or_empty()));
|
||||||
|
|
||||||
const auto phoneChanged = (result->phone() != phone);
|
const auto phoneChanged = (result->phone() != phone);
|
||||||
if (phoneChanged) {
|
if (phoneChanged) {
|
||||||
|
|
|
@ -119,6 +119,12 @@ void UserData::setName(const QString &newFirstName, const QString &newLastName,
|
||||||
updateNameDelayed(newFullName, newPhoneName, newUsername);
|
updateNameDelayed(newFullName, newPhoneName, newUsername);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void UserData::setUsername(const QString &username) {
|
||||||
|
if (_username != username) {
|
||||||
|
_username = username;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void UserData::setPhone(const QString &newPhone) {
|
void UserData::setPhone(const QString &newPhone) {
|
||||||
if (_phone != newPhone) {
|
if (_phone != newPhone) {
|
||||||
_phone = newPhone;
|
_phone = newPhone;
|
||||||
|
@ -281,6 +287,10 @@ bool UserData::canShareThisContactFast() const {
|
||||||
return !_phone.isEmpty();
|
return !_phone.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const QString &UserData::username() const {
|
||||||
|
return _username;
|
||||||
|
}
|
||||||
|
|
||||||
const QString &UserData::phone() const {
|
const QString &UserData::phone() const {
|
||||||
return _phone;
|
return _phone;
|
||||||
}
|
}
|
||||||
|
|
|
@ -77,6 +77,7 @@ public:
|
||||||
void setEmojiStatus(DocumentId emojiStatusId, TimeId until = 0);
|
void setEmojiStatus(DocumentId emojiStatusId, TimeId until = 0);
|
||||||
[[nodiscard]] DocumentId emojiStatusId() const;
|
[[nodiscard]] DocumentId emojiStatusId() const;
|
||||||
|
|
||||||
|
void setUsername(const QString &username);
|
||||||
void setPhone(const QString &newPhone);
|
void setPhone(const QString &newPhone);
|
||||||
void setBotInfoVersion(int version);
|
void setBotInfoVersion(int version);
|
||||||
void setBotInfo(const MTPBotInfo &info);
|
void setBotInfo(const MTPBotInfo &info);
|
||||||
|
@ -126,8 +127,8 @@ public:
|
||||||
|
|
||||||
QString firstName;
|
QString firstName;
|
||||||
QString lastName;
|
QString lastName;
|
||||||
QString username;
|
|
||||||
[[nodiscard]] const QString &phone() const;
|
[[nodiscard]] const QString &phone() const;
|
||||||
|
[[nodiscard]] const QString &username() const;
|
||||||
QString nameOrPhone;
|
QString nameOrPhone;
|
||||||
TimeId onlineTill = 0;
|
TimeId onlineTill = 0;
|
||||||
|
|
||||||
|
@ -165,6 +166,7 @@ private:
|
||||||
Flags _flags;
|
Flags _flags;
|
||||||
|
|
||||||
std::vector<Data::UnavailableReason> _unavailableReasons;
|
std::vector<Data::UnavailableReason> _unavailableReasons;
|
||||||
|
QString _username;
|
||||||
QString _phone;
|
QString _phone;
|
||||||
ContactStatus _contactStatus = ContactStatus::Unknown;
|
ContactStatus _contactStatus = ContactStatus::Unknown;
|
||||||
CallsStatus _callsStatus = CallsStatus::Unknown;
|
CallsStatus _callsStatus = CallsStatus::Unknown;
|
||||||
|
|
|
@ -3282,7 +3282,7 @@ void HistoryInner::elementSendBotCommand(
|
||||||
}
|
}
|
||||||
|
|
||||||
void HistoryInner::elementHandleViaClick(not_null<UserData*> bot) {
|
void HistoryInner::elementHandleViaClick(not_null<UserData*> bot) {
|
||||||
_widget->insertBotCommand('@' + bot->username);
|
_widget->insertBotCommand('@' + bot->username());
|
||||||
}
|
}
|
||||||
|
|
||||||
bool HistoryInner::elementIsChatWide() {
|
bool HistoryInner::elementIsChatWide() {
|
||||||
|
|
|
@ -53,7 +53,10 @@ void HistoryMessageVia::create(
|
||||||
UserId userId) {
|
UserId userId) {
|
||||||
bot = owner->user(userId);
|
bot = owner->user(userId);
|
||||||
maxWidth = st::msgServiceNameFont->width(
|
maxWidth = st::msgServiceNameFont->width(
|
||||||
tr::lng_inline_bot_via(tr::now, lt_inline_bot, '@' + bot->username));
|
tr::lng_inline_bot_via(
|
||||||
|
tr::now,
|
||||||
|
lt_inline_bot,
|
||||||
|
'@' + bot->username()));
|
||||||
link = std::make_shared<LambdaClickHandler>([bot = this->bot](
|
link = std::make_shared<LambdaClickHandler>([bot = this->bot](
|
||||||
ClickContext context) {
|
ClickContext context) {
|
||||||
const auto my = context.other.value<ClickHandlerContext>();
|
const auto my = context.other.value<ClickHandlerContext>();
|
||||||
|
@ -83,7 +86,10 @@ void HistoryMessageVia::resize(int32 availw) const {
|
||||||
text = QString();
|
text = QString();
|
||||||
width = 0;
|
width = 0;
|
||||||
} else {
|
} else {
|
||||||
text = tr::lng_inline_bot_via(tr::now, lt_inline_bot, '@' + bot->username);
|
text = tr::lng_inline_bot_via(
|
||||||
|
tr::now,
|
||||||
|
lt_inline_bot,
|
||||||
|
'@' + bot->username());
|
||||||
if (availw < maxWidth) {
|
if (availw < maxWidth) {
|
||||||
text = st::msgServiceNameFont->elided(text, availw);
|
text = st::msgServiceNameFont->elided(text, availw);
|
||||||
width = st::msgServiceNameFont->width(text);
|
width = st::msgServiceNameFont->width(text);
|
||||||
|
@ -182,7 +188,7 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const {
|
||||||
lt_channel,
|
lt_channel,
|
||||||
Ui::Text::Link(phrase.text, 1), // Link 1.
|
Ui::Text::Link(phrase.text, 1), // Link 1.
|
||||||
lt_inline_bot,
|
lt_inline_bot,
|
||||||
Ui::Text::Link('@' + via->bot->username, 2), // Link 2.
|
Ui::Text::Link('@' + via->bot->username(), 2), // Link 2.
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
} else {
|
} else {
|
||||||
phrase = tr::lng_forwarded_via(
|
phrase = tr::lng_forwarded_via(
|
||||||
|
@ -190,7 +196,7 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const {
|
||||||
lt_user,
|
lt_user,
|
||||||
Ui::Text::Link(phrase.text, 1), // Link 1.
|
Ui::Text::Link(phrase.text, 1), // Link 1.
|
||||||
lt_inline_bot,
|
lt_inline_bot,
|
||||||
Ui::Text::Link('@' + via->bot->username, 2), // Link 2.
|
Ui::Text::Link('@' + via->bot->username(), 2), // Link 2.
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
|
@ -1333,14 +1333,14 @@ void HistoryWidget::start() {
|
||||||
|
|
||||||
void HistoryWidget::insertMention(UserData *user) {
|
void HistoryWidget::insertMention(UserData *user) {
|
||||||
QString replacement, entityTag;
|
QString replacement, entityTag;
|
||||||
if (user->username.isEmpty()) {
|
if (user->username().isEmpty()) {
|
||||||
replacement = user->firstName;
|
replacement = user->firstName;
|
||||||
if (replacement.isEmpty()) {
|
if (replacement.isEmpty()) {
|
||||||
replacement = user->name();
|
replacement = user->name();
|
||||||
}
|
}
|
||||||
entityTag = PrepareMentionTag(user);
|
entityTag = PrepareMentionTag(user);
|
||||||
} else {
|
} else {
|
||||||
replacement = '@' + user->username;
|
replacement = '@' + user->username();
|
||||||
}
|
}
|
||||||
_field->insertTag(replacement, entityTag);
|
_field->insertTag(replacement, entityTag);
|
||||||
}
|
}
|
||||||
|
@ -1759,7 +1759,10 @@ void HistoryWidget::setInnerFocus() {
|
||||||
bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo) {
|
bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, UserData *samePeerBot, MsgId samePeerReplyTo) {
|
||||||
if (samePeerBot) {
|
if (samePeerBot) {
|
||||||
if (_history) {
|
if (_history) {
|
||||||
TextWithTags textWithTags = { '@' + samePeerBot->username + ' ' + query, TextWithTags::Tags() };
|
const auto textWithTags = TextWithTags{
|
||||||
|
'@' + samePeerBot->username() + ' ' + query,
|
||||||
|
TextWithTags::Tags(),
|
||||||
|
};
|
||||||
MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX };
|
MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX };
|
||||||
_history->setLocalDraft(std::make_unique<Data::Draft>(
|
_history->setLocalDraft(std::make_unique<Data::Draft>(
|
||||||
textWithTags,
|
textWithTags,
|
||||||
|
@ -1781,7 +1784,10 @@ bool HistoryWidget::notify_switchInlineBotButtonReceived(const QString &query, U
|
||||||
bot->botInfo->inlineReturnTo = Dialogs::EntryState();
|
bot->botInfo->inlineReturnTo = Dialogs::EntryState();
|
||||||
using Section = Dialogs::EntryState::Section;
|
using Section = Dialogs::EntryState::Section;
|
||||||
|
|
||||||
TextWithTags textWithTags = { '@' + bot->username + ' ' + query, TextWithTags::Tags() };
|
const auto textWithTags = TextWithTags{
|
||||||
|
'@' + bot->username() + ' ' + query,
|
||||||
|
TextWithTags::Tags(),
|
||||||
|
};
|
||||||
MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX };
|
MessageCursor cursor = { int(textWithTags.text.size()), int(textWithTags.text.size()), QFIXED_MAX };
|
||||||
auto draft = std::make_unique<Data::Draft>(
|
auto draft = std::make_unique<Data::Draft>(
|
||||||
textWithTags,
|
textWithTags,
|
||||||
|
@ -4182,7 +4188,7 @@ bool HistoryWidget::insertBotCommand(const QString &cmd) {
|
||||||
if (bot && (!bot->isUser() || !bot->asUser()->isBot())) {
|
if (bot && (!bot->isUser() || !bot->asUser()->isBot())) {
|
||||||
bot = nullptr;
|
bot = nullptr;
|
||||||
}
|
}
|
||||||
auto username = bot ? bot->asUser()->username : QString();
|
auto username = bot ? bot->asUser()->username() : QString();
|
||||||
auto botStatus = _peer->isChat() ? _peer->asChat()->botStatus : (_peer->isMegagroup() ? _peer->asChannel()->mgInfo->botStatus : -1);
|
auto botStatus = _peer->isChat() ? _peer->asChat()->botStatus : (_peer->isMegagroup() ? _peer->asChannel()->mgInfo->botStatus : -1);
|
||||||
if (toInsert.indexOf('@') < 0 && !username.isEmpty() && (botStatus == 0 || botStatus == 2)) {
|
if (toInsert.indexOf('@') < 0 && !username.isEmpty() && (botStatus == 0 || botStatus == 2)) {
|
||||||
toInsert += '@' + username;
|
toInsert += '@' + username;
|
||||||
|
@ -4818,7 +4824,7 @@ void HistoryWidget::updateFieldPlaceholder() {
|
||||||
if (!_editMsgId && _inlineBot && !_inlineLookingUpBot) {
|
if (!_editMsgId && _inlineBot && !_inlineLookingUpBot) {
|
||||||
_field->setPlaceholder(
|
_field->setPlaceholder(
|
||||||
rpl::single(_inlineBot->botInfo->inlinePlaceholder.mid(1)),
|
rpl::single(_inlineBot->botInfo->inlinePlaceholder.mid(1)),
|
||||||
_inlineBot->username.size() + 2);
|
_inlineBot->username().size() + 2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1497,12 +1497,12 @@ void ComposeControls::initAutocomplete() {
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
const auto insertMention = [=](not_null<UserData*> user) {
|
const auto insertMention = [=](not_null<UserData*> user) {
|
||||||
if (user->username.isEmpty()) {
|
if (user->username().isEmpty()) {
|
||||||
_field->insertTag(
|
_field->insertTag(
|
||||||
user->firstName.isEmpty() ? user->name() : user->firstName,
|
user->firstName.isEmpty() ? user->name() : user->firstName,
|
||||||
PrepareMentionTag(user));
|
PrepareMentionTag(user));
|
||||||
} else {
|
} else {
|
||||||
_field->insertTag('@' + user->username);
|
_field->insertTag('@' + user->username());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
@ -1604,7 +1604,7 @@ void ComposeControls::updateFieldPlaceholder() {
|
||||||
if (!isEditingMessage() && _isInlineBot) {
|
if (!isEditingMessage() && _isInlineBot) {
|
||||||
_field->setPlaceholder(
|
_field->setPlaceholder(
|
||||||
rpl::single(_inlineBot->botInfo->inlinePlaceholder.mid(1)),
|
rpl::single(_inlineBot->botInfo->inlinePlaceholder.mid(1)),
|
||||||
_inlineBot->username.size() + 2);
|
_inlineBot->username().size() + 2);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1972,7 +1972,7 @@ void RepliesWidget::listSendBotCommand(
|
||||||
}
|
}
|
||||||
|
|
||||||
void RepliesWidget::listHandleViaClick(not_null<UserData*> bot) {
|
void RepliesWidget::listHandleViaClick(not_null<UserData*> bot) {
|
||||||
_composeControls->setText({ '@' + bot->username + ' ' });
|
_composeControls->setText({ '@' + bot->username() + ' ' });
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<Ui::ChatTheme*> RepliesWidget::listChatTheme() {
|
not_null<Ui::ChatTheme*> RepliesWidget::listChatTheme() {
|
||||||
|
|
|
@ -1235,7 +1235,7 @@ void ScheduledWidget::listSendBotCommand(
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScheduledWidget::listHandleViaClick(not_null<UserData*> bot) {
|
void ScheduledWidget::listHandleViaClick(not_null<UserData*> bot) {
|
||||||
_composeControls->setText({ '@' + bot->username + ' ' });
|
_composeControls->setText({ '@' + bot->username() + ' ' });
|
||||||
}
|
}
|
||||||
|
|
||||||
not_null<Ui::ChatTheme*> ScheduledWidget::listChatTheme() {
|
not_null<Ui::ChatTheme*> ScheduledWidget::listChatTheme() {
|
||||||
|
|
|
@ -406,7 +406,7 @@ void AttachWebView::request(
|
||||||
if (botUsername.isEmpty()) {
|
if (botUsername.isEmpty()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
const auto username = _bot ? _bot->username : _botUsername;
|
const auto username = _bot ? _bot->username() : _botUsername;
|
||||||
if (_peer == peer
|
if (_peer == peer
|
||||||
&& username.toLower() == botUsername.toLower()
|
&& username.toLower() == botUsername.toLower()
|
||||||
&& _startCommand == startCommand) {
|
&& _startCommand == startCommand) {
|
||||||
|
@ -879,7 +879,7 @@ void AttachWebView::show(
|
||||||
.url = url,
|
.url = url,
|
||||||
.userDataPath = _session->domain().local().webviewDataPath(),
|
.userDataPath = _session->domain().local().webviewDataPath(),
|
||||||
.title = std::move(title),
|
.title = std::move(title),
|
||||||
.bottom = rpl::single('@' + _bot->username),
|
.bottom = rpl::single('@' + _bot->username()),
|
||||||
.handleLocalUri = handleLocalUri,
|
.handleLocalUri = handleLocalUri,
|
||||||
.handleInvoice = handleInvoice,
|
.handleInvoice = handleInvoice,
|
||||||
.sendData = sendData,
|
.sendData = sendData,
|
||||||
|
|
|
@ -148,7 +148,7 @@ not_null<Ui::RpWidget*> PanelForm::setupContent() {
|
||||||
auto text = policyUrl.isEmpty()
|
auto text = policyUrl.isEmpty()
|
||||||
? tr::lng_passport_allow(
|
? tr::lng_passport_allow(
|
||||||
lt_bot,
|
lt_bot,
|
||||||
rpl::single('@' + bot->username)
|
rpl::single('@' + bot->username())
|
||||||
) | Ui::Text::ToWithEntities()
|
) | Ui::Text::ToWithEntities()
|
||||||
: tr::lng_passport_accept_allow(
|
: tr::lng_passport_accept_allow(
|
||||||
lt_policy,
|
lt_policy,
|
||||||
|
@ -157,7 +157,7 @@ not_null<Ui::RpWidget*> PanelForm::setupContent() {
|
||||||
rpl::single(bot->name())
|
rpl::single(bot->name())
|
||||||
) | Ui::Text::ToLink(policyUrl),
|
) | Ui::Text::ToLink(policyUrl),
|
||||||
lt_bot,
|
lt_bot,
|
||||||
rpl::single('@' + bot->username) | Ui::Text::ToWithEntities(),
|
rpl::single('@' + bot->username()) | Ui::Text::ToWithEntities(),
|
||||||
Ui::Text::WithEntities);
|
Ui::Text::WithEntities);
|
||||||
const auto policy = inner->add(
|
const auto policy = inner->add(
|
||||||
object_ptr<Ui::FlatLabel>(
|
object_ptr<Ui::FlatLabel>(
|
||||||
|
|
|
@ -421,7 +421,7 @@ void Form::processDetails(const MTPDpayments_paymentForm &data) {
|
||||||
if (const auto botId = _details.botId) {
|
if (const auto botId = _details.botId) {
|
||||||
if (const auto bot = _session->data().userLoaded(botId)) {
|
if (const auto bot = _session->data().userLoaded(botId)) {
|
||||||
_invoice.cover.seller = bot->name();
|
_invoice.cover.seller = bot->name();
|
||||||
_details.termsBotUsername = bot->username;
|
_details.termsBotUsername = bot->username();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (const auto providerId = _details.providerId) {
|
if (const auto providerId = _details.providerId) {
|
||||||
|
|
|
@ -439,8 +439,8 @@ std::unique_ptr<PeerListRow> BlockedBoxController::createRow(
|
||||||
return tr::lng_group_status(tr::now);
|
return tr::lng_group_status(tr::now);
|
||||||
} else if (!user->phone().isEmpty()) {
|
} else if (!user->phone().isEmpty()) {
|
||||||
return Ui::FormatPhone(user->phone());
|
return Ui::FormatPhone(user->phone());
|
||||||
} else if (!user->username.isEmpty()) {
|
} else if (!user->username().isEmpty()) {
|
||||||
return '@' + user->username;
|
return '@' + user->username();
|
||||||
} else if (user->isBot()) {
|
} else if (user->isBot()) {
|
||||||
return tr::lng_status_bot(tr::now);
|
return tr::lng_status_bot(tr::now);
|
||||||
}
|
}
|
||||||
|
|
|
@ -121,7 +121,7 @@ uint32 peerSize(not_null<PeerData*> peer) {
|
||||||
result += stringSize(user->firstName)
|
result += stringSize(user->firstName)
|
||||||
+ stringSize(user->lastName)
|
+ stringSize(user->lastName)
|
||||||
+ stringSize(user->phone())
|
+ stringSize(user->phone())
|
||||||
+ stringSize(user->username)
|
+ stringSize(user->username())
|
||||||
+ sizeof(quint64) // access
|
+ sizeof(quint64) // access
|
||||||
+ sizeof(qint32) // flags
|
+ sizeof(qint32) // flags
|
||||||
+ sizeof(qint32) // onlineTill
|
+ sizeof(qint32) // onlineTill
|
||||||
|
@ -164,7 +164,7 @@ void writePeer(QDataStream &stream, not_null<PeerData*> peer) {
|
||||||
<< user->firstName
|
<< user->firstName
|
||||||
<< user->lastName
|
<< user->lastName
|
||||||
<< user->phone()
|
<< user->phone()
|
||||||
<< user->username
|
<< user->username()
|
||||||
<< quint64(user->accessHash())
|
<< quint64(user->accessHash())
|
||||||
<< qint32(user->flags())
|
<< qint32(user->flags())
|
||||||
<< botInlinePlaceholder
|
<< botInlinePlaceholder
|
||||||
|
|
|
@ -2537,7 +2537,7 @@ void Account::readRecentHashtagsAndBots() {
|
||||||
} else if (peer->isUser()
|
} else if (peer->isUser()
|
||||||
&& peer->asUser()->isBot()
|
&& peer->asUser()->isBot()
|
||||||
&& !peer->asUser()->botInfo->inlinePlaceholder.isEmpty()
|
&& !peer->asUser()->botInfo->inlinePlaceholder.isEmpty()
|
||||||
&& !peer->asUser()->username.isEmpty()) {
|
&& !peer->asUser()->username().isEmpty()) {
|
||||||
bots.push_back(peer->asUser());
|
bots.push_back(peer->asUser());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -957,9 +957,9 @@ QString Manager::addTargetAccountName(
|
||||||
return add
|
return add
|
||||||
? (title
|
? (title
|
||||||
+ accountNameSeparator()
|
+ accountNameSeparator()
|
||||||
+ (session->user()->username.isEmpty()
|
+ (session->user()->username().isEmpty()
|
||||||
? session->user()->name()
|
? session->user()->name()
|
||||||
: session->user()->username))
|
: session->user()->username()))
|
||||||
: title;
|
: title;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Reference in a new issue