2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-02 15:35:51 +00:00

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

@@ -15,6 +15,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL
#include "data/data_folder.h"
#include "data/data_peer_values.h"
#include "history/history.h"
#include "history/history_item.h"
#include "lang/lang_keys.h"
#include "mainwidget.h"
#include "styles/style_dialogs.h"
@@ -41,7 +42,7 @@ namespace {
list.size() - (throwAwayLastName ? 1 : 0)
);
const auto wrapName = [](not_null<History*> history) {
const auto name = history->peer->name;
const auto name = history->peer->name();
return TextWithEntities{
.text = name,
.entities = (history->unreadCount() > 0)
@@ -343,4 +344,15 @@ FakeRow::FakeRow(Key searchInChat, not_null<HistoryItem*> 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