diff --git a/Telegram/SourceFiles/history/history_item.cpp b/Telegram/SourceFiles/history/history_item.cpp index dfdfce87e..10a18c755 100644 --- a/Telegram/SourceFiles/history/history_item.cpp +++ b/Telegram/SourceFiles/history/history_item.cpp @@ -711,9 +711,9 @@ HistoryItem::HistoryItem( : tr::lng_sponsored_message_title(tr::now), from.title, textWithEntities, - from.webpageOrBotPhotoId - ? history->owner().photo(from.webpageOrBotPhotoId) - : nullptr, + (from.webpageOrBotPhotoId + ? history->owner().photo(from.webpageOrBotPhotoId).get() + : nullptr), nullptr, WebPageCollage(), 0, diff --git a/Telegram/SourceFiles/media/stories/media_stories_repost_view.cpp b/Telegram/SourceFiles/media/stories/media_stories_repost_view.cpp index cf44bcce8..4a729bb5f 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_repost_view.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_repost_view.cpp @@ -12,7 +12,6 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "data/data_session.h" #include "data/data_stories.h" #include "history/view/history_view_reply.h" -#include "lang/lang_keys.h" #include "main/main_session.h" #include "media/stories/media_stories_controller.h" #include "ui/effects/ripple_animation.h" @@ -54,14 +53,24 @@ void RepostView::draw(Painter &p, int x, int y, int availableWidth) { if (!_maxWidth) { recountDimensions(); } - const auto w = std::min(_maxWidth, availableWidth); - const auto rect = QRect(x, y, w, height()); + if (_loading) { + return; + } + const auto simple = _text.isEmpty(); + if (simple) { + y += st::normalFont->height; + } + const auto w = std::min(int(_maxWidth), availableWidth); + const auto h = height() - (simple ? st::normalFont->height : 0); + const auto rect = QRect(x, y, w, h); const auto colorPeer = _story->repostSourcePeer(); - const auto backgroundEmojiId = colorPeer + const auto backgroundEmojiId = (!simple && colorPeer) ? colorPeer->backgroundEmojiId() : DocumentId(); const auto cache = &_quoteCache; - const auto "eSt = st::messageQuoteStyle; + const auto "eSt = simple + ? st::storiesRepostSimpleStyle + : st::messageQuoteStyle; const auto backgroundEmoji = backgroundEmojiId ? &_backgroundEmojiData : nullptr; @@ -106,27 +115,27 @@ void RepostView::draw(Painter &p, int x, int y, int availableWidth) { } const auto pausedSpoiler = On(PowerSaving::kChatSpoiler); - auto textLeft = x + st::historyReplyPadding.left(); - auto textTop = y - + st::historyReplyPadding.top() - + st::semiboldFont->height; if (w > st::historyReplyPadding.left()) { - if (_stateText.isEmpty()) { - const auto textw = w - - st::historyReplyPadding.left() - - st::historyReplyPadding.right(); - const auto namew = textw; - if (namew > 0) { - p.setPen(cache->icon); - _name.drawLeftElided( - p, - x + st::historyReplyPadding.left(), - y + st::historyReplyPadding.top(), - namew, - w + 2 * x); + const auto textw = w + - st::historyReplyPadding.left() + - st::historyReplyPadding.right(); + const auto namew = textw; + if (namew > 0) { + p.setPen(cache->icon); + _name.drawLeftElided( + p, + x + st::historyReplyPadding.left(), + y + st::historyReplyPadding.top(), + namew, + w + 2 * x); + if (!simple) { + const auto textLeft = x + st::historyReplyPadding.left(); + const auto textTop = y + + st::historyReplyPadding.top() + + st::semiboldFont->height; _text.draw(p, { .position = { textLeft, textTop }, - .availableWidth = w, + .availableWidth = textw, .palette = &st::mediaviewTextPalette, .spoiler = Ui::Text::DefaultSpoilerCache(), .pausedEmoji = On(PowerSaving::kEmojiChat), @@ -134,18 +143,6 @@ void RepostView::draw(Painter &p, int x, int y, int availableWidth) { .elisionLines = 1, }); } - } else { - p.setFont(st::msgDateFont); - p.setPen(cache->icon); - p.drawTextLeft( - textLeft, - (y - + st::historyReplyPadding.top() - + (st::msgDateFont->height / 2)), - w + 2 * x, - st::msgDateFont->elided( - _stateText, - x + w - textLeft - st::historyReplyPadding.right())); } } } @@ -172,13 +169,11 @@ void RepostView::recountDimensions() { _quoteCache.icon = values.name; auto text = TextWithEntities(); - auto displaying = true; auto unavailable = false; if (sender && repostId) { const auto of = owner->stories().lookup({ sender->id, repostId }); - displaying = of.has_value(); - unavailable = !displaying && (of.error() == Data::NoStory::Deleted); - if (displaying) { + unavailable = !of && (of.error() == Data::NoStory::Deleted); + if (of) { text = (*of)->caption(); } else if (!unavailable) { const auto done = crl::guard(this, [=] { @@ -188,9 +183,6 @@ void RepostView::recountDimensions() { owner->stories().resolve({ sender->id, repostId }, done); } } - if (displaying && !unavailable && text.empty()) { - text = { tr::lng_in_dlg_story(tr::now) }; - } auto nameFull = TextWithEntities(); nameFull.append(HistoryView::Reply::PeerEmoji(owner, sender)); @@ -215,21 +207,10 @@ void RepostView::recountDimensions() { context); const auto nameMaxWidth = _name.maxWidth(); - const auto optimalTextWidth = std::min( - _text.maxWidth(), - st::maxSignatureSize); + const auto optimalTextWidth = _text.isEmpty() + ? 0 + : std::min(_text.maxWidth(), st::maxSignatureSize); _maxWidth = std::max(nameMaxWidth, optimalTextWidth); - if (!displaying) { - _stateText = !unavailable - ? tr::lng_profile_loading(tr::now) - : tr::lng_deleted_story(tr::now); - const auto phraseWidth = st::msgDateFont->width(_stateText); - _maxWidth = unavailable - ? phraseWidth - : std::max(_maxWidth, phraseWidth); - } else { - _stateText = QString(); - } _maxWidth = st::historyReplyPadding.left() + _maxWidth + st::historyReplyPadding.right(); diff --git a/Telegram/SourceFiles/media/stories/media_stories_repost_view.h b/Telegram/SourceFiles/media/stories/media_stories_repost_view.h index 5812cd77f..404c4f0a6 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_repost_view.h +++ b/Telegram/SourceFiles/media/stories/media_stories_repost_view.h @@ -45,9 +45,9 @@ private: Ui::Text::String _text; Ui::Text::QuotePaintCache _quoteCache; Ui::BackgroundEmojiData _backgroundEmojiData; - QString _stateText; Ui::ColorIndicesCompressed _colorIndices; - int _maxWidth = 0; + uint32 _maxWidth : 31 = 0; + uint32 _loading : 1 = 0; rpl::lifetime _lifetime; diff --git a/Telegram/SourceFiles/media/view/media_view.style b/Telegram/SourceFiles/media/view/media_view.style index b386e67eb..674129d22 100644 --- a/Telegram/SourceFiles/media/view/media_view.style +++ b/Telegram/SourceFiles/media/view/media_view.style @@ -1009,3 +1009,9 @@ storiesLikeCountStyle: TextStyle(defaultTextStyle) { font: font(32px semibold); } storiesChangelogFooterWidthMin: 240px; +storiesRepostSimpleStyle: QuoteStyle(defaultQuoteStyle) { + padding: margins(8px, 2px, 8px, 2px); + verticalSkip: 4px; + outline: 0px; + radius: 10px; +} diff --git a/Telegram/SourceFiles/window/main_window.cpp b/Telegram/SourceFiles/window/main_window.cpp index 41a688add..d25992051 100644 --- a/Telegram/SourceFiles/window/main_window.cpp +++ b/Telegram/SourceFiles/window/main_window.cpp @@ -42,6 +42,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include #include +#include #include #include diff --git a/Telegram/SourceFiles/window/window_controller.cpp b/Telegram/SourceFiles/window/window_controller.cpp index 642e44312..917cd6d66 100644 --- a/Telegram/SourceFiles/window/window_controller.cpp +++ b/Telegram/SourceFiles/window/window_controller.cpp @@ -33,6 +33,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "styles/style_layers.h" #include +#include namespace Window { namespace {