diff --git a/Telegram/SourceFiles/media/stories/media_stories_controller.cpp b/Telegram/SourceFiles/media/stories/media_stories_controller.cpp index 3201fb844..f1efa5319 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_controller.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_controller.cpp @@ -866,8 +866,7 @@ void Controller::show( .list = story->recentViewers(), .reactions = story->reactions(), .total = story->views(), - .self = peer->isSelf(), - .channel = peer->isChannel(), + .type = RecentViewsTypeFor(peer), }, _reactions->likedValue()); if (const auto nowLikeButton = _recentViews->likeButton()) { if (wasLikeButton != nowLikeButton) { @@ -875,7 +874,7 @@ void Controller::show( } } - if (peer->isSelf() || peer->isChannel()) { + if (peer->isSelf() || peer->isChannel() || peer->isServiceUser()) { _reactions->setReactionIconWidget(_recentViews->likeIconWidget()); } else if (const auto like = _replyArea->likeAnimationTarget()) { _reactions->setReactionIconWidget(like); @@ -963,8 +962,7 @@ void Controller::subscribeToSession() { .list = update.story->recentViewers(), .reactions = update.story->reactions(), .total = update.story->views(), - .self = update.story->peer()->isSelf(), - .channel = update.story->peer()->isChannel(), + .type = RecentViewsTypeFor(update.story->peer()), }); updateAreas(update.story); } diff --git a/Telegram/SourceFiles/media/stories/media_stories_recent_views.cpp b/Telegram/SourceFiles/media/stories/media_stories_recent_views.cpp index e2be66e08..ed8f4f7fa 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_recent_views.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_recent_views.cpp @@ -123,6 +123,16 @@ constexpr auto kLoadViewsPages = 2; } // namespace +RecentViewsType RecentViewsTypeFor(not_null peer) { + return peer->isSelf() + ? RecentViewsType::Self + : peer->isChannel() + ? RecentViewsType::Channel + : peer->isServiceUser() + ? RecentViewsType::Changelog + : RecentViewsType::Other; +} + RecentViews::RecentViews(not_null controller) : _controller(controller) { } @@ -155,7 +165,7 @@ void RecentViews::show( || (_data.reactions != data.reactions); const auto usersChanged = !_userpics || (_data.list != data.list); _data = data; - if (!_data.self) { + if (_data.type != RecentViewsType::Self) { _text = {}; _clickHandlerLifetime.destroy(); _userpicsLifetime.destroy(); @@ -177,13 +187,17 @@ void RecentViews::show( refreshClickHandler(); } - if (!_data.channel) { + if (_data.type != RecentViewsType::Channel + && _data.type != RecentViewsType::Changelog) { _likeIcon = nullptr; _likeWrap = nullptr; _viewsWrap = nullptr; } else { - _viewsCounter = Lang::FormatCountDecimal(std::max(_data.total, 1)); - _likesCounter = _data.reactions + _viewsCounter = (_data.type == RecentViewsType::Channel) + ? Lang::FormatCountDecimal(std::max(_data.total, 1)) + : tr::lng_stories_cant_reply(tr::now); + _likesCounter = ((_data.type == RecentViewsType::Channel) + && _data.reactions) ? Lang::FormatCountDecimal(_data.reactions) : QString(); if (!_likeWrap || !_likeIcon || !_viewsWrap) { @@ -300,14 +314,19 @@ void RecentViews::setupViewsReactions() { st::storiesViewsText); views->show(); views->setAttribute(Qt::WA_TransparentForMouseEvents); - views->move(st::storiesViewsTextPosition); views->widthValue( ) | rpl::start_with_next([=](int width) { - _viewsWrap->resize(views->x() + width, _likeIcon->height()); + const auto left = (_data.type == RecentViewsType::Changelog) + ? st::mediaviewCaptionPadding.left() + : st::storiesViewsTextPosition.x(); + views->move(left, st::storiesViewsTextPosition.y()); + _viewsWrap->resize(left + width, _likeIcon->height()); updateViewsReactionsGeometry(); }, _viewsWrap->lifetime()); - _viewsWrap->paintRequest() | rpl::start_with_next([=] { + _viewsWrap->paintRequest() | rpl::filter([=] { + return (_data.type != RecentViewsType::Changelog); + }) | rpl::start_with_next([=] { auto p = QPainter(_viewsWrap.get()); const auto &icon = st::storiesViewsIcon; const auto top = (_viewsWrap->height() - icon.height()) / 2; @@ -342,9 +361,14 @@ void RecentViews::setupViewsReactions() { } void RecentViews::updateViewsReactionsGeometry() { - _viewsWrap->move(_outer.topLeft() + st::storiesViewsPosition); - _likeWrap->move(_outer.topLeft() - + QPoint(_outer.width() - _likeWrap->width(), 0) + const auto outerWidth = (_data.type == RecentViewsType::Changelog) + ? std::max(_outer.width(), st::storiesChangelogFooterWidthMin) + : _outer.width(); + const auto outerOrigin = _outer.topLeft() + + QPoint((_outer.width() - outerWidth) / 2, 0); + _viewsWrap->move(outerOrigin + st::storiesViewsPosition); + _likeWrap->move(outerOrigin + + QPoint(outerWidth - _likeWrap->width(), 0) + st::storiesLikesPosition); } diff --git a/Telegram/SourceFiles/media/stories/media_stories_recent_views.h b/Telegram/SourceFiles/media/stories/media_stories_recent_views.h index 1e8f226fb..ed4617952 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_recent_views.h +++ b/Telegram/SourceFiles/media/stories/media_stories_recent_views.h @@ -33,12 +33,18 @@ namespace Media::Stories { class Controller; +enum class RecentViewsType { + Other, + Self, + Channel, + Changelog, +}; + struct RecentViewsData { std::vector> list; int reactions = 0; int total = 0; - bool self = false; - bool channel = false; + RecentViewsType type = RecentViewsType::Other; friend inline auto operator<=>( const RecentViewsData &, @@ -48,6 +54,8 @@ struct RecentViewsData { const RecentViewsData &) = default; }; +[[nodiscard]] RecentViewsType RecentViewsTypeFor(not_null peer); + class RecentViews final { public: explicit RecentViews(not_null controller); diff --git a/Telegram/SourceFiles/media/stories/media_stories_reply.cpp b/Telegram/SourceFiles/media/stories/media_stories_reply.cpp index 9296a8b63..4da1201f0 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_reply.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_reply.cpp @@ -675,8 +675,9 @@ void ReplyArea::show( }), }); _controls->clear(); - const auto hidden = peer && (!peer->isUser() || peer->isSelf()); - const auto cant = !peer || peer->isServiceUser(); + const auto hidden = peer + && (!peer->isUser() || peer->isSelf() || peer->isServiceUser()); + const auto cant = !peer; if (!hidden && !cant) { _controls->show(); } else { diff --git a/Telegram/SourceFiles/media/view/media_view.style b/Telegram/SourceFiles/media/view/media_view.style index bafcd0574..6b10b078c 100644 --- a/Telegram/SourceFiles/media/view/media_view.style +++ b/Telegram/SourceFiles/media/view/media_view.style @@ -1014,3 +1014,4 @@ storiesLikeCountStyle: TextStyle(defaultTextStyle) { linkFont: font(32px semibold); linkFontOver: font(32px semibold underline); } +storiesChangelogFooterWidthMin: 240px;