Fix chats list forwarded messages sender.

This commit is contained in:
John Preston 2021-11-23 15:40:15 +04:00
parent 9bc9547b1c
commit a7c9a1ab34
1 changed files with 18 additions and 11 deletions

View File

@ -974,22 +974,29 @@ ItemPreview HistoryItem::toPreview(ToPreviewOptions options) const {
} }
return {}; return {};
}(); }();
const auto fromSender = [](not_null<PeerData*> sender) {
return sender->isSelf()
? tr::lng_from_you(tr::now)
: sender->shortName();
};
const auto fromForwarded = [&]() -> std::optional<QString> {
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
return forwarded->originalSender
? fromSender(forwarded->originalSender)
: forwarded->hiddenSenderInfo->name;
}
return {};
};
const auto sender = [&]() -> std::optional<QString> { const auto sender = [&]() -> std::optional<QString> {
const auto fromSender = [](not_null<PeerData*> sender) {
return sender->isSelf()
? tr::lng_from_you(tr::now)
: sender->shortName();
};
if (options.hideSender || isPost() || isEmpty()) { if (options.hideSender || isPost() || isEmpty()) {
return {}; return {};
} else if (!_history->peer->isUser()) { } else if (!_history->peer->isUser()) {
return fromSender(displayFrom()); if (const auto from = displayFrom()) {
} else if (_history->peer->isSelf()) { return fromSender(from);
if (const auto forwarded = Get<HistoryMessageForwarded>()) {
return forwarded->originalSender
? fromSender(forwarded->originalSender)
: forwarded->hiddenSenderInfo->name;
} }
return fromForwarded();
} else if (_history->peer->isSelf()) {
return fromForwarded();
} }
return {}; return {};
}(); }();