diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index e758858cf..dcdd8b3d0 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -1235,6 +1235,22 @@ uint8 HistoryItem::colorIndex() const { Unexpected("No displayFrom and no displayHiddenSenderInfo."); } +PeerData *HistoryItem::contentColorsFrom() const { + if (const auto forwarded = Get()) { + return forwarded->originalSender; + } + return displayFrom(); +} + +uint8 HistoryItem::contentColorIndex() const { + if (const auto forwarded = Get()) { + return forwarded->originalSender + ? forwarded->originalSender->colorIndex() + : forwarded->originalHiddenSenderInfo->colorIndex; + } + return colorIndex(); +} + std::unique_ptr HistoryItem::createView( not_null delegate, HistoryView::Element *replacing) { diff --git a/Telegram/SourceFiles/history/history_item.h b/Telegram/SourceFiles/history/history_item.h index de206baac..412b9e057 100644 --- a/Telegram/SourceFiles/history/history_item.h +++ b/Telegram/SourceFiles/history/history_item.h @@ -516,6 +516,11 @@ public: [[nodiscard]] PeerData *displayFrom() const; [[nodiscard]] uint8 colorIndex() const; + // In forwards we show name in sender's color, but the message + // content uses the color of the original sender. + [[nodiscard]] PeerData *contentColorsFrom() const; + [[nodiscard]] uint8 contentColorIndex() const; + [[nodiscard]] std::unique_ptr createView( not_null delegate, HistoryView::Element *replacing = nullptr); diff --git a/Telegram/SourceFiles/history/view/history_view_element.cpp b/Telegram/SourceFiles/history/view/history_view_element.cpp index 872c10fd8..a573eace0 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.cpp +++ b/Telegram/SourceFiles/history/view/history_view_element.cpp @@ -490,6 +490,10 @@ uint8 Element::colorIndex() const { return data()->colorIndex(); } +uint8 Element::contentColorIndex() const { + return data()->contentColorIndex(); +} + QDateTime Element::dateTime() const { return _dateTime; } diff --git a/Telegram/SourceFiles/history/view/history_view_element.h b/Telegram/SourceFiles/history/view/history_view_element.h index 3fbaa598f..3b524915f 100644 --- a/Telegram/SourceFiles/history/view/history_view_element.h +++ b/Telegram/SourceFiles/history/view/history_view_element.h @@ -317,6 +317,7 @@ public: void refreshDataId(); [[nodiscard]] uint8 colorIndex() const; + [[nodiscard]] uint8 contentColorIndex() const; [[nodiscard]] QDateTime dateTime() const; [[nodiscard]] int y() const; diff --git a/Telegram/SourceFiles/history/view/history_view_message.cpp b/Telegram/SourceFiles/history/view/history_view_message.cpp index 82acfc530..4edffbe37 100644 --- a/Telegram/SourceFiles/history/view/history_view_message.cpp +++ b/Telegram/SourceFiles/history/view/history_view_message.cpp @@ -1670,7 +1670,7 @@ void Message::paintText( .availableWidth = trect.width(), .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(colorIndex()), + .blockquote = context.quoteCache(contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/history_view_reply.cpp b/Telegram/SourceFiles/history/view/history_view_reply.cpp index b2d89f2fd..678b34b8f 100644 --- a/Telegram/SourceFiles/history/view/history_view_reply.cpp +++ b/Telegram/SourceFiles/history/view/history_view_reply.cpp @@ -201,7 +201,7 @@ void Reply::update( } } _colorPeer = message - ? message->displayFrom() + ? message->contentColorsFrom() : story ? story->peer().get() : _externalSender diff --git a/Telegram/SourceFiles/history/view/media/history_view_document.cpp b/Telegram/SourceFiles/history/view/media/history_view_document.cpp index 226285f72..e3e2808cd 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_document.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_document.cpp @@ -888,7 +888,7 @@ void Document::draw( .availableWidth = captionw, .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(parent()->colorIndex()), + .blockquote = context.quoteCache(parent()->contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp b/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp index b229b5eb9..d127fc4fc 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_extended_preview.cpp @@ -237,7 +237,7 @@ void ExtendedPreview::draw(Painter &p, const PaintContext &context) const { .availableWidth = captionw, .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(parent()->colorIndex()), + .blockquote = context.quoteCache(parent()->contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/media/history_view_game.cpp b/Telegram/SourceFiles/history/view/media/history_view_game.cpp index 57dd72167..2eda3513c 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_game.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_game.cpp @@ -219,7 +219,7 @@ void Game::draw(Painter &p, const PaintContext &context) const { auto tshift = inner.top(); auto paintw = inner.width(); - const auto colorIndex = parent()->colorIndex(); + const auto colorIndex = parent()->contentColorIndex(); const auto selected = context.selected(); const auto cache = context.outbg ? stm->replyCache[st->colorPatternIndex(colorIndex)].get() diff --git a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp index 21d35d0a6..87a0e00bf 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_gif.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_gif.cpp @@ -724,7 +724,7 @@ void Gif::draw(Painter &p, const PaintContext &context) const { .availableWidth = captionw, .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(parent()->colorIndex()), + .blockquote = context.quoteCache(parent()->contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp index 379afd782..038192cf1 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_media_grouped.cpp @@ -405,7 +405,7 @@ void GroupedMedia::draw(Painter &p, const PaintContext &context) const { .availableWidth = captionw, .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(parent()->colorIndex()), + .blockquote = context.quoteCache(parent()->contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp index b87c0c6a3..fa633ab37 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_photo.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_photo.cpp @@ -433,7 +433,7 @@ void Photo::draw(Painter &p, const PaintContext &context) const { .availableWidth = captionw, .palette = &stm->textPalette, .pre = stm->preCache.get(), - .blockquote = context.quoteCache(parent()->colorIndex()), + .blockquote = context.quoteCache(parent()->contentColorIndex()), .colors = context.st->highlightColors(), .spoiler = Ui::Text::DefaultSpoilerCache(), .now = context.now, diff --git a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp index 7e75ddb91..43b3d8370 100644 --- a/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp +++ b/Telegram/SourceFiles/history/view/media/history_view_web_page.cpp @@ -584,11 +584,11 @@ void WebPage::draw(Painter &p, const PaintContext &context) const { const auto selected = context.selected(); const auto view = parent(); - const auto colorIndex = view->colorIndex(); + const auto from = view->data()->contentColorsFrom(); + const auto colorIndex = from ? from->colorIndex() : view->colorIndex(); const auto cache = context.outbg ? stm->replyCache[st->colorPatternIndex(colorIndex)].get() : st->coloredReplyCache(selected, colorIndex).get(); - const auto from = view->data()->displayFrom(); const auto backgroundEmojiId = from ? from->backgroundEmojiId() : DocumentId();