diff --git a/Telegram/SourceFiles/history/view/history_view_reply.cpp b/Telegram/SourceFiles/history/view/history_view_reply.cpp index 678b34b8f3..1c78094d64 100644 --- a/Telegram/SourceFiles/history/view/history_view_reply.cpp +++ b/Telegram/SourceFiles/history/view/history_view_reply.cpp @@ -408,7 +408,10 @@ void Reply::updateName( std::optional resolvedSender) const { auto viaBotUsername = QString(); const auto message = data->resolvedMessage.get(); - if (message && !message->Has()) { + const auto forwarded = message + ? message->Get() + : nullptr; + if (message && !forwarded) { if (const auto bot = message->viaBot()) { viaBotUsername = bot->username(); } @@ -424,7 +427,14 @@ void Reply::updateName( && externalPeer && (externalPeer != sender) && (externalPeer->isChat() || externalPeer->isMegagroup()); - const auto shorten = !viaBotUsername.isEmpty() || groupNameAdded; + const auto originalNameAdded = !displayAsExternal + && forwarded + && !message->isDiscussionPost() + && (!message->showForwardsFromSender(forwarded) + || forwarded->forwardOfForward()); + const auto shorten = !viaBotUsername.isEmpty() + || groupNameAdded + || originalNameAdded; const auto name = sender ? senderName(sender, shorten) : senderName(view, data, shorten); @@ -443,6 +453,11 @@ void Reply::updateName( if (groupNameAdded) { nameFull.append(' ').append(PeerEmoji(history, externalPeer)); nameFull.append(externalPeer->name()); + } else if (originalNameAdded) { + nameFull.append(' ').append(ForwardEmoji(&history->owner())); + nameFull.append(forwarded->originalSender + ? forwarded->originalSender->name() + : forwarded->originalHiddenSenderInfo->name); } if (!viaBotUsername.isEmpty()) { nameFull.append(u" @"_q).append(viaBotUsername); @@ -838,6 +853,13 @@ TextWithEntities Reply::PeerEmoji( icon.second)); } +TextWithEntities Reply::ForwardEmoji(not_null owner) { + return Ui::Text::SingleCustomEmoji( + owner->customEmojiManager().registerInternalEmoji( + st::historyReplyForward, + st::historyReplyForwardPadding)); +} + TextWithEntities Reply::ComposePreviewName( not_null history, not_null to, diff --git a/Telegram/SourceFiles/history/view/history_view_reply.h b/Telegram/SourceFiles/history/view/history_view_reply.h index 9a70356ea7..416f4c0097 100644 --- a/Telegram/SourceFiles/history/view/history_view_reply.h +++ b/Telegram/SourceFiles/history/view/history_view_reply.h @@ -105,6 +105,8 @@ public: [[nodiscard]] static TextWithEntities PeerEmoji( not_null owner, PeerData *peer); + [[nodiscard]] static TextWithEntities ForwardEmoji( + not_null owner); [[nodiscard]] static TextWithEntities ComposePreviewName( not_null history, not_null to, diff --git a/Telegram/SourceFiles/ui/chat/chat.style b/Telegram/SourceFiles/ui/chat/chat.style index b025a57b84..7507e0e6bb 100644 --- a/Telegram/SourceFiles/ui/chat/chat.style +++ b/Telegram/SourceFiles/ui/chat/chat.style @@ -38,6 +38,8 @@ historyReplyGroup: icon {{ "chat/reply_type_group", windowFg }}; historyReplyGroupPadding: margins(0px, 4px, 4px, 0px); historyReplyChannel: icon {{ "chat/reply_type_channel", windowFg }}; historyReplyChannelPadding: margins(0px, 5px, 4px, 0px); +historyReplyForward: icon {{ "mini_forward", windowFg }}; +historyReplyForwardPadding: margins(0px, 2px, 2px, 0px); msgReplyPadding: margins(6px, 6px, 11px, 6px); msgReplyBarPos: point(1px, 0px);