Show forward original sender in reply bar.

This commit is contained in:
John Preston 2024-01-02 14:11:09 +04:00
parent ca9caa36da
commit 5c29cc59c8
3 changed files with 28 additions and 2 deletions

View File

@ -408,7 +408,10 @@ void Reply::updateName(
std::optional<PeerData*> resolvedSender) const {
auto viaBotUsername = QString();
const auto message = data->resolvedMessage.get();
if (message && !message->Has<HistoryMessageForwarded>()) {
const auto forwarded = message
? message->Get<HistoryMessageForwarded>()
: 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<Data::Session*> owner) {
return Ui::Text::SingleCustomEmoji(
owner->customEmojiManager().registerInternalEmoji(
st::historyReplyForward,
st::historyReplyForwardPadding));
}
TextWithEntities Reply::ComposePreviewName(
not_null<History*> history,
not_null<HistoryItem*> to,

View File

@ -105,6 +105,8 @@ public:
[[nodiscard]] static TextWithEntities PeerEmoji(
not_null<Data::Session*> owner,
PeerData *peer);
[[nodiscard]] static TextWithEntities ForwardEmoji(
not_null<Data::Session*> owner);
[[nodiscard]] static TextWithEntities ComposePreviewName(
not_null<History*> history,
not_null<HistoryItem*> to,

View File

@ -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);