Set name / phone texts on-demand.

This commit is contained in:
John Preston 2022-08-09 14:12:19 +03:00
parent ceb7d5f238
commit 8bc807dc40
98 changed files with 426 additions and 260 deletions

View file

@ -280,7 +280,7 @@ void ConfirmInviteBox::prepare() {
auto name = new Ui::FlatLabel(this, st::confirmInviteUserName); auto name = new Ui::FlatLabel(this, st::confirmInviteUserName);
name->resizeToWidth(st::confirmInviteUserPhotoSize + padding); name->resizeToWidth(st::confirmInviteUserPhotoSize + padding);
name->setText(participant.user->firstName.isEmpty() name->setText(participant.user->firstName.isEmpty()
? participant.user->name ? participant.user->name()
: participant.user->firstName); : participant.user->firstName);
name->moveToLeft(left + (padding / 2), st::confirmInviteUserNameTop); name->moveToLeft(left + (padding / 2), st::confirmInviteUserNameTop);
left += _userWidth; left += _userWidth;

View file

@ -103,7 +103,7 @@ void SendExistingMedia(
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as; sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
} }
const auto messagePostAuthor = peer->isBroadcast() const auto messagePostAuthor = peer->isBroadcast()
? session->user()->name ? session->user()->name()
: QString(); : QString();
auto caption = TextWithEntities{ auto caption = TextWithEntities{
@ -290,7 +290,7 @@ bool SendDice(MessageToSend &message) {
sendFlags |= MTPmessages_SendMedia::Flag::f_send_as; sendFlags |= MTPmessages_SendMedia::Flag::f_send_as;
} }
const auto messagePostAuthor = peer->isBroadcast() const auto messagePostAuthor = peer->isBroadcast()
? session->user()->name ? session->user()->name()
: QString(); : QString();
const auto replyTo = message.action.replyTo; const auto replyTo = message.action.replyTo;
@ -423,7 +423,7 @@ void SendConfirmedFile(
? PeerId() ? PeerId()
: session->userPeerId(); : session->userPeerId();
const auto messagePostAuthor = peer->isBroadcast() const auto messagePostAuthor = peer->isBroadcast()
? session->user()->name ? session->user()->name()
: QString(); : QString();
const auto media = MTPMessageMedia([&] { const auto media = MTPMessageMedia([&] {

View file

@ -426,12 +426,12 @@ void RegenerateParticipants(not_null<State*> state, int small, int large) {
const auto id = peer->id.value; const auto id = peer->id.value;
const auto was = ranges::find(old, id, &Ui::WhoReadParticipant::id); const auto was = ranges::find(old, id, &Ui::WhoReadParticipant::id);
if (was != end(old)) { if (was != end(old)) {
was->name = peer->name; was->name = peer->name();
now.push_back(std::move(*was)); now.push_back(std::move(*was));
continue; continue;
} }
now.push_back({ now.push_back({
.name = peer->name, .name = peer->name(),
.reaction = userpic.reaction, .reaction = userpic.reaction,
.userpicLarge = GenerateUserpic(userpic, large), .userpicLarge = GenerateUserpic(userpic, large),
.userpicKey = userpic.uniqueKey, .userpicKey = userpic.uniqueKey,

View file

@ -3199,7 +3199,7 @@ void ApiWrap::forwardMessages(
? PeerId(0) ? PeerId(0)
: self->id; : self->id;
const auto messagePostAuthor = peer->isBroadcast() const auto messagePostAuthor = peer->isBroadcast()
? self->name ? self->name()
: QString(); : QString();
history->addNewLocalMessage( history->addNewLocalMessage(
newId.msg, newId.msg,
@ -3282,7 +3282,7 @@ void ApiWrap::sendSharedContact(
? PeerId() ? PeerId()
: _session->userPeerId(); : _session->userPeerId();
const auto messagePostAuthor = peer->isBroadcast() const auto messagePostAuthor = peer->isBroadcast()
? _session->user()->name ? _session->user()->name()
: QString(); : QString();
const auto viaBotId = UserId(); const auto viaBotId = UserId();
const auto item = history->addNewLocalMessage( const auto item = history->addNewLocalMessage(
@ -3545,7 +3545,7 @@ void ApiWrap::sendMessage(MessageToSend &&message) {
sendFlags |= MTPmessages_SendMessage::Flag::f_send_as; sendFlags |= MTPmessages_SendMessage::Flag::f_send_as;
} }
const auto messagePostAuthor = peer->isBroadcast() const auto messagePostAuthor = peer->isBroadcast()
? _session->user()->name ? _session->user()->name()
: QString(); : QString();
if (action.options.scheduled) { if (action.options.scheduled) {
flags |= MessageFlag::IsOrWasScheduled; flags |= MessageFlag::IsOrWasScheduled;
@ -3693,7 +3693,7 @@ void ApiWrap::sendInlineResult(
sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_send_as; sendFlags |= MTPmessages_SendInlineBotResult::Flag::f_send_as;
} }
const auto messagePostAuthor = peer->isBroadcast() const auto messagePostAuthor = peer->isBroadcast()
? _session->user()->name ? _session->user()->name()
: QString(); : QString();
_session->data().registerMessageRandomId(randomId, newId); _session->data().registerMessageRandomId(randomId, newId);

View file

@ -1091,7 +1091,7 @@ void SetupChannelBox::save() {
MTP_string(_sentUsername) MTP_string(_sentUsername)
)).done([=] { )).done([=] {
_channel->setName( _channel->setName(
TextUtilities::SingleLine(_channel->name), TextUtilities::SingleLine(_channel->name()),
_sentUsername); _sentUsername);
closeBox(); closeBox();
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
@ -1239,7 +1239,7 @@ void SetupChannelBox::updateFail(UsernameResult result) {
if ((result == UsernameResult::Ok) if ((result == UsernameResult::Ok)
|| (_sentUsername == _channel->username)) { || (_sentUsername == _channel->username)) {
_channel->setName( _channel->setName(
TextUtilities::SingleLine(_channel->name), TextUtilities::SingleLine(_channel->name()),
TextUtilities::SingleLine(_sentUsername)); TextUtilities::SingleLine(_sentUsername));
closeBox(); closeBox();
} else if (result == UsernameResult::Invalid) { } else if (result == UsernameResult::Invalid) {

View file

@ -69,7 +69,7 @@ void ChangeFilterById(
MTP_flags(MTPmessages_UpdateDialogFilter::Flag::f_filter), MTP_flags(MTPmessages_UpdateDialogFilter::Flag::f_filter),
MTP_int(filter.id()), MTP_int(filter.id()),
filter.tl() filter.tl()
)).done([=, chat = history->peer->name, filterName = filter.title()] { )).done([=, chat = history->peer->name(), name = filter.title()]{
// Since only the primary window has dialogs list, // Since only the primary window has dialogs list,
// We can safely show toast there. // We can safely show toast there.
if (const auto controller = Core::App().primaryWindow()) { if (const auto controller = Core::App().primaryWindow()) {
@ -80,7 +80,7 @@ void ChangeFilterById(
lt_chat, lt_chat,
Ui::Text::Bold(chat), Ui::Text::Bold(chat),
lt_folder, lt_folder,
Ui::Text::Bold(filterName), Ui::Text::Bold(name),
Ui::Text::WithEntities); Ui::Text::WithEntities);
Ui::Toast::Show( Ui::Toast::Show(
Window::Show(controller).toastParent(), Window::Show(controller).toastParent(),

View file

@ -120,20 +120,29 @@ void DeleteMessagesBox::prepare() {
: peer->isSelf() : peer->isSelf()
? tr::lng_sure_delete_saved_messages(tr::now) ? tr::lng_sure_delete_saved_messages(tr::now)
: peer->isUser() : peer->isUser()
? tr::lng_sure_delete_history(tr::now, lt_contact, peer->name) ? tr::lng_sure_delete_history(
tr::now,
lt_contact,
peer->name())
: tr::lng_sure_delete_group_history( : tr::lng_sure_delete_group_history(
tr::now, tr::now,
lt_group, lt_group,
peer->name); peer->name());
details = Ui::Text::RichLangValue(details.text); details = Ui::Text::RichLangValue(details.text);
deleteStyle = &st::attentionBoxButton; deleteStyle = &st::attentionBoxButton;
} else { } else {
details.text = peer->isSelf() details.text = peer->isSelf()
? tr::lng_sure_delete_saved_messages(tr::now) ? tr::lng_sure_delete_saved_messages(tr::now)
: peer->isUser() : peer->isUser()
? tr::lng_sure_delete_history(tr::now, lt_contact, peer->name) ? tr::lng_sure_delete_history(
tr::now,
lt_contact,
peer->name())
: peer->isChat() : peer->isChat()
? tr::lng_sure_delete_and_exit(tr::now, lt_group, peer->name) ? tr::lng_sure_delete_and_exit(
tr::now,
lt_group,
peer->name())
: peer->isMegagroup() : peer->isMegagroup()
? tr::lng_sure_leave_group(tr::now) ? tr::lng_sure_leave_group(tr::now)
: tr::lng_sure_leave_channel(tr::now); : tr::lng_sure_leave_channel(tr::now);
@ -189,7 +198,7 @@ void DeleteMessagesBox::prepare() {
tr::lng_delete_all_from_user( tr::lng_delete_all_from_user(
tr::now, tr::now,
lt_user, lt_user,
Ui::Text::Bold(_moderateFrom->name), Ui::Text::Bold(_moderateFrom->name()),
Ui::Text::WithEntities), Ui::Text::WithEntities),
false, false,
st::defaultBoxCheckbox); st::defaultBoxCheckbox);

View file

@ -11,6 +11,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "chat_helpers/emoji_suggestions_widget.h" #include "chat_helpers/emoji_suggestions_widget.h"
#include "ui/layers/generic_box.h" #include "ui/layers/generic_box.h"
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/text/text_options.h"
#include "ui/widgets/buttons.h" #include "ui/widgets/buttons.h"
#include "ui/widgets/input_fields.h" #include "ui/widgets/input_fields.h"
#include "ui/effects/panel_animation.h" #include "ui/effects/panel_animation.h"
@ -82,6 +83,7 @@ private:
struct PeerButton { struct PeerButton {
not_null<History*> history; not_null<History*> history;
std::shared_ptr<Data::CloudImageView> userpic; std::shared_ptr<Data::CloudImageView> userpic;
Ui::Text::String name;
Button button; Button button;
}; };
@ -208,7 +210,7 @@ int FilterChatsPreview::resizeGetHeight(int newWidth) {
for (const auto &[flag, button] : _removeFlag) { for (const auto &[flag, button] : _removeFlag) {
moveNextButton(button.get()); moveNextButton(button.get());
} }
for (const auto &[history, userpic, button] : _removePeer) { for (const auto &[history, userpic, name, button] : _removePeer) {
moveNextButton(button.get()); moveNextButton(button.get());
} }
return top; return top;
@ -240,7 +242,7 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) {
FilterChatsTypeName(flag)); FilterChatsTypeName(flag));
top += st.height; top += st.height;
} }
for (auto &[history, userpic, button] : _removePeer) { for (auto &[history, userpic, name, button] : _removePeer) {
const auto savedMessages = history->peer->isSelf(); const auto savedMessages = history->peer->isSelf();
const auto repliesMessages = history->peer->isRepliesChat(); const auto repliesMessages = history->peer->isRepliesChat();
if (savedMessages || repliesMessages) { if (savedMessages || repliesMessages) {
@ -276,7 +278,13 @@ void FilterChatsPreview::paintEvent(QPaintEvent *e) {
width(), width(),
st.photoSize); st.photoSize);
p.setPen(st::contactsNameFg); p.setPen(st::contactsNameFg);
history->peer->nameText().drawLeftElided( if (name.isEmpty()) {
name.setText(
st::msgNameStyle,
history->peer->name(),
Ui::NameTextOptions());
}
name.drawLeftElided(
p, p,
nameLeft, nameLeft,
top + nameTop, top + nameTop,

View file

@ -46,7 +46,7 @@ void MuteSettingsBox::prepare() {
icon->moveToLeft(st::boxPadding.left(), y); icon->moveToLeft(st::boxPadding.left(), y);
object_ptr<Ui::FlatLabel> title(this, st::muteChatTitle); object_ptr<Ui::FlatLabel> title(this, st::muteChatTitle);
title->setText(_peer->name); title->setText(_peer->name());
title->moveToLeft( title->moveToLeft(
st::boxPadding.left() + st::muteChatTitleLeft, st::boxPadding.left() + st::muteChatTitleLeft,
y + (icon->height() / 2) - (title->height() / 2)); y + (icon->height() / 2) - (title->height() / 2));

View file

@ -613,7 +613,7 @@ void PeerListRow::elementsPaint(
} }
QString PeerListRow::generateName() { QString PeerListRow::generateName() {
return peer()->name; return peer()->name();
} }
QString PeerListRow::generateShortName() { QString PeerListRow::generateShortName() {

View file

@ -207,9 +207,15 @@ void AddBotToGroupBoxController::shareBotGame(not_null<PeerData*> chat) {
}); });
auto confirmText = [chat] { auto confirmText = [chat] {
if (chat->isUser()) { if (chat->isUser()) {
return tr::lng_bot_sure_share_game(tr::now, lt_user, chat->name); return tr::lng_bot_sure_share_game(
tr::now,
lt_user,
chat->name());
} }
return tr::lng_bot_sure_share_game_group(tr::now, lt_group, chat->name); return tr::lng_bot_sure_share_game_group(
tr::now,
lt_group,
chat->name());
}(); }();
_controller->show( _controller->show(
Ui::MakeConfirmBox({ Ui::MakeConfirmBox({
@ -320,7 +326,7 @@ void AddBotToGroupBoxController::addBotToGroup(not_null<PeerData*> chat) {
}); });
controller->show( controller->show(
Ui::MakeConfirmBox({ Ui::MakeConfirmBox({
tr::lng_bot_sure_invite(tr::now, lt_group, chat->name), tr::lng_bot_sure_invite(tr::now, lt_group, chat->name()),
std::move(callback), std::move(callback),
}), }),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);

View file

@ -262,16 +262,16 @@ void AddParticipantsBoxController::inviteSelectedUsers(
? tr::lng_participant_invite_sure( ? tr::lng_participant_invite_sure(
tr::now, tr::now,
lt_user, lt_user,
{ users.front()->name }, { users.front()->name()},
lt_group, lt_group,
{ _peer->name }, { _peer->name()},
Ui::Text::RichLangValue) Ui::Text::RichLangValue)
: tr::lng_participant_invite_sure_many( : tr::lng_participant_invite_sure_many(
tr::now, tr::now,
lt_count, lt_count,
int(users.size()), int(users.size()),
lt_group, lt_group,
{ _peer->name }, { _peer->name() },
Ui::Text::RichLangValue); Ui::Text::RichLangValue);
Ui::ConfirmBox(box, { Ui::ConfirmBox(box, {
.text = std::move(text), .text = std::move(text),
@ -834,7 +834,7 @@ void AddSpecialBoxController::kickUser(
: tr::lng_profile_sure_kick_channel)( : tr::lng_profile_sure_kick_channel)(
tr::now, tr::now,
lt_user, lt_user,
participant->name); participant->name());
_editBox = showBox(Ui::MakeConfirmBox({ text, kickUserSure })); _editBox = showBox(Ui::MakeConfirmBox({ text, kickUserSure }));
return; return;
} }

View file

@ -134,9 +134,9 @@ void Controller::choose(not_null<ChannelData*> chat) {
auto text = tr::lng_manage_discussion_group_sure( auto text = tr::lng_manage_discussion_group_sure(
tr::now, tr::now,
lt_group, lt_group,
Ui::Text::Bold(chat->name), Ui::Text::Bold(chat->name()),
lt_channel, lt_channel,
Ui::Text::Bold(_channel->name), Ui::Text::Bold(_channel->name()),
Ui::Text::WithEntities); Ui::Text::WithEntities);
if (!_channel->isPublic()) { if (!_channel->isPublic()) {
text.append( text.append(
@ -170,9 +170,9 @@ void Controller::choose(not_null<ChatData*> chat) {
auto text = tr::lng_manage_discussion_group_sure( auto text = tr::lng_manage_discussion_group_sure(
tr::now, tr::now,
lt_group, lt_group,
Ui::Text::Bold(chat->name), Ui::Text::Bold(chat->name()),
lt_channel, lt_channel,
Ui::Text::Bold(_channel->name), Ui::Text::Bold(_channel->name()),
Ui::Text::WithEntities); Ui::Text::WithEntities);
if (!_channel->isPublic()) { if (!_channel->isPublic()) {
text.append("\n\n" + tr::lng_manage_linked_channel_private(tr::now)); text.append("\n\n" + tr::lng_manage_linked_channel_private(tr::now));
@ -212,13 +212,13 @@ object_ptr<Ui::RpWidget> SetupAbout(
return tr::lng_manage_linked_channel_about( return tr::lng_manage_linked_channel_about(
tr::now, tr::now,
lt_channel, lt_channel,
Ui::Text::Bold(chat->name), Ui::Text::Bold(chat->name()),
Ui::Text::WithEntities); Ui::Text::WithEntities);
} else if (chat != nullptr) { } else if (chat != nullptr) {
return tr::lng_manage_discussion_group_about_chosen( return tr::lng_manage_discussion_group_about_chosen(
tr::now, tr::now,
lt_group, lt_group,
Ui::Text::Bold(chat->name), Ui::Text::Bold(chat->name()),
Ui::Text::WithEntities); Ui::Text::WithEntities);
} }
return tr::lng_manage_discussion_group_about( return tr::lng_manage_discussion_group_about(
@ -257,7 +257,7 @@ object_ptr<Ui::RpWidget> SetupCreateGroup(
Box<GroupInfoBox>( Box<GroupInfoBox>(
navigation, navigation,
GroupInfoBox::Type::Megagroup, GroupInfoBox::Type::Megagroup,
channel->name + " Chat", channel->name() + " Chat",
guarded), guarded),
Ui::LayerOption::KeepOther); Ui::LayerOption::KeepOther);
}); });

View file

@ -99,7 +99,7 @@ EditParticipantBox::Inner::Inner(
_userPhoto->setPointerCursor(false); _userPhoto->setPointerCursor(false);
_userName.setText( _userName.setText(
st::rightsNameStyle, st::rightsNameStyle,
_user->name, _user->name(),
Ui::NameTextOptions()); Ui::NameTextOptions());
} }
@ -394,7 +394,7 @@ void EditAdminBox::prepare() {
phrase( phrase(
tr::now, tr::now,
lt_group, lt_group,
Ui::Text::Bold(peer()->name), Ui::Text::Bold(peer()->name()),
Ui::Text::WithEntities), Ui::Text::WithEntities),
crl::guard(this, [=] { finishAddAdmin(); }) crl::guard(this, [=] { finishAddAdmin(); })
}), Ui::LayerOption::KeepOther); }), Ui::LayerOption::KeepOther);
@ -542,7 +542,7 @@ void EditAdminBox::transferOwnership() {
.text = tr::lng_rights_transfer_about( .text = tr::lng_rights_transfer_about(
tr::now, tr::now,
lt_group, lt_group,
Ui::Text::Bold(peer()->name), Ui::Text::Bold(peer()->name()),
lt_user, lt_user,
Ui::Text::Bold(user()->shortName()), Ui::Text::Bold(user()->shortName()),
Ui::Text::RichLangValue), Ui::Text::RichLangValue),

View file

@ -1298,7 +1298,7 @@ void ParticipantsBoxController::rebuildChatAdmins(
list.emplace_back(creator); list.emplace_back(creator);
} }
ranges::sort(list, [](not_null<UserData*> a, not_null<UserData*> b) { ranges::sort(list, [](not_null<UserData*> a, not_null<UserData*> b) {
return (a->name.compare(b->name, Qt::CaseInsensitive) < 0); return (a->name().compare(b->name(), Qt::CaseInsensitive) < 0);
}); });
const auto same = [&] { const auto same = [&] {
@ -1723,7 +1723,7 @@ void ParticipantsBoxController::kickParticipant(not_null<PeerData*> participant)
: tr::lng_profile_sure_kick_channel)( : tr::lng_profile_sure_kick_channel)(
tr::now, tr::now,
lt_user, lt_user,
user ? user->firstName : participant->name); user ? user->firstName : participant->name());
_editBox = showBox( _editBox = showBox(
Ui::MakeConfirmBox({ Ui::MakeConfirmBox({
.text = text, .text = text,
@ -1967,7 +1967,7 @@ void ParticipantsBoxController::refreshCustomStatus(
row->setCustomStatus(tr::lng_channel_admin_status_promoted_by( row->setCustomStatus(tr::lng_channel_admin_status_promoted_by(
tr::now, tr::now,
lt_user, lt_user,
by->name)); by->name()));
} else { } else {
if (_additional.isCreator(user)) { if (_additional.isCreator(user)) {
row->setCustomStatus( row->setCustomStatus(
@ -1984,7 +1984,7 @@ void ParticipantsBoxController::refreshCustomStatus(
: tr::lng_channel_banned_status_restricted_by)( : tr::lng_channel_banned_status_restricted_by)(
tr::now, tr::now,
lt_user, lt_user,
by ? by->name : "Unknown")); by ? by->name() : "Unknown"));
} }
} }

View file

@ -473,7 +473,7 @@ object_ptr<Ui::RpWidget> Controller::createTitleEdit() {
(_isGroup (_isGroup
? tr::lng_dlg_new_group_name ? tr::lng_dlg_new_group_name
: tr::lng_dlg_new_channel_name)(), : tr::lng_dlg_new_channel_name)(),
_peer->name), _peer->name()),
st::editPeerTitleMargins); st::editPeerTitleMargins);
result->entity()->setMaxLength(Ui::EditPeer::kMaxGroupChannelTitle); result->entity()->setMaxLength(Ui::EditPeer::kMaxGroupChannelTitle);
result->entity()->setInstantReplaces(Ui::InstantReplaces::Default()); result->entity()->setInstantReplaces(Ui::InstantReplaces::Default());
@ -769,15 +769,13 @@ void Controller::fillLinkedChatButton() {
auto label = isGroup auto label = isGroup
? _linkedChatUpdates.events( ? _linkedChatUpdates.events(
) | rpl::map([](ChannelData *chat) { ) | rpl::map([](ChannelData *chat) {
return chat ? chat->name : QString(); return chat ? chat->name() : QString();
}) | rpl::type_erased() }) | rpl::type_erased()
: rpl::combine( : rpl::combine(
tr::lng_manage_discussion_group_add(), tr::lng_manage_discussion_group_add(),
_linkedChatUpdates.events() _linkedChatUpdates.events()
) | rpl::map([=](const QString &add, ChannelData *chat) { ) | rpl::map([=](const QString &add, ChannelData *chat) {
return chat return chat ? chat->name() : add;
? chat->name
: add;
}) | rpl::type_erased(); }) | rpl::type_erased();
AddButtonWithText( AddButtonWithText(
_controls.buttonsLayout, _controls.buttonsLayout,
@ -1388,14 +1386,14 @@ void Controller::saveUsername() {
MTP_string(*_savingData.username) MTP_string(*_savingData.username)
)).done([=] { )).done([=] {
channel->setName( channel->setName(
TextUtilities::SingleLine(channel->name), TextUtilities::SingleLine(channel->name()),
*_savingData.username); *_savingData.username);
continueSave(); continueSave();
}).fail([=](const MTP::Error &error) { }).fail([=](const MTP::Error &error) {
const auto &type = error.type(); const auto &type = error.type();
if (type == qstr("USERNAME_NOT_MODIFIED")) { if (type == qstr("USERNAME_NOT_MODIFIED")) {
channel->setName( channel->setName(
TextUtilities::SingleLine(channel->name), TextUtilities::SingleLine(channel->name()),
TextUtilities::SingleLine(*_savingData.username)); TextUtilities::SingleLine(*_savingData.username));
continueSave(); continueSave();
return; return;
@ -1450,7 +1448,7 @@ void Controller::saveLinkedChat() {
} }
void Controller::saveTitle() { void Controller::saveTitle() {
if (!_savingData.title || *_savingData.title == _peer->name) { if (!_savingData.title || *_savingData.title == _peer->name()) {
return continueSave(); return continueSave();
} }

View file

@ -809,7 +809,7 @@ void Controller::processRequest(
: tr::lng_group_requests_was_added)( : tr::lng_group_requests_was_added)(
tr::now, tr::now,
lt_user, lt_user,
Ui::Text::Bold(user->name), Ui::Text::Bold(user->name()),
Ui::Text::WithEntities) Ui::Text::WithEntities)
}); });
} }
@ -1164,7 +1164,7 @@ object_ptr<Ui::BoxContent> ShareInviteLinkBox(
auto text = TextWithEntities(); auto text = TextWithEntities();
if (result.size() > 1) { if (result.size() > 1) {
text.append( text.append(
Ui::Text::Bold(error.second->name) Ui::Text::Bold(error.second->name())
).append("\n\n"); ).append("\n\n");
} }
text.append(error.first); text.append(error.first);

View file

@ -388,7 +388,7 @@ void RequestsBoxController::processRequest(
: tr::lng_group_requests_was_added)( : tr::lng_group_requests_was_added)(
tr::now, tr::now,
lt_user, lt_user,
Ui::Text::Bold(user->name), Ui::Text::Bold(user->name()),
Ui::Text::WithEntities) Ui::Text::WithEntities)
}); });
} }

View file

@ -209,7 +209,7 @@ void ProcessFullPhoto(
const auto user = peer->asUser(); const auto user = peer->asUser();
const auto username = peer->userName(); const auto username = peer->userName();
return PeerShortInfoFields{ return PeerShortInfoFields{
.name = peer->name, .name = peer->name(),
.phone = user ? Ui::FormatPhone(user->phone()) : QString(), .phone = user ? Ui::FormatPhone(user->phone()) : QString(),
.link = ((user || username.isEmpty()) .link = ((user || username.isEmpty())
? QString() ? QString()

View file

@ -356,7 +356,7 @@ void PublicsController::rowRightActionClicked(not_null<PeerListRow*> row) {
lt_link, lt_link,
peer->session().createInternalLink(peer->userName()), peer->session().createInternalLink(peer->userName()),
lt_group, lt_group,
peer->name); peer->name());
const auto confirmText = tr::lng_channels_too_much_public_revoke( const auto confirmText = tr::lng_channels_too_much_public_revoke(
tr::now); tr::now);
const auto closeBox = _closeBox; const auto closeBox = _closeBox;
@ -929,7 +929,7 @@ void AccountsLimitBox(
&& account->session().premiumPossible(); && account->session().premiumPossible();
}) | ranges::views::transform([&](not_null<Main::Account*> account) { }) | ranges::views::transform([&](not_null<Main::Account*> account) {
const auto user = account->session().user(); const auto user = account->session().user();
return Args::Entry{ user->name, PaintUserpicCallback(user, false) }; return Args::Entry{ user->name(), PaintUserpicCallback(user, false)};
}) | ranges::views::take(defaultLimit) | ranges::to_vector; }) | ranges::views::take(defaultLimit) | ranges::to_vector;
const auto premiumPossible = !promotePossible.empty(); const auto premiumPossible = !promotePossible.empty();

View file

@ -726,7 +726,7 @@ void ShareBox::Inner::updateChatName(
? tr::lng_saved_messages(tr::now) ? tr::lng_saved_messages(tr::now)
: peer->isRepliesChat() : peer->isRepliesChat()
? tr::lng_replies_messages(tr::now) ? tr::lng_replies_messages(tr::now)
: peer->name; : peer->name();
chat->name.setText(_st.item.nameStyle, text, Ui::NameTextOptions()); chat->name.setText(_st.item.nameStyle, text, Ui::NameTextOptions());
} }
@ -1306,7 +1306,7 @@ void FastShareMessage(
auto text = TextWithEntities(); auto text = TextWithEntities();
if (result.size() > 1) { if (result.size() > 1) {
text.append( text.append(
Ui::Text::Bold(error.second->name) Ui::Text::Bold(error.second->name())
).append("\n\n"); ).append("\n\n");
} }
text.append(error.first); text.append(error.first);
@ -1386,7 +1386,7 @@ void FastShareMessage(
tr::lng_restricted_send_voice_messages( tr::lng_restricted_send_voice_messages(
tr::now, tr::now,
lt_user, lt_user,
peer->name)); peer->name()));
} }
} }
finish(); finish();

View file

@ -277,7 +277,7 @@ not_null<Ui::RpWidget*> UrlAuthBox::setupContent(
lt_domain, lt_domain,
Ui::Text::Bold(domain), Ui::Text::Bold(domain),
lt_user, lt_user,
Ui::Text::Bold(session->user()->name), Ui::Text::Bold(session->user()->name()),
Ui::Text::WithEntities)); Ui::Text::WithEntities));
const auto allow = bot const auto allow = bot
? addCheckbox(tr::lng_url_auth_allow_messages( ? addCheckbox(tr::lng_url_auth_allow_messages(

View file

@ -1277,11 +1277,13 @@ void Call::setFailedQueued(const QString &error) {
void Call::handleRequestError(const QString &error) { void Call::handleRequestError(const QString &error) {
const auto inform = (error == u"USER_PRIVACY_RESTRICTED"_q) const auto inform = (error == u"USER_PRIVACY_RESTRICTED"_q)
? tr::lng_call_error_not_available(tr::now, lt_user, _user->name) ? tr::lng_call_error_not_available(tr::now, lt_user, _user->name())
: (error == u"PARTICIPANT_VERSION_OUTDATED"_q) : (error == u"PARTICIPANT_VERSION_OUTDATED"_q)
? tr::lng_call_error_outdated(tr::now, lt_user, _user->name) ? tr::lng_call_error_outdated(tr::now, lt_user, _user->name())
: (error == u"CALL_PROTOCOL_LAYER_INVALID"_q) : (error == u"CALL_PROTOCOL_LAYER_INVALID"_q)
? Lang::Hard::CallErrorIncompatible().replace("{user}", _user->name) ? Lang::Hard::CallErrorIncompatible().replace(
"{user}",
_user->name())
: QString(); : QString();
if (!inform.isEmpty()) { if (!inform.isEmpty()) {
Ui::show(Ui::MakeInformBox(inform)); Ui::show(Ui::MakeInformBox(inform));
@ -1291,7 +1293,9 @@ void Call::handleRequestError(const QString &error) {
void Call::handleControllerError(const QString &error) { void Call::handleControllerError(const QString &error) {
const auto inform = (error == u"ERROR_INCOMPATIBLE"_q) const auto inform = (error == u"ERROR_INCOMPATIBLE"_q)
? Lang::Hard::CallErrorIncompatible().replace("{user}", _user->name) ? Lang::Hard::CallErrorIncompatible().replace(
"{user}",
_user->name())
: (error == u"ERROR_AUDIO_IO"_q) : (error == u"ERROR_AUDIO_IO"_q)
? tr::lng_call_error_audio_io(tr::now) ? tr::lng_call_error_audio_io(tr::now)
: QString(); : QString();

View file

@ -188,7 +188,7 @@ object_ptr<Ui::RpWidget> CreateFingerprintAndSignalBars(
tr::lng_call_fingerprint_tooltip( tr::lng_call_fingerprint_tooltip(
tr::now, tr::now,
lt_user, lt_user,
call->user()->name)); call->user()->name()));
raw->setMouseTracking(true); raw->setMouseTracking(true);
raw->events( raw->events(
) | rpl::start_with_next([=](not_null<QEvent*> e) { ) | rpl::start_with_next([=](not_null<QEvent*> e) {

View file

@ -193,8 +193,10 @@ void Instance::startOutgoingCall(not_null<UserData*> user, bool video) {
if (user->callsStatus() == UserData::CallsStatus::Private) { if (user->callsStatus() == UserData::CallsStatus::Private) {
// Request full user once more to refresh the setting in case it was changed. // Request full user once more to refresh the setting in case it was changed.
user->session().api().requestFullPeer(user); user->session().api().requestFullPeer(user);
Ui::show(Ui::MakeInformBox( Ui::show(Ui::MakeInformBox(tr::lng_call_error_not_available(
tr::lng_call_error_not_available(tr::now, lt_user, user->name))); tr::now,
lt_user,
user->name())));
return; return;
} }
requestPermissionsOrFail(crl::guard(this, [=] { requestPermissionsOrFail(crl::guard(this, [=] {

View file

@ -124,7 +124,7 @@ void Panel::replaceCall(not_null<Call*> call) {
void Panel::initWindow() { void Panel::initWindow() {
window()->setAttribute(Qt::WA_OpaquePaintEvent); window()->setAttribute(Qt::WA_OpaquePaintEvent);
window()->setAttribute(Qt::WA_NoSystemBackground); window()->setAttribute(Qt::WA_NoSystemBackground);
window()->setTitle(_user->name); window()->setTitle(_user->name());
window()->setTitleStyle(st::callTitle); window()->setTitleStyle(st::callTitle);
window()->events( window()->events(
@ -473,7 +473,10 @@ void Panel::reinitWithCall(Call *call) {
case ErrorType::NoCamera: case ErrorType::NoCamera:
return tr::lng_call_error_no_camera(tr::now); return tr::lng_call_error_no_camera(tr::now);
case ErrorType::NotVideoCall: case ErrorType::NotVideoCall:
return tr::lng_call_error_camera_outdated(tr::now, lt_user, _user->name); return tr::lng_call_error_camera_outdated(
tr::now,
lt_user,
_user->name());
case ErrorType::NotStartedCall: case ErrorType::NotStartedCall:
return tr::lng_call_error_camera_not_started(tr::now); return tr::lng_call_error_camera_not_started(tr::now);
//case ErrorType::NoMicrophone: //case ErrorType::NoMicrophone:
@ -490,7 +493,7 @@ void Panel::reinitWithCall(Call *call) {
}); });
}, _callLifetime); }, _callLifetime);
_name->setText(_user->name); _name->setText(_user->name());
updateStatusText(_call->state()); updateStatusText(_call->state());
_answerHangupRedial->raise(); _answerHangupRedial->raise();
@ -552,7 +555,7 @@ void Panel::initLayout() {
// _user may change for the same Panel. // _user may change for the same Panel.
return (_call != nullptr) && (update.peer == _user); return (_call != nullptr) && (update.peer == _user);
}) | rpl::start_with_next([=](const Data::PeerUpdate &update) { }) | rpl::start_with_next([=](const Data::PeerUpdate &update) {
_name->setText(_call->user()->name); _name->setText(_call->user()->name());
updateControlsGeometry(); updateControlsGeometry();
}, widget()->lifetime()); }, widget()->lifetime());

View file

@ -644,14 +644,14 @@ void TopBar::updateInfoLabels() {
void TopBar::setInfoLabels() { void TopBar::setInfoLabels() {
if (const auto call = _call.get()) { if (const auto call = _call.get()) {
const auto user = call->user(); const auto user = call->user();
const auto fullName = user->name; const auto fullName = user->name();
const auto shortName = user->firstName; const auto shortName = user->firstName;
_fullInfoLabel->setText(fullName); _fullInfoLabel->setText(fullName);
_shortInfoLabel->setText(shortName); _shortInfoLabel->setText(shortName);
} else if (const auto group = _groupCall.get()) { } else if (const auto group = _groupCall.get()) {
const auto peer = group->peer(); const auto peer = group->peer();
const auto real = peer->groupCall(); const auto real = peer->groupCall();
const auto name = peer->name; const auto name = peer->name();
const auto text = _isGroupConnecting.current() const auto text = _isGroupConnecting.current()
? tr::lng_group_call_connecting(tr::now) ? tr::lng_group_call_connecting(tr::now)
: (real && real->id() == group->id() && !real->title().isEmpty()) : (real && real->id() == group->id() && !real->title().isEmpty())

View file

@ -197,7 +197,7 @@ void Userpic::createCache(Image *image) {
Painter p(&filled); Painter p(&filled);
Ui::EmptyUserpic( Ui::EmptyUserpic(
Data::PeerUserpicColor(_peer->id), Data::PeerUserpicColor(_peer->id),
_peer->name _peer->name()
).paint(p, 0, 0, size, size); ).paint(p, 0, 0, size, size);
} }
//_userPhoto = Images::PixmapFast(Images::Round( //_userPhoto = Images::PixmapFast(Images::Round(

View file

@ -288,7 +288,7 @@ void ChooseJoinAsBox(
} }
const auto name = !existing->title().isEmpty() const auto name = !existing->title().isEmpty()
? existing->title() ? existing->title()
: peer->name; : peer->name();
return (peer->isBroadcast() return (peer->isBroadcast()
? tr::lng_group_call_join_confirm_channel ? tr::lng_group_call_join_confirm_channel
: tr::lng_group_call_join_confirm)( : tr::lng_group_call_join_confirm)(

View file

@ -238,7 +238,7 @@ object_ptr<Ui::BoxContent> PrepareInviteBox(
finish(); finish();
return; return;
} }
const auto name = peer->name; const auto name = peer->name();
const auto text = (nonMembers.size() == 1) const auto text = (nonMembers.size() == 1)
? tr::lng_group_call_add_to_group_one( ? tr::lng_group_call_add_to_group_one(
tr::now, tr::now,

View file

@ -527,7 +527,7 @@ void FillMenu(
if (const auto real = resolveReal()) { if (const auto real = resolveReal()) {
showBox(Box( showBox(Box(
EditGroupCallTitleBox, EditGroupCallTitleBox,
peer->name, peer->name(),
real->title(), real->title(),
livestream, livestream,
done)); done));

View file

@ -1430,7 +1430,7 @@ void Panel::kickParticipant(not_null<PeerData*> participantPeer) {
: tr::lng_group_call_remove_channel)( : tr::lng_group_call_remove_channel)(
tr::now, tr::now,
lt_channel, lt_channel,
participantPeer->name) participantPeer->name())
: (_peer->isBroadcast() : (_peer->isBroadcast()
? tr::lng_profile_sure_kick_channel ? tr::lng_profile_sure_kick_channel
: tr::lng_profile_sure_kick)( : tr::lng_profile_sure_kick)(
@ -1668,7 +1668,7 @@ void Panel::setupEmptyRtmp() {
(_call->rtmpInfo().url.isEmpty() (_call->rtmpInfo().url.isEmpty()
? tr::lng_group_call_no_stream( ? tr::lng_group_call_no_stream(
lt_group, lt_group,
rpl::single(_peer->name)) rpl::single(_peer->name()))
: tr::lng_group_call_no_stream_admin()), : tr::lng_group_call_no_stream_admin()),
_controlsBackgroundColor.color()); _controlsBackgroundColor.color());
_emptyRtmp->setAttribute(Qt::WA_TransparentForMouseEvents); _emptyRtmp->setAttribute(Qt::WA_TransparentForMouseEvents);

View file

@ -156,7 +156,7 @@ object_ptr<ShareBox> ShareInviteLinkBox(
auto text = TextWithEntities(); auto text = TextWithEntities();
if (result.size() > 1) { if (result.size() > 1) {
text.append( text.append(
Ui::Text::Bold(error.second->name) Ui::Text::Bold(error.second->name())
).append("\n\n"); ).append("\n\n");
} }
text.append(error.first); text.append(error.first);

View file

@ -54,7 +54,7 @@ void Toasts::setupJoinAsChanged() {
: tr::lng_group_call_join_as_changed)( : tr::lng_group_call_join_as_changed)(
tr::now, tr::now,
lt_name, lt_name,
Ui::Text::Bold(_call->joinAs()->name), Ui::Text::Bold(_call->joinAs()->name()),
Ui::Text::WithEntities)); Ui::Text::WithEntities));
}, _lifetime); }, _lifetime);
} }
@ -66,7 +66,7 @@ void Toasts::setupTitleChanged() {
}) | rpl::map([=] { }) | rpl::map([=] {
const auto peer = _call->peer(); const auto peer = _call->peer();
return peer->groupCall()->title().isEmpty() return peer->groupCall()->title().isEmpty()
? peer->name ? peer->name()
: peer->groupCall()->title(); : peer->groupCall()->title();
}) | rpl::start_with_next([=](const QString &title) { }) | rpl::start_with_next([=](const QString &title) {
_panel->showToast((_call->peer()->isBroadcast() _panel->showToast((_call->peer()->isBroadcast()
@ -90,7 +90,7 @@ void Toasts::setupAllowedToSpeak() {
const auto real = _call->lookupReal(); const auto real = _call->lookupReal();
const auto name = (real && !real->title().isEmpty()) const auto name = (real && !real->title().isEmpty())
? real->title() ? real->title()
: _call->peer()->name; : _call->peer()->name();
Ui::ShowMultilineToast({ Ui::ShowMultilineToast({
.text = tr::lng_group_call_can_speak( .text = tr::lng_group_call_can_speak(
tr::now, tr::now,

View file

@ -1230,9 +1230,9 @@ void Viewport::RendererGL::validateDatas() {
const auto index = (j - begin(_tileData)); const auto index = (j - begin(_tileData));
_tileDataIndices[i] = index; _tileDataIndices[i] = index;
const auto peer = tiles[i]->row()->peer(); const auto peer = tiles[i]->row()->peer();
if (peer != j->peer if ((j->peer != peer)
|| peer->nameVersion != j->nameVersion || (j->nameVersion != peer->nameVersion())
|| width != j->nameRect.width()) { || (j->nameRect.width() != width)) {
const auto nameTop = pausedBottom + index * nameHeight; const auto nameTop = pausedBottom + index * nameHeight;
j->nameRect = QRect(0, nameTop, width, nameHeight); j->nameRect = QRect(0, nameTop, width, nameHeight);
requests.push_back({ .index = i, .updating = true }); requests.push_back({ .index = i, .updating = true });
@ -1279,7 +1279,7 @@ void Viewport::RendererGL::validateDatas() {
}); });
} }
const auto nameTop = pausedBottom + index * nameHeight; const auto nameTop = pausedBottom + index * nameHeight;
_tileData[index].nameVersion = peer->nameVersion; _tileData[index].nameVersion = peer->nameVersion();
_tileData[index].nameRect = QRect( _tileData[index].nameRect = QRect(
0, 0,
nameTop, nameTop,

View file

@ -937,7 +937,10 @@ void FieldAutocomplete::Inner::paintEvent(QPaintEvent *e) {
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;
auto namewidth = user->nameText().maxWidth(); if (row.name.isEmpty()) {
row.name.setText(st::msgNameStyle, user->name(), Ui::NameTextOptions());
}
auto namewidth = row.name.maxWidth();
if (mentionwidth < unamewidth + namewidth) { if (mentionwidth < unamewidth + namewidth) {
namewidth = (mentionwidth * namewidth) / (namewidth + unamewidth); namewidth = (mentionwidth * namewidth) / (namewidth + unamewidth);
unamewidth = mentionwidth - namewidth; unamewidth = mentionwidth - namewidth;
@ -956,7 +959,7 @@ void FieldAutocomplete::Inner::paintEvent(QPaintEvent *e) {
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);
p.setPen(selected ? st::mentionNameFgOver : st::mentionNameFg); p.setPen(selected ? st::mentionNameFgOver : st::mentionNameFg);
user->nameText().drawElided(p, 2 * st::mentionPadding.left() + st::mentionPhotoSize, i * st::mentionHeight + st::mentionTop, namewidth); row.name.drawElided(p, 2 * st::mentionPadding.left() + st::mentionPhotoSize, i * st::mentionHeight + st::mentionTop, namewidth);
p.setFont(st::mentionFont); p.setFont(st::mentionFont);
p.setPen(selected ? st::mentionFgOverActive : st::mentionFgActive); p.setPen(selected ? st::mentionFgOverActive : st::mentionFgActive);

View file

@ -135,6 +135,7 @@ private:
struct MentionRow { struct MentionRow {
not_null<UserData*> user; not_null<UserData*> user;
Ui::Text::String name;
std::shared_ptr<Data::CloudImageView> userpic; std::shared_ptr<Data::CloudImageView> userpic;
}; };

View file

@ -175,7 +175,7 @@ void BotGameUrlClickHandler::onClick(ClickContext context) const {
.text = tr::lng_allow_bot_pass( .text = tr::lng_allow_bot_pass(
tr::now, tr::now,
lt_bot_name, lt_bot_name,
_bot->name), _bot->name()),
.confirmed = callback, .confirmed = callback,
.confirmText = tr::lng_allow_bot(), .confirmText = tr::lng_allow_bot(),
})); }));
@ -238,7 +238,7 @@ auto MentionNameClickHandler::getTextEntity() const -> TextEntity {
QString MentionNameClickHandler::tooltip() const { QString MentionNameClickHandler::tooltip() const {
if (const auto user = _session->data().userLoaded(_userId)) { if (const auto user = _session->data().userLoaded(_userId)) {
const auto name = user->name; const auto name = user->name();
if (name != _text) { if (name != _text) {
return name; return name;
} }

View file

@ -97,14 +97,20 @@ void ChannelData::setPhoto(const MTPChatPhoto &photo) {
}); });
} }
void ChannelData::setName(const QString &newName, const QString &newUsername) { void ChannelData::setName(
updateNameDelayed(newName.isEmpty() ? name : newName, QString(), newUsername); const QString &newName,
const QString &newUsername) {
updateNameDelayed(newName.isEmpty() ? name() : newName, {}, newUsername);
} }
void ChannelData::setAccessHash(uint64 accessHash) { void ChannelData::setAccessHash(uint64 accessHash) {
access = accessHash; access = accessHash;
input = MTP_inputPeerChannel(MTP_long(peerToChannel(id).bare), MTP_long(accessHash)); input = MTP_inputPeerChannel(
inputChannel = MTP_inputChannel(MTP_long(peerToChannel(id).bare), MTP_long(accessHash)); MTP_long(peerToChannel(id).bare),
MTP_long(accessHash));
inputChannel = MTP_inputChannel(
MTP_long(peerToChannel(id).bare),
MTP_long(accessHash));
} }
void ChannelData::setInviteLink(const QString &newInviteLink) { void ChannelData::setInviteLink(const QString &newInviteLink) {
@ -377,7 +383,7 @@ void ChannelData::markForbidden() {
: MTPDchannelForbidden::Flag::f_broadcast), : MTPDchannelForbidden::Flag::f_broadcast),
MTP_long(peerToChannel(id).bare), MTP_long(peerToChannel(id).bare),
MTP_long(access), MTP_long(access),
MTP_string(name), MTP_string(name()),
MTPint())); MTPint()));
} }

View file

@ -116,7 +116,7 @@ bool ChatData::anyoneCanAddMembers() const {
} }
void ChatData::setName(const QString &newName) { void ChatData::setName(const QString &newName) {
updateNameDelayed(newName.isEmpty() ? name : newName, QString(), QString()); updateNameDelayed(newName.isEmpty() ? name() : newName, {}, {});
} }
void ChatData::applyEditAdmin(not_null<UserData*> user, bool isAdmin) { void ChatData::applyEditAdmin(not_null<UserData*> user, bool isAdmin) {

View file

@ -135,6 +135,10 @@ void Folder::unregisterOne(not_null<History*> history) {
reorderLastHistories(); reorderLastHistories();
} }
int Folder::chatListNameVersion() const {
return 1;
}
void Folder::oneListMessageChanged(HistoryItem *from, HistoryItem *to) { void Folder::oneListMessageChanged(HistoryItem *from, HistoryItem *to) {
if (!applyChatListMessage(to) && _chatListMessage == from) { if (!applyChatListMessage(to) && _chatListMessage == from) {
computeChatListMessage(); computeChatListMessage();

View file

@ -81,6 +81,8 @@ private:
bool applyChatListMessage(HistoryItem *item); bool applyChatListMessage(HistoryItem *item);
void computeChatListMessage(); void computeChatListMessage();
int chatListNameVersion() const override;
void reorderLastHistories(); void reorderLastHistories();
void updateChatListEntryPostponed(); void updateChatListEntryPostponed();

View file

@ -142,7 +142,6 @@ void PeerClickHandler::onClick(ClickContext context) const {
PeerData::PeerData(not_null<Data::Session*> owner, PeerId id) PeerData::PeerData(not_null<Data::Session*> owner, PeerId id)
: id(id) : id(id)
, _owner(owner) { , _owner(owner) {
_nameText.setText(st::msgNameStyle, QString(), Ui::NameTextOptions());
} }
Data::Session &PeerData::owner() const { Data::Session &PeerData::owner() const {
@ -161,7 +160,7 @@ void PeerData::updateNameDelayed(
const QString &newName, const QString &newName,
const QString &newNameOrPhone, const QString &newNameOrPhone,
const QString &newUsername) { const QString &newUsername) {
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) {
@ -175,13 +174,12 @@ void PeerData::updateNameDelayed(
return; return;
} }
} }
name = newName; _name = newName;
_nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
_userpicEmpty = nullptr; _userpicEmpty = nullptr;
auto flags = UpdateFlag::None | UpdateFlag::None; auto flags = UpdateFlag::None | UpdateFlag::None;
auto oldFirstLetters = base::flat_set<QChar>(); auto oldFirstLetters = base::flat_set<QChar>();
const auto nameUpdated = (nameVersion++ > 1); const auto nameUpdated = (_nameVersion++ > 1);
if (nameUpdated) { if (nameUpdated) {
oldFirstLetters = nameFirstLetters(); oldFirstLetters = nameFirstLetters();
flags |= UpdateFlag::Name; flags |= UpdateFlag::Name;
@ -216,7 +214,7 @@ not_null<Ui::EmptyUserpic*> PeerData::ensureEmptyUserpic() const {
if (!_userpicEmpty) { if (!_userpicEmpty) {
_userpicEmpty = std::make_unique<Ui::EmptyUserpic>( _userpicEmpty = std::make_unique<Ui::EmptyUserpic>(
Data::PeerUserpicColor(id), Data::PeerUserpicColor(id),
name); name());
} }
return _userpicEmpty.get(); return _userpicEmpty.get();
} }
@ -564,14 +562,14 @@ void PeerData::fillNames() {
} }
}; };
appendToIndex(name); appendToIndex(name());
const auto appendTranslit = !toIndexList.isEmpty() const auto appendTranslit = !toIndexList.isEmpty()
&& cRussianLetters().match(toIndexList.front()).hasMatch(); && cRussianLetters().match(toIndexList.front()).hasMatch();
if (appendTranslit) { if (appendTranslit) {
appendToIndex(translitRusEng(toIndexList.front())); appendToIndex(translitRusEng(toIndexList.front()));
} }
if (const auto user = asUser()) { if (const auto user = asUser()) {
if (user->nameOrPhone != name) { if (user->nameOrPhone != name()) {
appendToIndex(user->nameOrPhone); appendToIndex(user->nameOrPhone);
} }
appendToIndex(user->username); appendToIndex(user->username);
@ -732,29 +730,33 @@ not_null<const PeerData*> PeerData::migrateToOrMe() const {
return this; return this;
} }
const Ui::Text::String &PeerData::topBarNameText() const { const QString &PeerData::topBarNameText() const {
if (const auto to = migrateTo()) { if (const auto to = migrateTo()) {
return to->topBarNameText(); return to->topBarNameText();
} else if (const auto user = asUser()) { } else if (const auto user = asUser()) {
if (!user->phoneText.isEmpty()) { if (!user->nameOrPhone.isEmpty()) {
return user->phoneText; return user->nameOrPhone;
} }
} }
return _nameText; return _name;
} }
const Ui::Text::String &PeerData::nameText() const { int PeerData::nameVersion() const {
return _nameVersion;
}
const QString &PeerData::name() const {
if (const auto to = migrateTo()) { if (const auto to = migrateTo()) {
return to->nameText(); return to->name();
} }
return _nameText; return _name;
} }
const QString &PeerData::shortName() const { const QString &PeerData::shortName() const {
if (const auto user = asUser()) { if (const auto user = asUser()) {
return user->firstName.isEmpty() ? user->lastName : user->firstName; return user->firstName.isEmpty() ? user->lastName : user->firstName;
} }
return name; return _name;
} }
QString PeerData::userName() const { QString PeerData::userName() const {
@ -1138,7 +1140,7 @@ std::optional<QString> RestrictionError(
: tr::lng_restricted_send_video_messages)( : tr::lng_restricted_send_video_messages)(
tr::now, tr::now,
lt_user, lt_user,
user->name); user->name());
} }
} }
return std::nullopt; return std::nullopt;

View file

@ -241,9 +241,10 @@ public:
return (_lastFullUpdate != 0); return (_lastFullUpdate != 0);
} }
[[nodiscard]] const Ui::Text::String &nameText() const; [[nodiscard]] int nameVersion() const;
[[nodiscard]] const QString &name() const;
[[nodiscard]] const QString &shortName() const; [[nodiscard]] const QString &shortName() const;
[[nodiscard]] const Ui::Text::String &topBarNameText() const; [[nodiscard]] const QString &topBarNameText() const;
[[nodiscard]] QString userName() const; [[nodiscard]] QString userName() const;
[[nodiscard]] const base::flat_set<QString> &nameWords() const { [[nodiscard]] const base::flat_set<QString> &nameWords() const {
@ -409,11 +410,8 @@ public:
[[nodiscard]] const QString &themeEmoji() const; [[nodiscard]] const QString &themeEmoji() const;
const PeerId id; const PeerId id;
QString name;
MTPinputPeer input = MTP_inputPeerEmpty(); MTPinputPeer input = MTP_inputPeerEmpty();
int nameVersion = 1;
protected: protected:
void updateNameDelayed( void updateNameDelayed(
const QString &newName, const QString &newName,
@ -440,7 +438,6 @@ private:
bool _userpicHasVideo = false; bool _userpicHasVideo = false;
mutable std::unique_ptr<Ui::EmptyUserpic> _userpicEmpty; mutable std::unique_ptr<Ui::EmptyUserpic> _userpicEmpty;
Ui::Text::String _nameText;
Data::PeerNotifySettings _notify; Data::PeerNotifySettings _notify;
@ -450,6 +447,9 @@ private:
crl::time _lastFullUpdate = 0; crl::time _lastFullUpdate = 0;
QString _name;
int _nameVersion = 1;
TimeId _ttlPeriod = 0; TimeId _ttlPeriod = 0;
Settings _settings = PeerSettings(PeerSetting::Unknown); Settings _settings = PeerSettings(PeerSetting::Unknown);

View file

@ -155,7 +155,7 @@ void SponsoredMessages::append(
const auto channel = peer->asChannel(); const auto channel = peer->asChannel();
return SponsoredFrom{ return SponsoredFrom{
.peer = peer, .peer = peer,
.title = peer->name, .title = peer->name(),
.isBroadcast = (channel && channel->isBroadcast()), .isBroadcast = (channel && channel->isBroadcast()),
.isMegagroup = (channel && channel->isMegagroup()), .isMegagroup = (channel && channel->isMegagroup()),
.isChannel = (channel != nullptr), .isChannel = (channel != nullptr),

View file

@ -165,13 +165,7 @@ void UserData::setBotInfo(const MTPBotInfo &info) {
} }
void UserData::setNameOrPhone(const QString &newNameOrPhone) { void UserData::setNameOrPhone(const QString &newNameOrPhone) {
if (nameOrPhone != newNameOrPhone) { nameOrPhone = newNameOrPhone;
nameOrPhone = newNameOrPhone;
phoneText.setText(
st::msgNameStyle,
nameOrPhone,
Ui::NameTextOptions());
}
} }
void UserData::madeAction(TimeId when) { void UserData::madeAction(TimeId when) {

View file

@ -123,7 +123,6 @@ public:
QString username; QString username;
[[nodiscard]] const QString &phone() const; [[nodiscard]] const QString &phone() const;
QString nameOrPhone; QString nameOrPhone;
Ui::Text::String phoneText;
TimeId onlineTill = 0; TimeId onlineTill = 0;
enum class ContactStatus : char { enum class ContactStatus : char {

View file

@ -16,6 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "mainwidget.h" #include "mainwidget.h"
#include "main/main_session.h" #include "main/main_session.h"
#include "main/main_session_settings.h" #include "main/main_session_settings.h"
#include "ui/text/text_options.h"
#include "history/history_item.h" #include "history/history_item.h"
#include "history/history.h" #include "history/history.h"
#include "styles/style_dialogs.h" // st::dialogsTextWidthMin #include "styles/style_dialogs.h" // st::dialogsTextWidthMin
@ -163,6 +164,18 @@ void Entry::notifyUnreadStateChange(const UnreadState &wasState) {
} }
} }
const Ui::Text::String &Entry::chatListNameText() const {
const auto version = chatListNameVersion();
if (_chatListNameVersion < version) {
_chatListNameVersion = version;
_chatListNameText.setText(
st::msgNameStyle,
chatListName(),
Ui::NameTextOptions());
}
return _chatListNameText;
}
void Entry::setChatListExistence(bool exists) { void Entry::setChatListExistence(bool exists) {
if (exists && _sortKeyInChatList) { if (exists && _sortKeyInChatList) {
owner().refreshChatListEntry(this); owner().refreshChatListEntry(this);

View file

@ -187,6 +187,8 @@ public:
return _timeId; return _timeId;
} }
[[nodiscard]] const Ui::Text::String &chatListNameText() const;
protected: protected:
void notifyUnreadStateChange(const UnreadState &wasState); void notifyUnreadStateChange(const UnreadState &wasState);
auto unreadStateChangeNotifier(bool required) { auto unreadStateChangeNotifier(bool required) {
@ -208,6 +210,8 @@ private:
void pinnedIndexChanged(FilterId filterId, int was, int now); void pinnedIndexChanged(FilterId filterId, int was, int now);
[[nodiscard]] uint64 computeSortPosition(FilterId filterId) const; [[nodiscard]] uint64 computeSortPosition(FilterId filterId) const;
[[nodiscard]] virtual int chatListNameVersion() const = 0;
void setChatListExistence(bool exists); void setChatListExistence(bool exists);
not_null<Row*> mainChatListLink(FilterId filterId) const; not_null<Row*> mainChatListLink(FilterId filterId) const;
Row *maybeMainChatListLink(FilterId filterId) const; Row *maybeMainChatListLink(FilterId filterId) const;
@ -217,6 +221,8 @@ private:
uint64 _sortKeyInChatList = 0; uint64 _sortKeyInChatList = 0;
uint64 _sortKeyByDate = 0; uint64 _sortKeyByDate = 0;
base::flat_map<FilterId, int> _pinnedIndex; base::flat_map<FilterId, int> _pinnedIndex;
mutable Ui::Text::String _chatListNameText;
mutable int _chatListNameVersion = 0;
TimeId _timeId = 0; TimeId _timeId = 0;
bool _isTopPromoted = false; bool _isTopPromoted = false;
const bool _isFolder = false; const bool _isFolder = false;

View file

@ -121,6 +121,7 @@ struct InnerWidget::PeerSearchResult {
PeerSearchResult(not_null<PeerData*> peer) : peer(peer) { PeerSearchResult(not_null<PeerData*> peer) : peer(peer) {
} }
not_null<PeerData*> peer; not_null<PeerData*> peer;
mutable Ui::Text::String name;
BasicRow row; BasicRow row;
}; };
@ -781,6 +782,13 @@ void InnerWidget::paintPeerSearchResult(
auto namewidth = fullWidth - nameleft - st::dialogsPadding.x(); auto namewidth = fullWidth - nameleft - st::dialogsPadding.x();
QRect rectForName(nameleft, st::dialogsPadding.y() + st::dialogsNameTop, namewidth, st::msgNameFont->height); QRect rectForName(nameleft, st::dialogsPadding.y() + st::dialogsNameTop, namewidth, st::msgNameFont->height);
if (result->name.isEmpty()) {
result->name.setText(
st::msgNameStyle,
peer->name(),
Ui::NameTextOptions());
}
// draw chat icon // draw chat icon
if (auto chatTypeIcon = Ui::ChatTypeIcon(peer, active, selected)) { if (auto chatTypeIcon = Ui::ChatTypeIcon(peer, active, selected)) {
chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth); chatTypeIcon->paint(p, rectForName.topLeft(), fullWidth);
@ -806,7 +814,7 @@ void InnerWidget::paintPeerSearchResult(
peer, peer,
p, p,
rectForName, rectForName,
peer->nameText().maxWidth(), result->name.maxWidth(),
fullWidth, fullWidth,
badgeStyle); badgeStyle);
rectForName.setWidth(rectForName.width() - badgeWidth); rectForName.setWidth(rectForName.width() - badgeWidth);
@ -833,7 +841,7 @@ void InnerWidget::paintPeerSearchResult(
} }
p.setPen(active ? st::dialogsTextFgActive : st::dialogsNameFg); p.setPen(active ? st::dialogsTextFgActive : st::dialogsNameFg);
peer->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width()); result->name.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
} }
void InnerWidget::paintSearchInChat(Painter &p) const { void InnerWidget::paintSearchInChat(Painter &p) const {
@ -2427,7 +2435,7 @@ void InnerWidget::refreshSearchInChatLabel() {
} else if (peer->isRepliesChat()) { } else if (peer->isRepliesChat()) {
return tr::lng_replies_messages(tr::now); return tr::lng_replies_messages(tr::now);
} }
return peer->name; return peer->name();
} }
return QString(); return QString();
}(); }();
@ -2437,7 +2445,7 @@ void InnerWidget::refreshSearchInChatLabel() {
dialog, dialog,
Ui::DialogTextOptions()); Ui::DialogTextOptions());
} }
const auto from = _searchFromPeer ? _searchFromPeer->name : QString(); const auto from = _searchFromPeer ? _searchFromPeer->name() : QString();
if (!from.isEmpty()) { if (!from.isEmpty()) {
const auto fromUserText = tr::lng_dlg_search_from( const auto fromUserText = tr::lng_dlg_search_from(
tr::now, tr::now,

View file

@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_folder.h" #include "data/data_folder.h"
#include "data/data_peer_values.h" #include "data/data_peer_values.h"
#include "history/history.h" #include "history/history.h"
#include "history/history_item.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "mainwidget.h" #include "mainwidget.h"
#include "styles/style_dialogs.h" #include "styles/style_dialogs.h"
@ -41,7 +42,7 @@ namespace {
list.size() - (throwAwayLastName ? 1 : 0) list.size() - (throwAwayLastName ? 1 : 0)
); );
const auto wrapName = [](not_null<History*> history) { const auto wrapName = [](not_null<History*> history) {
const auto name = history->peer->name; const auto name = history->peer->name();
return TextWithEntities{ return TextWithEntities{
.text = name, .text = name,
.entities = (history->unreadCount() > 0) .entities = (history->unreadCount() > 0)
@ -343,4 +344,15 @@ FakeRow::FakeRow(Key searchInChat, not_null<HistoryItem*> item)
, _item(item) { , _item(item) {
} }
const Ui::Text::String &FakeRow::name() const {
if (_name.isEmpty()) {
const auto from = _searchInChat
? _item->displayFrom()
: nullptr;
const auto peer = from ? from : _item->history()->peer.get();
_name.setText(st::msgNameStyle, peer->name(), Ui::NameTextOptions());
}
return _name;
}
} // namespace Dialogs } // namespace Dialogs

View file

@ -158,6 +158,7 @@ public:
[[nodiscard]] Ui::MessageView &itemView() const { [[nodiscard]] Ui::MessageView &itemView() const {
return _itemView; return _itemView;
} }
[[nodiscard]] const Ui::Text::String &name() const;
private: private:
friend class Ui::RowPainter; friend class Ui::RowPainter;
@ -165,6 +166,7 @@ private:
Key _searchInChat; Key _searchInChat;
not_null<HistoryItem*> _item; not_null<HistoryItem*> _item;
mutable Ui::MessageView _itemView; mutable Ui::MessageView _itemView;
mutable Ui::Text::String _name;
}; };

View file

@ -311,6 +311,7 @@ void paintRow(
VideoUserpic *videoUserpic, VideoUserpic *videoUserpic,
FilterId filterId, FilterId filterId,
PeerData *from, PeerData *from,
const Ui::Text::String &fromName,
const HiddenSenderInfo *hiddenSenderInfo, const HiddenSenderInfo *hiddenSenderInfo,
HistoryItem *item, HistoryItem *item,
const Data::Draft *draft, const Data::Draft *draft,
@ -590,7 +591,7 @@ void paintRow(
from, from,
p, p,
rectForName, rectForName,
from->nameText().maxWidth(), fromName.maxWidth(),
fullWidth, fullWidth,
badgeStyle); badgeStyle);
rectForName.setWidth(rectForName.width() - badgeWidth); rectForName.setWidth(rectForName.width() - badgeWidth);
@ -600,14 +601,14 @@ void paintRow(
: selected : selected
? st::dialogsNameFgOver ? st::dialogsNameFgOver
: st::dialogsNameFg); : st::dialogsNameFg);
from->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width()); fromName.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
} else if (hiddenSenderInfo) { } else if (hiddenSenderInfo) {
p.setPen(active p.setPen(active
? st::dialogsNameFgActive ? st::dialogsNameFgActive
: selected : selected
? st::dialogsNameFgOver ? st::dialogsNameFgOver
: st::dialogsNameFg); : st::dialogsNameFg);
hiddenSenderInfo->nameText.drawElided(p, rectForName.left(), rectForName.top(), rectForName.width()); hiddenSenderInfo->nameText().drawElided(p, rectForName.left(), rectForName.top(), rectForName.width());
} else { } else {
p.setPen(active p.setPen(active
? st::dialogsNameFgActive ? st::dialogsNameFgActive
@ -958,6 +959,7 @@ void RowPainter::paint(
videoUserpic, videoUserpic,
filterId, filterId,
from, from,
entry->chatListNameText(),
nullptr, nullptr,
item, item,
cloudDraft, cloudDraft,
@ -1092,6 +1094,7 @@ void RowPainter::paint(
nullptr, nullptr,
FilterId(), FilterId(),
from, from,
row->name(),
hiddenSenderInfo, hiddenSenderInfo,
item, item,
cloudDraft, cloudDraft,

View file

@ -18,10 +18,10 @@ class BasicRow;
namespace Dialogs::Ui { namespace Dialogs::Ui {
class VideoUserpic;
using namespace ::Ui; using namespace ::Ui;
class VideoUserpic;
const style::icon *ChatTypeIcon( const style::icon *ChatTypeIcon(
not_null<PeerData*> peer, not_null<PeerData*> peer,
bool active, bool active,

View file

@ -9,6 +9,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/widgets/checkbox.h" #include "ui/widgets/checkbox.h"
#include "ui/effects/ripple_animation.h" #include "ui/effects/ripple_animation.h"
#include "ui/text/text_options.h"
#include "lang/lang_keys.h" #include "lang/lang_keys.h"
#include "data/data_peer_values.h" #include "data/data_peer_values.h"
#include "data/data_channel.h" #include "data/data_channel.h"
@ -62,6 +63,7 @@ private:
const not_null<UserData*> _user; const not_null<UserData*> _user;
std::shared_ptr<Data::CloudImageView> _userpic; std::shared_ptr<Data::CloudImageView> _userpic;
Ui::Text::String _name;
QString _statusText; QString _statusText;
bool _statusOnline = false; bool _statusOnline = false;
@ -113,11 +115,14 @@ void UserCheckbox::paintEvent(QPaintEvent *e) {
auto userpicTop = 0; auto userpicTop = 0;
_user->paintUserpicLeft(p, _userpic, userpicLeft, userpicTop, width(), st::contactsPhotoSize); _user->paintUserpicLeft(p, _userpic, userpicLeft, userpicTop, width(), st::contactsPhotoSize);
if (_name.isEmpty()) {
_name.setText(st::msgNameStyle, _user->name(), Ui::NameTextOptions());
}
auto nameLeft = userpicLeft + st::contactsPhotoSize + st::contactsPadding.left(); auto nameLeft = userpicLeft + st::contactsPhotoSize + st::contactsPadding.left();
auto nameTop = userpicTop + st::contactsNameTop; auto nameTop = userpicTop + st::contactsNameTop;
auto nameWidth = width() - nameLeft - st::contactsPadding.right(); auto nameWidth = width() - nameLeft - st::contactsPadding.right();
p.setPen(st::contactsNameFg); p.setPen(st::contactsNameFg);
_user->nameText().drawLeftElided(p, nameLeft, nameTop, nameWidth, width()); _name.drawLeftElided(p, nameLeft, nameTop, nameWidth, width());
auto statusLeft = nameLeft; auto statusLeft = nameLeft;
auto statusTop = userpicTop + st::contactsStatusTop; auto statusTop = userpicTop + st::contactsStatusTop;

View file

@ -1429,7 +1429,7 @@ void InnerWidget::suggestRestrictParticipant(
: tr::lng_profile_sure_kick)( : tr::lng_profile_sure_kick)(
tr::now, tr::now,
lt_user, lt_user,
participant->name); participant->name());
auto weakBox = std::make_shared<QPointer<Ui::BoxContent>>(); auto weakBox = std::make_shared<QPointer<Ui::BoxContent>>();
const auto sure = crl::guard(this, [=] { const auto sure = crl::guard(this, [=] {
restrictParticipant( restrictParticipant(

View file

@ -456,7 +456,7 @@ auto GenerateParticipantString(
PeerId participantId) { PeerId participantId) {
// User name in "User name (@username)" format with entities. // User name in "User name (@username)" format with entities.
const auto peer = session->data().peer(participantId); const auto peer = session->data().peer(participantId);
auto name = TextWithEntities { peer->name }; auto name = TextWithEntities { peer->name()};
if (const auto user = peer->asUser()) { if (const auto user = peer->asUser()) {
auto entityData = QString::number(user->id.value) auto entityData = QString::number(user->id.value)
+ '.' + '.'
@ -706,7 +706,7 @@ void GenerateItems(
return callback(OwnedItem(delegate, item), sentDate); return callback(OwnedItem(delegate, item), sentDate);
}; };
const auto fromName = from->name; const auto fromName = from->name();
const auto fromLink = from->createOpenLink(); const auto fromLink = from->createOpenLink();
const auto fromLinkText = Ui::Text::Link(fromName, QString()); const auto fromLinkText = Ui::Text::Link(fromName, QString());
@ -1120,7 +1120,7 @@ void GenerateItems(
lt_from, lt_from,
fromLinkText, fromLinkText,
lt_chat, lt_chat,
Ui::Text::Link(now->name, QString()), Ui::Text::Link(now->name(), QString()),
Ui::Text::WithEntities); Ui::Text::WithEntities);
const auto chatLink = std::make_shared<LambdaClickHandler>([=] { const auto chatLink = std::make_shared<LambdaClickHandler>([=] {
Ui::showPeerHistory(now, ShowAtUnreadMsgId); Ui::showPeerHistory(now, ShowAtUnreadMsgId);
@ -1237,7 +1237,7 @@ void GenerateItems(
data.vparticipant()); data.vparticipant());
const auto participantPeerLink = participantPeer->createOpenLink(); const auto participantPeerLink = participantPeer->createOpenLink();
const auto participantPeerLinkText = Ui::Text::Link( const auto participantPeerLinkText = Ui::Text::Link(
participantPeer->name, participantPeer->name(),
QString()); QString());
const auto text = (broadcast const auto text = (broadcast
? tr::lng_admin_log_muted_participant_channel ? tr::lng_admin_log_muted_participant_channel
@ -1256,7 +1256,7 @@ void GenerateItems(
data.vparticipant()); data.vparticipant());
const auto participantPeerLink = participantPeer->createOpenLink(); const auto participantPeerLink = participantPeer->createOpenLink();
const auto participantPeerLinkText = Ui::Text::Link( const auto participantPeerLinkText = Ui::Text::Link(
participantPeer->name, participantPeer->name(),
QString()); QString());
const auto text = (broadcast const auto text = (broadcast
? tr::lng_admin_log_unmuted_participant_channel ? tr::lng_admin_log_unmuted_participant_channel
@ -1360,7 +1360,7 @@ void GenerateItems(
data.vparticipant()); data.vparticipant());
const auto participantPeerLink = participantPeer->createOpenLink(); const auto participantPeerLink = participantPeer->createOpenLink();
const auto participantPeerLinkText = Ui::Text::Link( const auto participantPeerLinkText = Ui::Text::Link(
participantPeer->name, participantPeer->name(),
QString()); QString());
const auto volume = data.vparticipant().match([&]( const auto volume = data.vparticipant().match([&](
const MTPDgroupCallParticipant &data) { const MTPDgroupCallParticipant &data) {
@ -1433,7 +1433,7 @@ void GenerateItems(
lt_link, lt_link,
linkText, linkText,
lt_user, lt_user,
Ui::Text::Link(user->name, QString()), Ui::Text::Link(user->name(), QString()),
Ui::Text::WithEntities), Ui::Text::WithEntities),
data.vinvite(), data.vinvite(),
user->createOpenLink()); user->createOpenLink());

View file

@ -72,7 +72,7 @@ History::History(not_null<Data::Session*> owner, PeerId peerId)
, cloudDraftTextCache(st::dialogsTextWidthMin) , cloudDraftTextCache(st::dialogsTextWidthMin)
, _delegateMixin(HistoryInner::DelegateMixin()) , _delegateMixin(HistoryInner::DelegateMixin())
, _mute(owner->notifySettings().isMuted(peer)) , _mute(owner->notifySettings().isMuted(peer))
, _chatListNameSortKey(owner->nameSortKey(peer->name)) , _chatListNameSortKey(owner->nameSortKey(peer->name()))
, _sendActionPainter(this) { , _sendActionPainter(this) {
if (const auto user = peer->asUser()) { if (const auto user = peer->asUser()) {
if (user->isBot()) { if (user->isBot()) {
@ -1823,6 +1823,10 @@ void History::setFolderPointer(Data::Folder *folder) {
session().changes().historyUpdated(this, UpdateFlag::Folder); session().changes().historyUpdated(this, UpdateFlag::Folder);
} }
int History::chatListNameVersion() const {
return peer->nameVersion();
}
void History::applyPinnedUpdate(const MTPDupdateDialogPinned &data) { void History::applyPinnedUpdate(const MTPDupdateDialogPinned &data) {
const auto folderId = data.vfolder_id().value_or_empty(); const auto folderId = data.vfolder_id().value_or_empty();
if (!folderKnown()) { if (!folderKnown()) {
@ -2034,7 +2038,7 @@ bool History::chatListMessageKnown() const {
} }
const QString &History::chatListName() const { const QString &History::chatListName() const {
return peer->name; return peer->name();
} }
const QString &History::chatListNameSortKey() const { const QString &History::chatListNameSortKey() const {
@ -2042,7 +2046,7 @@ const QString &History::chatListNameSortKey() const {
} }
void History::refreshChatListNameSortKey() { void History::refreshChatListNameSortKey() {
_chatListNameSortKey = owner().nameSortKey(peer->name); _chatListNameSortKey = owner().nameSortKey(peer->name());
} }
const base::flat_set<QString> &History::chatListNameWords() const { const base::flat_set<QString> &History::chatListNameWords() const {

View file

@ -597,6 +597,8 @@ private:
void setFolderPointer(Data::Folder *folder); void setFolderPointer(Data::Folder *folder);
int chatListNameVersion() const override;
const std::unique_ptr<HistoryMainElementDelegateMixin> _delegateMixin; const std::unique_ptr<HistoryMainElementDelegateMixin> _delegateMixin;
Flags _flags = 0; Flags _flags = 0;

View file

@ -2607,7 +2607,7 @@ TextForMimeData HistoryInner::getSelectedText() const {
not_null<HistoryItem*> item, not_null<HistoryItem*> item,
TextForMimeData &&unwrapped) { TextForMimeData &&unwrapped) {
const auto i = texts.emplace(item->position(), Part{ const auto i = texts.emplace(item->position(), Part{
.name = item->author()->name, .name = item->author()->name(),
.time = ItemDateTime(item).toString(timeFormat), .time = ItemDateTime(item).toString(timeFormat),
.unwrapped = std::move(unwrapped), .unwrapped = std::move(unwrapped),
}).first; }).first;

View file

@ -53,6 +53,7 @@ class PathShiftGradient;
} // namespace Ui } // namespace Ui
namespace Dialogs::Ui { namespace Dialogs::Ui {
using namespace ::Ui;
class VideoUserpic; class VideoUserpic;
} // namespace Dialogs::Ui } // namespace Dialogs::Ui

View file

@ -63,7 +63,7 @@ enum class Context : char;
class ElementDelegate; class ElementDelegate;
} // namespace HistoryView } // namespace HistoryView
struct HiddenSenderInfo; class HiddenSenderInfo;
class History; class History;
[[nodiscard]] MessageFlags FlagsFromMTP( [[nodiscard]] MessageFlags FlagsFromMTP(

View file

@ -102,7 +102,6 @@ HiddenSenderInfo::HiddenSenderInfo(const QString &name, bool external)
: name)) { : name)) {
Expects(!name.isEmpty()); Expects(!name.isEmpty());
nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
const auto parts = name.trimmed().split(' ', Qt::SkipEmptyParts); const auto parts = name.trimmed().split(' ', Qt::SkipEmptyParts);
firstName = parts[0]; firstName = parts[0];
for (const auto &part : parts.mid(1)) { for (const auto &part : parts.mid(1)) {
@ -113,6 +112,13 @@ HiddenSenderInfo::HiddenSenderInfo(const QString &name, bool external)
} }
} }
const Ui::Text::String &HiddenSenderInfo::nameText() const {
if (_nameText.isEmpty()) {
_nameText.setText(st::msgNameStyle, name, Ui::NameTextOptions());
}
return _nameText;
}
ClickHandlerPtr HiddenSenderInfo::ForwardClickHandler() { ClickHandlerPtr HiddenSenderInfo::ForwardClickHandler() {
static const auto hidden = std::make_shared<LambdaClickHandler>([]( static const auto hidden = std::make_shared<LambdaClickHandler>([](
ClickContext context) { ClickContext context) {
@ -153,7 +159,9 @@ void HistoryMessageForwarded::create(const HistoryMessageVia *via) const {
&& originalSender->isChannel() && originalSender->isChannel()
&& !originalSender->isMegagroup(); && !originalSender->isMegagroup();
const auto name = TextWithEntities{ const auto name = TextWithEntities{
.text = originalSender ? originalSender->name : hiddenSenderInfo->name .text = (originalSender
? originalSender->name()
: hiddenSenderInfo->name)
}; };
if (!originalAuthor.isEmpty()) { if (!originalAuthor.isEmpty()) {
phrase = tr::lng_forwarded_signed( phrase = tr::lng_forwarded_signed(
@ -342,13 +350,13 @@ QString HistoryMessageReply::replyToFromName(
if (const auto user = replyToVia ? peer->asUser() : nullptr) { if (const auto user = replyToVia ? peer->asUser() : nullptr) {
return user->firstName; return user->firstName;
} }
return peer->name; return peer->name();
} }
bool HistoryMessageReply::isNameUpdated( bool HistoryMessageReply::isNameUpdated(
not_null<HistoryMessage*> holder) const { not_null<HistoryMessage*> holder) const {
if (const auto from = replyToFrom(holder)) { if (const auto from = replyToFrom(holder)) {
if (from->nameVersion > replyToVersion) { if (replyToVersion < from->nameVersion()) {
updateName(holder); updateName(holder);
return true; return true;
} }
@ -361,9 +369,9 @@ void HistoryMessageReply::updateName(
if (const auto name = replyToFromName(holder); !name.isEmpty()) { if (const auto name = replyToFromName(holder); !name.isEmpty()) {
replyToName.setText(st::fwdTextStyle, name, Ui::NameTextOptions()); replyToName.setText(st::fwdTextStyle, name, Ui::NameTextOptions());
if (const auto from = replyToFrom(holder)) { if (const auto from = replyToFrom(holder)) {
replyToVersion = from->nameVersion; replyToVersion = from->nameVersion();
} else { } else {
replyToVersion = replyToMsg->author()->nameVersion; replyToVersion = replyToMsg->author()->nameVersion();
} }
bool hasPreview = replyToMsg->media() ? replyToMsg->media()->hasReplyPreview() : false; bool hasPreview = replyToMsg->media() ? replyToMsg->media()->hasReplyPreview() : false;
int32 previewSkip = hasPreview ? (st::msgReplyBarSize.height() + st::msgReplyBarSkip - st::msgReplyBarSize.width() - st::msgReplyBarPos.x()) : 0; int32 previewSkip = hasPreview ? (st::msgReplyBarSize.height() + st::msgReplyBarSkip - st::msgReplyBarSize.width() - st::msgReplyBarPos.x()) : 0;

View file

@ -70,19 +70,20 @@ struct HistoryMessageEdited : public RuntimeComponent<HistoryMessageEdited, Hist
TimeId date = 0; TimeId date = 0;
}; };
struct HiddenSenderInfo { class HiddenSenderInfo {
public:
HiddenSenderInfo(const QString &name, bool external); HiddenSenderInfo(const QString &name, bool external);
QString name; QString name;
QString firstName; QString firstName;
QString lastName; QString lastName;
PeerId colorPeerId = 0; PeerId colorPeerId = 0;
Ui::Text::String nameText;
Ui::EmptyUserpic emptyUserpic; Ui::EmptyUserpic emptyUserpic;
mutable Data::CloudImage customUserpic; mutable Data::CloudImage customUserpic;
[[nodiscard]] static ClickHandlerPtr ForwardClickHandler(); [[nodiscard]] static ClickHandlerPtr ForwardClickHandler();
[[nodiscard]] const Ui::Text::String &nameText() const;
[[nodiscard]] bool paintCustomUserpic( [[nodiscard]] bool paintCustomUserpic(
Painter &p, Painter &p,
int x, int x,
@ -96,6 +97,10 @@ struct HiddenSenderInfo {
inline bool operator!=(const HiddenSenderInfo &other) const { inline bool operator!=(const HiddenSenderInfo &other) const {
return !(*this == other); return !(*this == other);
} }
private:
mutable Ui::Text::String _nameText;
}; };
struct HistoryMessageForwarded : public RuntimeComponent<HistoryMessageForwarded, HistoryItem> { struct HistoryMessageForwarded : public RuntimeComponent<HistoryMessageForwarded, HistoryItem> {

View file

@ -19,7 +19,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
TextForMimeData WrapAsReply( TextForMimeData WrapAsReply(
TextForMimeData &&text, TextForMimeData &&text,
not_null<HistoryItem*> to) { not_null<HistoryItem*> to) {
const auto name = to->author()->name; const auto name = to->author()->name();
auto result = TextForMimeData(); auto result = TextForMimeData();
result.reserve( result.reserve(
tr::lng_in_reply_to(tr::now).size() tr::lng_in_reply_to(tr::now).size()

View file

@ -1022,8 +1022,6 @@ void HistoryMessage::createComponents(CreateConfig &&config) {
} else { } else {
_flags &= ~MessageFlag::HasReplyMarkup; _flags &= ~MessageFlag::HasReplyMarkup;
} }
const auto from = displayFrom();
_fromNameVersion = from ? from->nameVersion : 1;
} }
bool HistoryMessage::checkRepliesPts( bool HistoryMessage::checkRepliesPts(
@ -1914,7 +1912,7 @@ QString HistoryMessage::notificationHeader() const {
if (out() && isFromScheduled() && !_history->peer->isSelf()) { if (out() && isFromScheduled() && !_history->peer->isSelf()) {
return tr::lng_from_you(tr::now); return tr::lng_from_you(tr::now);
} else if (!_history->peer->isUser() && !isPost()) { } else if (!_history->peer->isUser() && !isPost()) {
return from()->name; return from()->name();
} }
return QString(); return QString();
} }

View file

@ -275,8 +275,6 @@ private:
[[nodiscard]] bool checkRepliesPts( [[nodiscard]] bool checkRepliesPts(
const HistoryMessageRepliesData &data) const; const HistoryMessageRepliesData &data) const;
mutable int _fromNameVersion = 0;
friend class HistoryView::Element; friend class HistoryView::Element;
friend class HistoryView::Message; friend class HistoryView::Message;

View file

@ -128,7 +128,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
lt_from, lt_from,
fromLinkText(), // Link 1. fromLinkText(), // Link 1.
lt_user, lt_user,
Ui::Text::Link(u->name, 2), // Link 2. Ui::Text::Link(u->name(), 2), // Link 2.
Ui::Text::WithEntities); Ui::Text::WithEntities);
} }
} else if (users.isEmpty()) { } else if (users.isEmpty()) {
@ -146,7 +146,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
auto user = history()->owner().user(users[i].v); auto user = history()->owner().user(users[i].v);
result.links.push_back(user->createOpenLink()); result.links.push_back(user->createOpenLink());
auto linkText = Ui::Text::Link(user->name, 2 + i); auto linkText = Ui::Text::Link(user->name(), 2 + i);
if (i == 0) { if (i == 0) {
result.text = linkText; result.text = linkText;
} else if (i + 1 == l) { } else if (i + 1 == l) {
@ -256,7 +256,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
lt_from, lt_from,
fromLinkText(), // Link 1. fromLinkText(), // Link 1.
lt_user, lt_user,
Ui::Text::Link(user->name, 2), // Link 2. Ui::Text::Link(user->name(), 2), // Link 2.
Ui::Text::WithEntities); Ui::Text::WithEntities);
} }
return result; return result;
@ -367,7 +367,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
result.text = tr::lng_action_secure_values_sent( result.text = tr::lng_action_secure_values_sent(
tr::now, tr::now,
lt_user, lt_user,
Ui::Text::Link(history()->peer->name, QString()), // Link 1. Ui::Text::Link(history()->peer->name(), QString()), // Link 1.
lt_documents, lt_documents,
{ .text = documents.join(", ") }, { .text = documents.join(", ") },
Ui::Text::WithEntities); Ui::Text::WithEntities);
@ -415,14 +415,14 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
lt_distance, lt_distance,
{ .text = distance }, { .text = distance },
lt_user, lt_user,
Ui::Text::Link(toPeer->name, QString()), // Link 1. Ui::Text::Link(toPeer->name(), QString()), // Link 1.
Ui::Text::WithEntities); Ui::Text::WithEntities);
} else if (toId == selfId) { } else if (toId == selfId) {
result.links.push_back(fromPeer->createOpenLink()); result.links.push_back(fromPeer->createOpenLink());
return tr::lng_action_proximity_reached_you( return tr::lng_action_proximity_reached_you(
tr::now, tr::now,
lt_from, lt_from,
Ui::Text::Link(fromPeer->name, QString()), // Link 1. Ui::Text::Link(fromPeer->name(), QString()), // Link 1.
lt_distance, lt_distance,
{ .text = distance }, { .text = distance },
Ui::Text::WithEntities); Ui::Text::WithEntities);
@ -432,11 +432,11 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
return tr::lng_action_proximity_reached( return tr::lng_action_proximity_reached(
tr::now, tr::now,
lt_from, lt_from,
Ui::Text::Link(fromPeer->name, 1), // Link 1. Ui::Text::Link(fromPeer->name(), 1), // Link 1.
lt_distance, lt_distance,
{ .text = distance }, { .text = distance },
lt_user, lt_user,
Ui::Text::Link(toPeer->name, 2), // Link 2. Ui::Text::Link(toPeer->name(), 2), // Link 2.
Ui::Text::WithEntities); Ui::Text::WithEntities);
} }
}(); }();
@ -629,7 +629,7 @@ void HistoryService::setMessageByAction(const MTPmessageAction &action) {
: tr::lng_action_gift_received)( : tr::lng_action_gift_received)(
tr::now, tr::now,
lt_user, lt_user,
Ui::Text::Link(peer->name, 1), // Link 1. Ui::Text::Link(peer->name(), 1), // Link 1.
lt_cost, lt_cost,
{ Ui::FillAmountAndCurrency(amount, currency) }, { Ui::FillAmountAndCurrency(amount, currency) },
Ui::Text::WithEntities); Ui::Text::WithEntities);
@ -854,7 +854,7 @@ HistoryService::PreparedText HistoryService::prepareInvitedToCallText(
lt_from, lt_from,
fromLinkText(), // Link 1. fromLinkText(), // Link 1.
lt_user, lt_user,
Ui::Text::Link(user->name, ++linkIndex), // Link N. Ui::Text::Link(user->name(), ++linkIndex), // Link N.
lt_chat, lt_chat,
chatText, chatText,
Ui::Text::WithEntities); Ui::Text::WithEntities);
@ -873,7 +873,7 @@ HistoryService::PreparedText HistoryService::prepareInvitedToCallText(
auto user = owner->user(users[i].v); auto user = owner->user(users[i].v);
result.links.push_back(user->createOpenLink()); result.links.push_back(user->createOpenLink());
auto linkText = Ui::Text::Link(user->name, ++linkIndex); auto linkText = Ui::Text::Link(user->name(), ++linkIndex);
if (i == 0) { if (i == 0) {
result.text = linkText; result.text = linkText;
} else if (i + 1 == l) { } else if (i + 1 == l) {
@ -1098,7 +1098,7 @@ HistoryService::PreparedText HistoryService::preparePaymentSentText() {
lt_amount, lt_amount,
{ .text = payment->amount }, { .text = payment->amount },
lt_user, lt_user,
{ .text = history()->peer->name }, { .text = history()->peer->name() },
Ui::Text::WithEntities); Ui::Text::WithEntities);
} }
} else { } else {
@ -1109,7 +1109,7 @@ HistoryService::PreparedText HistoryService::preparePaymentSentText() {
lt_amount, lt_amount,
{ .text = payment->amount }, { .text = payment->amount },
lt_user, lt_user,
{ .text = history()->peer->name }, { .text = history()->peer->name() },
lt_invoice, lt_invoice,
invoiceTitle, invoiceTitle,
Ui::Text::WithEntities); Ui::Text::WithEntities);
@ -1256,7 +1256,7 @@ ItemPreview HistoryService::toPreview(ToPreviewOptions options) const {
TextWithEntities HistoryService::inReplyText() const { TextWithEntities HistoryService::inReplyText() const {
auto result = HistoryService::notificationText(); auto result = HistoryService::notificationText();
const auto &name = author()->name; const auto &name = author()->name();
TextUtilities::Trim(result); TextUtilities::Trim(result);
if (result.text.startsWith(name)) { if (result.text.startsWith(name)) {
result = Ui::Text::Mid(result, name.size()); result = Ui::Text::Mid(result, name.size());
@ -1272,7 +1272,7 @@ std::unique_ptr<HistoryView::Element> HistoryService::createView(
} }
TextWithEntities HistoryService::fromLinkText() const { TextWithEntities HistoryService::fromLinkText() const {
return Ui::Text::Link(_from->name, 1); return Ui::Text::Link(_from->name(), 1);
} }
ClickHandlerPtr HistoryService::fromLink() const { ClickHandlerPtr HistoryService::fromLink() const {
@ -1628,7 +1628,7 @@ HistoryService::PreparedText GenerateJoinedText(
: tr::lng_action_add_you)( : tr::lng_action_add_you)(
tr::now, tr::now,
lt_from, lt_from,
Ui::Text::Link(inviter->name, QString()), Ui::Text::Link(inviter->name(), QString()),
Ui::Text::WithEntities); Ui::Text::WithEntities);
return result; return result;
} else if (history->peer->isMegagroup()) { } else if (history->peer->isMegagroup()) {
@ -1643,7 +1643,7 @@ HistoryService::PreparedText GenerateJoinedText(
result.text = tr::lng_action_user_joined( result.text = tr::lng_action_user_joined(
tr::now, tr::now,
lt_from, lt_from,
Ui::Text::Link(self->name, QString()), Ui::Text::Link(self->name(), QString()),
Ui::Text::WithEntities); Ui::Text::WithEntities);
return result; return result;
} }

View file

@ -1365,7 +1365,7 @@ void HistoryWidget::insertMention(UserData *user) {
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 {
@ -7522,9 +7522,9 @@ void HistoryWidget::updateForwardingTexts() {
if (!insertedPeers.contains(from)) { if (!insertedPeers.contains(from)) {
insertedPeers.emplace(from); insertedPeers.emplace(from);
names.push_back(from->shortName()); names.push_back(from->shortName());
fullname = from->name; fullname = from->name();
} }
version += from->nameVersion; version += from->nameVersion();
} else if (const auto info = item->hiddenSenderInfo()) { } else if (const auto info = item->hiddenSenderInfo()) {
if (!insertedNames.contains(info->name)) { if (!insertedNames.contains(info->name)) {
insertedNames.emplace(info->name); insertedNames.emplace(info->name);
@ -7588,7 +7588,7 @@ void HistoryWidget::checkForwardingInfo() {
if (keepNames) { if (keepNames) {
for (const auto item : _toForward.items) { for (const auto item : _toForward.items) {
if (const auto from = item->senderOriginal()) { if (const auto from = item->senderOriginal()) {
version += from->nameVersion; version += from->nameVersion();
} else if (const auto info = item->hiddenSenderInfo()) { } else if (const auto info = item->hiddenSenderInfo()) {
++version; ++version;
} else { } else {
@ -7617,9 +7617,11 @@ void HistoryWidget::updateReplyToName() {
}(); }();
_replyToName.setText( _replyToName.setText(
st::msgNameStyle, st::msgNameStyle,
from->name, from->name(),
Ui::NameTextOptions()); Ui::NameTextOptions());
_replyToNameVersion = (_replyEditMsg ? _replyEditMsg : _kbReplyTo)->author()->nameVersion; _replyToNameVersion = (_replyEditMsg
? _replyEditMsg
: _kbReplyTo)->author()->nameVersion();
} }
void HistoryWidget::updateField() { void HistoryWidget::updateField() {
@ -7639,7 +7641,10 @@ void HistoryWidget::drawField(Painter &p, const QRect &rect) {
auto hasForward = readyToForward(); auto hasForward = readyToForward();
auto drawMsgText = (_editMsgId || _replyToId) ? _replyEditMsg : _kbReplyTo; auto drawMsgText = (_editMsgId || _replyToId) ? _replyEditMsg : _kbReplyTo;
if (_editMsgId || _replyToId || (!hasForward && _kbReplyTo)) { if (_editMsgId || _replyToId || (!hasForward && _kbReplyTo)) {
if (!_editMsgId && drawMsgText && drawMsgText->author()->nameVersion > _replyToNameVersion) { if (!_editMsgId
&& drawMsgText
&& (_replyToNameVersion
< drawMsgText->author()->nameVersion())) {
updateReplyToName(); updateReplyToName();
} }
backy -= st::historyReplyHeight; backy -= st::historyReplyHeight;

View file

@ -709,12 +709,12 @@ void FieldHeader::paintEditOrReplyToMessage(Painter &p) {
const auto user = _shownMessage->displayFrom() const auto user = _shownMessage->displayFrom()
? _shownMessage->displayFrom() ? _shownMessage->displayFrom()
: _shownMessage->author().get(); : _shownMessage->author().get();
if (user->nameVersion > _shownMessageNameVersion) { if (_shownMessageNameVersion < user->nameVersion()) {
_shownMessageName.setText( _shownMessageName.setText(
st::msgNameStyle, st::msgNameStyle,
user->name, user->name(),
Ui::NameTextOptions()); Ui::NameTextOptions());
_shownMessageNameVersion = user->nameVersion; _shownMessageNameVersion = user->nameVersion();
} }
} }
@ -1476,7 +1476,7 @@ 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);

View file

@ -467,7 +467,7 @@ void ContactStatus::setupShareHandler(not_null<UserData*> user) {
Ui::Text::WithEntities( Ui::Text::WithEntities(
Ui::FormatPhone(user->session().user()->phone())), Ui::FormatPhone(user->session().user()->phone())),
lt_user, lt_user,
Ui::Text::Bold(user->name), Ui::Text::Bold(user->name()),
Ui::Text::WithEntities), Ui::Text::WithEntities),
.confirmed = share, .confirmed = share,
.confirmText = tr::lng_box_ok(), .confirmText = tr::lng_box_ok(),

View file

@ -1964,11 +1964,11 @@ TextForMimeData ListWidget::getSelectedText() const {
TextForMimeData &&unwrapped) { TextForMimeData &&unwrapped) {
auto time = ItemDateTime(item).toString(timeFormat); auto time = ItemDateTime(item).toString(timeFormat);
auto part = TextForMimeData(); auto part = TextForMimeData();
auto size = item->author()->name.size() auto size = item->author()->name().size()
+ time.size() + time.size()
+ unwrapped.expanded.size(); + unwrapped.expanded.size();
part.reserve(size); part.reserve(size);
part.append(item->author()->name).append(time); part.append(item->author()->name()).append(time);
part.append(std::move(unwrapped)); part.append(std::move(unwrapped));
texts.emplace_back(std::move(item), std::move(part)); texts.emplace_back(std::move(item), std::move(part));
fullSize += size; fullSize += size;

View file

@ -539,9 +539,10 @@ QSize Message::performCountOptimalSize() {
// They will be added in resizeGetHeight() anyway. // They will be added in resizeGetHeight() anyway.
if (displayFromName()) { if (displayFromName()) {
const auto from = item->displayFrom(); const auto from = item->displayFrom();
validateFromNameText(from);
const auto &name = from const auto &name = from
? from->nameText() ? _fromName
: item->hiddenSenderInfo()->nameText; : item->hiddenSenderInfo()->nameText();
auto namew = st::msgPadding.left() auto namew = st::msgPadding.left()
+ name.maxWidth() + name.maxWidth()
+ st::msgPadding.right(); + st::msgPadding.right();
@ -746,7 +747,7 @@ void Message::draw(Painter &p, const PaintContext &context) const {
if (bubble) { if (bubble) {
if (displayFromName() if (displayFromName()
&& item->displayFrom() && item->displayFrom()
&& item->displayFrom()->nameVersion > item->_fromNameVersion) { && (_fromNameVersion < item->displayFrom()->nameVersion())) {
fromNameUpdated(g.width()); fromNameUpdated(g.width());
} }
@ -1095,14 +1096,15 @@ void Message::paintFromName(
: item->isSponsored() : item->isSponsored()
? st->boxTextFgGood() ? st->boxTextFgGood()
: stm->msgServiceFg); : stm->msgServiceFg);
return &from->nameText(); validateFromNameText(from);
return &_fromName;
} else if (const auto info = item->hiddenSenderInfo()) { } else if (const auto info = item->hiddenSenderInfo()) {
p.setPen(!service p.setPen(!service
? FromNameFg(context, info->colorPeerId) ? FromNameFg(context, info->colorPeerId)
: item->isSponsored() : item->isSponsored()
? st->boxTextFgGood() ? st->boxTextFgGood()
: stm->msgServiceFg); : stm->msgServiceFg);
return &info->nameText; return &info->nameText();
} else { } else {
Unexpected("Corrupt sender information in message."); Unexpected("Corrupt sender information in message.");
} }
@ -1698,9 +1700,10 @@ bool Message::getStateFromName(
const auto from = item->displayFrom(); const auto from = item->displayFrom();
const auto nameText = [&]() -> const Ui::Text::String * { const auto nameText = [&]() -> const Ui::Text::String * {
if (from) { if (from) {
return &from->nameText(); validateFromNameText(from);
return &_fromName;
} else if (const auto info = item->hiddenSenderInfo()) { } else if (const auto info = item->hiddenSenderInfo()) {
return &info->nameText; return &info->nameText();
} else { } else {
Unexpected("Corrupt forwarded information in message."); Unexpected("Corrupt forwarded information in message.");
} }
@ -2203,6 +2206,17 @@ void Message::refreshReactions() {
} }
} }
void Message::validateFromNameText(PeerData *from) const {
const auto version = from ? from->nameVersion() : 0;
if (_fromNameVersion < version) {
_fromNameVersion = version;
_fromName.setText(
st::msgNameStyle,
from->name(),
Ui::NameTextOptions());
}
}
void Message::itemDataChanged() { void Message::itemDataChanged() {
const auto wasInfo = _bottomInfo.currentSize(); const auto wasInfo = _bottomInfo.currentSize();
const auto wasReactions = _reactions const auto wasReactions = _reactions
@ -2738,14 +2752,14 @@ void Message::fromNameUpdated(int width) const {
width -= st::msgPadding.right() + replyWidth; width -= st::msgPadding.right() + replyWidth;
} }
const auto from = item->displayFrom(); const auto from = item->displayFrom();
item->_fromNameVersion = from ? from->nameVersion : 1; validateFromNameText(from);
if (const auto via = item->Get<HistoryMessageVia>()) { if (const auto via = item->Get<HistoryMessageVia>()) {
if (!displayForwardedFrom()) { if (!displayForwardedFrom()) {
const auto nameText = [&]() -> const Ui::Text::String * { const auto nameText = [&]() -> const Ui::Text::String * {
if (from) { if (from) {
return &from->nameText(); return &_fromName;
} else if (const auto info = item->hiddenSenderInfo()) { } else if (const auto info = item->hiddenSenderInfo()) {
return &info->nameText; return &info->nameText();
} else { } else {
Unexpected("Corrupted forwarded information in message."); Unexpected("Corrupted forwarded information in message.");
} }

View file

@ -243,6 +243,7 @@ private:
void refreshRightBadge(); void refreshRightBadge();
void refreshReactions(); void refreshReactions();
void validateFromNameText(PeerData *from) const;
mutable ClickHandlerPtr _rightActionLink; mutable ClickHandlerPtr _rightActionLink;
mutable ClickHandlerPtr _fastReplyLink; mutable ClickHandlerPtr _fastReplyLink;
@ -250,7 +251,9 @@ private:
std::unique_ptr<Reactions::InlineList> _reactions; std::unique_ptr<Reactions::InlineList> _reactions;
mutable std::unique_ptr<CommentsButton> _comments; mutable std::unique_ptr<CommentsButton> _comments;
mutable Ui::Text::String _fromName;
Ui::Text::String _rightBadge; Ui::Text::String _rightBadge;
mutable int _fromNameVersion = 0;
int _bubbleWidthLimit = 0; int _bubbleWidthLimit = 0;
BottomInfo _bottomInfo; BottomInfo _bottomInfo;

View file

@ -105,7 +105,9 @@ rpl::producer<Ui::MessageBarContent> RootViewContent(
const auto sender = (item && item->discussionPostOriginalSender()) const auto sender = (item && item->discussionPostOriginalSender())
? item->discussionPostOriginalSender() ? item->discussionPostOriginalSender()
: history->peer.get(); : history->peer.get();
content.title = sender->name.isEmpty() ? "Message" : sender->name; content.title = sender->name().isEmpty()
? "Message"
: sender->name();
return std::move(content); return std::move(content);
}); });
} }

View file

@ -160,7 +160,7 @@ rpl::producer<Ui::RequestsBarContent> RequestsBarContentByPeer(
if (count == 1 && !state->users.empty()) { if (count == 1 && !state->users.empty()) {
const auto user = state->users.front(); const auto user = state->users.front();
state->current.nameShort = user->shortName(); state->current.nameShort = user->shortName();
state->current.nameFull = user->name; state->current.nameFull = user->name();
} else { } else {
state->current.nameShort state->current.nameShort
= state->current.nameFull = state->current.nameFull

View file

@ -519,7 +519,13 @@ void TopBarWidget::paintTopBar(Painter &p) {
} }
} else if (const auto history = _activeChat.key.history()) { } else if (const auto history = _activeChat.key.history()) {
const auto peer = history->peer; const auto peer = history->peer;
const auto &text = peer->topBarNameText(); if (_titleNameVersion < peer->nameVersion()) {
_titleNameVersion = peer->nameVersion();
_title.setText(
st::msgNameStyle,
peer->topBarNameText(),
Ui::NameTextOptions());
}
const auto badgeStyle = Ui::PeerBadgeStyle{ const auto badgeStyle = Ui::PeerBadgeStyle{
&st::dialogsVerifiedIcon, &st::dialogsVerifiedIcon,
&st::dialogsPremiumIcon, &st::dialogsPremiumIcon,
@ -533,13 +539,13 @@ void TopBarWidget::paintTopBar(Painter &p) {
nametop, nametop,
availableWidth, availableWidth,
st::msgNameStyle.font->height), st::msgNameStyle.font->height),
text.maxWidth(), _title.maxWidth(),
width(), width(),
badgeStyle); badgeStyle);
const auto namewidth = availableWidth - badgeWidth; const auto namewidth = availableWidth - badgeWidth;
p.setPen(st::dialogsNameFg); p.setPen(st::dialogsNameFg);
peer->topBarNameText().drawElided( _title.drawElided(
p, p,
nameleft, nameleft,
nametop, nametop,
@ -692,6 +698,7 @@ void TopBarWidget::setActiveChat(
update(); update();
if (peerChanged) { if (peerChanged) {
_titleNameVersion = 0;
_emojiInteractionSeen = nullptr; _emojiInteractionSeen = nullptr;
_activeChatLifetime.destroy(); _activeChatLifetime.destroy();
if (const auto history = _activeChat.key.history()) { if (const auto history = _activeChat.key.history()) {

View file

@ -159,6 +159,9 @@ private:
std::unique_ptr<EmojiInteractionSeenAnimation> _emojiInteractionSeen; std::unique_ptr<EmojiInteractionSeenAnimation> _emojiInteractionSeen;
rpl::lifetime _activeChatLifetime; rpl::lifetime _activeChatLifetime;
Ui::Text::String _title;
int _titleNameVersion = 0;
int _selectedCount = 0; int _selectedCount = 0;
bool _canDelete = false; bool _canDelete = false;
bool _canForward = false; bool _canForward = false;

View file

@ -78,7 +78,7 @@ rpl::producer<TextWithEntities> NameValue(not_null<PeerData*> peer) {
peer, peer,
UpdateFlag::Name UpdateFlag::Name
) | rpl::map([=] { ) | rpl::map([=] {
return peer->name; return peer->name();
}) | Ui::Text::ToWithEntities(); }) | Ui::Text::ToWithEntities();
} }

View file

@ -744,7 +744,7 @@ void AttachWebView::confirmOpen(
.text = tr::lng_allow_bot_webview( .text = tr::lng_allow_bot_webview(
tr::now, tr::now,
lt_bot_name, lt_bot_name,
Ui::Text::Bold(_bot->name), Ui::Text::Bold(_bot->name()),
Ui::Text::RichLangValue), Ui::Text::RichLangValue),
.confirmed = callback, .confirmed = callback,
.confirmText = tr::lng_box_ok(), .confirmText = tr::lng_box_ok(),
@ -828,7 +828,7 @@ void AttachWebView::show(
&AttachWebViewBot::user); &AttachWebViewBot::user);
const auto name = (attached != end(_attachBots)) const auto name = (attached != end(_attachBots))
? attached->name ? attached->name
: _bot->name; : _bot->name();
const auto hasSettings = (attached != end(_attachBots)) const auto hasSettings = (attached != end(_attachBots))
&& !attached->inactive && !attached->inactive
&& attached->hasSettings; && attached->hasSettings;

View file

@ -1015,7 +1015,7 @@ void Widget::handleSongChange() {
if (document->isVoiceMessage() || document->isVideoMessage()) { if (document->isVoiceMessage() || document->isVideoMessage()) {
if (const auto item = document->owner().message(current.contextId())) { if (const auto item = document->owner().message(current.contextId())) {
const auto name = (!item->out() || item->isPost()) const auto name = (!item->out() || item->isPost())
? item->fromOriginal()->name ? item->fromOriginal()->name()
: tr::lng_from_you(tr::now); : tr::lng_from_you(tr::now);
const auto date = [item] { const auto date = [item] {
const auto parsed = ItemDateTime(item); const auto parsed = ItemDateTime(item);

View file

@ -2233,12 +2233,14 @@ void OverlayWidget::refreshFromLabel() {
_fromName = info->name; _fromName = info->name;
} else { } else {
Assert(_from != nullptr); Assert(_from != nullptr);
const auto from = _from->migrateTo() ? _from->migrateTo() : _from; const auto from = _from->migrateTo()
_fromName = from->name; ? _from->migrateTo()
: _from;
_fromName = from->name();
} }
} else { } else {
_from = _user; _from = _user;
_fromName = _user ? _user->name : QString(); _fromName = _user ? _user->name() : QString();
} }
} }

View file

@ -663,8 +663,8 @@ void Voice::paint(Painter &p, const QRect &clip, TextSelection selection, const
} }
} }
const auto showPause = updateStatusText(); const auto showPause = updateStatusText();
const auto nameVersion = parent()->fromOriginal()->nameVersion; const auto nameVersion = parent()->fromOriginal()->nameVersion();
if (nameVersion > _nameVersion) { if (_nameVersion < nameVersion) {
updateName(); updateName();
} }
const auto radial = isRadialAnimation(); const auto radial = isRadialAnimation();
@ -879,18 +879,31 @@ const style::RoundCheckbox &Voice::checkboxStyle() const {
} }
void Voice::updateName() { void Voice::updateName() {
auto version = 0;
if (const auto forwarded = parent()->Get<HistoryMessageForwarded>()) { if (const auto forwarded = parent()->Get<HistoryMessageForwarded>()) {
if (parent()->fromOriginal()->isChannel()) { if (parent()->fromOriginal()->isChannel()) {
_name.setText(st::semiboldTextStyle, tr::lng_forwarded_channel(tr::now, lt_channel, parent()->fromOriginal()->name), Ui::NameTextOptions()); _name.setText(
st::semiboldTextStyle,
tr::lng_forwarded_channel(
tr::now,
lt_channel,
parent()->fromOriginal()->name()),
Ui::NameTextOptions());
} else { } else {
_name.setText(st::semiboldTextStyle, tr::lng_forwarded(tr::now, lt_user, parent()->fromOriginal()->name), Ui::NameTextOptions()); _name.setText(
st::semiboldTextStyle,
tr::lng_forwarded(
tr::now,
lt_user,
parent()->fromOriginal()->name()),
Ui::NameTextOptions());
} }
} else { } else {
_name.setText(st::semiboldTextStyle, parent()->from()->name, Ui::NameTextOptions()); _name.setText(
st::semiboldTextStyle,
parent()->from()->name(),
Ui::NameTextOptions());
} }
version = parent()->fromOriginal()->nameVersion; _nameVersion = parent()->fromOriginal()->nameVersion();
_nameVersion = version;
} }
int Voice::duration() const { int Voice::duration() const {

View file

@ -85,7 +85,7 @@ not_null<Ui::RpWidget*> PanelForm::setupContent() {
inner, inner,
object_ptr<Ui::FlatLabel>( object_ptr<Ui::FlatLabel>(
inner, inner,
tr::lng_passport_request1(tr::now, lt_bot, bot->name), tr::lng_passport_request1(tr::now, lt_bot, bot->name()),
st::passportPasswordLabelBold)), st::passportPasswordLabelBold)),
st::passportFormAbout1Padding)->entity(); st::passportFormAbout1Padding)->entity();
@ -154,7 +154,7 @@ not_null<Ui::RpWidget*> PanelForm::setupContent() {
lt_policy, lt_policy,
tr::lng_passport_policy( tr::lng_passport_policy(
lt_bot, lt_bot,
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(),

View file

@ -38,7 +38,7 @@ PanelAskPassword::PanelAskPassword(
tr::lng_passport_request1( tr::lng_passport_request1(
tr::now, tr::now,
lt_bot, lt_bot,
_controller->bot()->name), _controller->bot()->name()),
st::passportPasswordLabelBold) st::passportPasswordLabelBold)
, _about2( , _about2(
this, this,
@ -179,7 +179,7 @@ void PanelNoPassword::setupContent() {
tr::lng_passport_request1( tr::lng_passport_request1(
tr::now, tr::now,
lt_bot, lt_bot,
_controller->bot()->name), _controller->bot()->name()),
st::passportPasswordLabelBold)), st::passportPasswordLabelBold)),
st::passportPasswordAbout1Padding)->entity(); st::passportPasswordAbout1Padding)->entity();

View file

@ -316,7 +316,7 @@ void CheckoutProcess::handleFormUpdate(const FormUpdate &update) {
}, [&](const BotTrustRequired &data) { }, [&](const BotTrustRequired &data) {
UnregisterPaymentStart(this); UnregisterPaymentStart(this);
_submitState = SubmitState::Validated; _submitState = SubmitState::Validated;
_panel->showWarning(data.bot->name, data.provider->name); _panel->showWarning(data.bot->name(), data.provider->name());
if (const auto box = _enterPasswordBox.data()) { if (const auto box = _enterPasswordBox.data()) {
box->closeBox(); box->closeBox();
} }

View file

@ -418,13 +418,13 @@ 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) {
if (const auto bot = _session->data().userLoaded(providerId)) { if (const auto bot = _session->data().userLoaded(providerId)) {
_invoice.provider = bot->name; _invoice.provider = bot->name();
} }
} }
} }
@ -456,7 +456,7 @@ void Form::processDetails(const MTPDpayments_paymentReceipt &data) {
} }
if (_details.botId) { if (_details.botId) {
if (const auto bot = _session->data().userLoaded(_details.botId)) { if (const auto bot = _session->data().userLoaded(_details.botId)) {
_invoice.cover.seller = bot->name; _invoice.cover.seller = bot->name();
} }
} }
} }

View file

@ -99,7 +99,7 @@ void PeerListWidget::paintItem(Painter &p, int x, int y, Item *item, bool select
if (item->name.isEmpty()) { if (item->name.isEmpty()) {
item->name.setText( item->name.setText(
st::msgNameStyle, st::msgNameStyle,
item->peer->name, item->peer->name(),
Ui::NameTextOptions()); Ui::NameTextOptions());
} }
int nameLeft = x + _st.namePosition.x(); int nameLeft = x + _st.namePosition.x();

View file

@ -599,11 +599,11 @@ void SetupAccountsWrap(
const auto user = session->user(); const auto user = session->user();
auto text = rpl::single( auto text = rpl::single(
user->name user->name()
) | rpl::then(session->changes().realtimeNameUpdates( ) | rpl::then(session->changes().realtimeNameUpdates(
user user
) | rpl::map([=] { ) | rpl::map([=] {
return user->name; return user->name();
})); }));
auto result = object_ptr<Ui::SettingsButton>( auto result = object_ptr<Ui::SettingsButton>(
parent, parent,

View file

@ -10,6 +10,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "settings/settings_common.h" #include "settings/settings_common.h"
namespace Dialogs::Ui { namespace Dialogs::Ui {
using namespace ::Ui;
struct UnreadBadgeStyle; struct UnreadBadgeStyle;
} // namespace Dialogs::Ui } // namespace Dialogs::Ui

View file

@ -770,7 +770,7 @@ QPointer<Ui::RpWidget> Premium::createPinnedToTop(
lt_count, lt_count,
rpl::single(float64(gift.months)), rpl::single(float64(gift.months)),
lt_user, lt_user,
rpl::single(Ui::Text::Bold(peer->name)), rpl::single(Ui::Text::Bold(peer->name())),
Ui::Text::RichLangValue); Ui::Text::RichLangValue);
} }
} }

View file

@ -218,7 +218,7 @@ struct ForwardedTooltip {
const auto phrase = tr::lng_forwarded( const auto phrase = tr::lng_forwarded(
tr::now, tr::now,
lt_user, lt_user,
view->history()->session().user()->name); view->history()->session().user()->name());
const auto kReplacementPosition = QChar(0x0001); const auto kReplacementPosition = QChar(0x0001);
const auto possiblePosition = tr::lng_forwarded( const auto possiblePosition = tr::lng_forwarded(
tr::now, tr::now,

View file

@ -128,7 +128,7 @@ uint32 peerSize(not_null<PeerData*> peer) {
+ sizeof(qint32) // contact + sizeof(qint32) // contact
+ sizeof(qint32); // botInfoVersion + sizeof(qint32); // botInfoVersion
} else if (const auto chat = peer->asChat()) { } else if (const auto chat = peer->asChat()) {
result += stringSize(chat->name) result += stringSize(chat->name())
+ sizeof(qint32) // count + sizeof(qint32) // count
+ sizeof(qint32) // date + sizeof(qint32) // date
+ sizeof(qint32) // version + sizeof(qint32) // version
@ -137,7 +137,7 @@ uint32 peerSize(not_null<PeerData*> peer) {
+ sizeof(quint32) // flags + sizeof(quint32) // flags
+ stringSize(chat->inviteLink()); + stringSize(chat->inviteLink());
} else if (const auto channel = peer->asChannel()) { } else if (const auto channel = peer->asChannel()) {
result += stringSize(channel->name) result += stringSize(channel->name())
+ sizeof(quint64) // access + sizeof(quint64) // access
+ sizeof(qint32) // date + sizeof(qint32) // date
+ sizeof(qint32) // version + sizeof(qint32) // version
@ -175,7 +175,7 @@ void writePeer(QDataStream &stream, not_null<PeerData*> peer) {
auto field1 = qint32(uint32(chat->creator.bare & 0xFFFFFFFFULL)); auto field1 = qint32(uint32(chat->creator.bare & 0xFFFFFFFFULL));
auto field2 = qint32(uint32(chat->creator.bare >> 32) << 8); auto field2 = qint32(uint32(chat->creator.bare >> 32) << 8);
stream stream
<< chat->name << chat->name()
<< qint32(chat->count) << qint32(chat->count)
<< qint32(chat->date) << qint32(chat->date)
<< qint32(chat->version()) << qint32(chat->version())
@ -185,7 +185,7 @@ void writePeer(QDataStream &stream, not_null<PeerData*> peer) {
<< chat->inviteLink(); << chat->inviteLink();
} else if (const auto channel = peer->asChannel()) { } else if (const auto channel = peer->asChannel()) {
stream stream
<< channel->name << channel->name()
<< quint64(channel->access) << quint64(channel->access)
<< qint32(channel->date) << qint32(channel->date)
<< qint32(0) // legacy - version << qint32(0) // legacy - version

View file

@ -874,7 +874,7 @@ QString Manager::addTargetAccountName(
? (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;
} }
@ -994,10 +994,10 @@ void NativeManager::doShowNotification(NotificationFields &&fields) {
? AppName.utf16() ? AppName.utf16()
: (scheduled && peer->isSelf()) : (scheduled && peer->isSelf())
? tr::lng_notification_reminder(tr::now) ? tr::lng_notification_reminder(tr::now)
: peer->name; : peer->name();
const auto fullTitle = addTargetAccountName(title, &peer->session()); const auto fullTitle = addTargetAccountName(title, &peer->session());
const auto subtitle = reactionFrom const auto subtitle = reactionFrom
? (reactionFrom != peer ? reactionFrom->name : QString()) ? (reactionFrom != peer ? reactionFrom->name() : QString())
: options.hideNameAndPhoto : options.hideNameAndPhoto
? QString() ? QString()
: item->notificationHeader(); : item->notificationHeader();

View file

@ -86,7 +86,7 @@ Manager::QueuedNotification::QueuedNotification(NotificationFields &&fields)
, author(!fields.reactionFrom , author(!fields.reactionFrom
? fields.item->notificationHeader() ? fields.item->notificationHeader()
: (fields.reactionFrom != peer) : (fields.reactionFrom != peer)
? fields.reactionFrom->name ? fields.reactionFrom->name()
: QString()) : QString())
, item((fields.forwardedCount < 2) ? fields.item.get() : nullptr) , item((fields.forwardedCount < 2) ? fields.item.get() : nullptr)
, forwardedCount(fields.forwardedCount) , forwardedCount(fields.forwardedCount)
@ -922,7 +922,7 @@ void Notification::updateNotifyDisplay() {
? qsl("Telegram Desktop") ? qsl("Telegram Desktop")
: reminder : reminder
? tr::lng_notification_reminder(tr::now) ? tr::lng_notification_reminder(tr::now)
: _history->peer->nameText().toString(); : _history->peer->name();
const auto fullTitle = manager()->addTargetAccountName( const auto fullTitle = manager()->addTargetAccountName(
title, title,
&_history->session()); &_history->session());

View file

@ -22,6 +22,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "ui/wrap/vertical_layout_reorder.h" #include "ui/wrap/vertical_layout_reorder.h"
#include "ui/text/format_values.h" // Ui::FormatPhone #include "ui/text/format_values.h" // Ui::FormatPhone
#include "ui/text/text_utilities.h" #include "ui/text/text_utilities.h"
#include "ui/text/text_options.h"
#include "ui/special_buttons.h" #include "ui/special_buttons.h"
#include "ui/empty_userpic.h" #include "ui/empty_userpic.h"
#include "dialogs/ui/dialogs_layout.h" #include "dialogs/ui/dialogs_layout.h"
@ -765,7 +766,14 @@ void MainMenu::paintEvent(QPaintEvent *e) {
p.setFont(st::semiboldFont); p.setFont(st::semiboldFont);
p.setPen(st::windowBoldFg); p.setPen(st::windowBoldFg);
_controller->session().user()->nameText().drawLeftElided( const auto user = _controller->session().user();
if (_nameVersion < user->nameVersion()) {
_name.setText(
st::msgNameStyle,
user->name(),
Ui::NameTextOptions());
}
_name.drawLeftElided(
p, p,
st::mainMenuCoverNameLeft, st::mainMenuCoverNameLeft,
st::mainMenuCoverNameTop, st::mainMenuCoverNameTop,

View file

@ -66,6 +66,8 @@ private:
const not_null<SessionController*> _controller; const not_null<SessionController*> _controller;
object_ptr<Ui::UserpicButton> _userpicButton; object_ptr<Ui::UserpicButton> _userpicButton;
Ui::Text::String _name;
int _nameVersion = 0;
object_ptr<ToggleAccountsButton> _toggleAccounts; object_ptr<ToggleAccountsButton> _toggleAccounts;
object_ptr<ResetScaleButton> _resetScaleButton = { nullptr }; object_ptr<ResetScaleButton> _resetScaleButton = { nullptr };
object_ptr<Ui::ScrollArea> _scroll; object_ptr<Ui::ScrollArea> _scroll;

View file

@ -950,7 +950,7 @@ void PeerMenuDeleteContact(
const auto text = tr::lng_sure_delete_contact( const auto text = tr::lng_sure_delete_contact(
tr::now, tr::now,
lt_contact, lt_contact,
user->name); user->name());
const auto deleteSure = [=](Fn<void()> &&close) { const auto deleteSure = [=](Fn<void()> &&close) {
close(); close();
user->session().api().request(MTPcontacts_DeleteContacts( user->session().api().request(MTPcontacts_DeleteContacts(
@ -992,8 +992,8 @@ void PeerMenuShareContactBox(
return; return;
} }
auto recipient = peer->isUser() auto recipient = peer->isUser()
? peer->name ? peer->name()
: '\xAB' + peer->name + '\xBB'; : '\xAB' + peer->name() + '\xBB';
navigation->parentController()->show( navigation->parentController()->show(
Ui::MakeConfirmBox({ Ui::MakeConfirmBox({
.text = tr::lng_forward_share_contact( .text = tr::lng_forward_share_contact(
@ -1084,7 +1084,7 @@ void PeerMenuBlockUserBox(
: v::get<bool>(suggestReport); : v::get<bool>(suggestReport);
const auto user = peer->asUser(); const auto user = peer->asUser();
const auto name = user ? user->shortName() : peer->name; const auto name = user ? user->shortName() : peer->name();
if (user) { if (user) {
box->addRow(object_ptr<Ui::FlatLabel>( box->addRow(object_ptr<Ui::FlatLabel>(
box, box,
@ -1130,7 +1130,7 @@ void PeerMenuBlockUserBox(
tr::lng_delete_all_from_user( tr::lng_delete_all_from_user(
tr::now, tr::now,
lt_user, lt_user,
Ui::Text::Bold(peer->name), Ui::Text::Bold(peer->name()),
Ui::Text::WithEntities), Ui::Text::WithEntities),
true, true,
st::defaultBoxCheckbox)) st::defaultBoxCheckbox))