Use name instead of "My Story" if it doesn't fit.

This commit is contained in:
John Preston 2023-08-17 12:31:57 +02:00
parent 5dcca4482a
commit 4b0c4eee30
2 changed files with 9 additions and 4 deletions

View File

@ -347,9 +347,7 @@ Content State::next() {
}
result.elements.push_back({
.id = uint64(user->id.value),
.name = (user->isSelf()
? tr::lng_stories_my_name(tr::now)
: user->shortName()),
.name = user->shortName(),
.thumbnail = std::move(userpic),
.count = info.count,
.unreadCount = info.unreadCount,

View File

@ -671,7 +671,14 @@ void List::validateName(not_null<Item*> item) {
const auto &full = _st.full;
const auto &font = full.nameStyle.font;
const auto available = AvailableNameWidth(_st);
const auto text = Ui::Text::String(full.nameStyle, element.name);
const auto my = element.skipSmall
? tr::lng_stories_my_name(tr::now)
: QString();
const auto use = (my.isEmpty()
|| full.nameStyle.font->width(my) > available)
? element.name
: my;
const auto text = Ui::Text::String(full.nameStyle, use);
const auto ratio = style::DevicePixelRatio();
item->nameCacheColor = color->c;
item->nameCache = QImage(