diff --git a/Telegram/SourceFiles/media/stories/media_stories_controller.cpp b/Telegram/SourceFiles/media/stories/media_stories_controller.cpp index bc7d0eaec..af4abbb4b 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_controller.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_controller.cpp @@ -96,7 +96,6 @@ private: const not_null _controller; std::unique_ptr _bg; - std::unique_ptr _reply; std::unique_ptr _text; std::unique_ptr _button; Ui::RoundRect _bgRound; @@ -172,32 +171,9 @@ void Controller::Unsupported::setup(not_null user) { _bgRound.paint(p, _bg->rect()); }, _bg->lifetime()); - if (!user->isSelf()) { - _reply = std::make_unique(wrap); - _reply->show(); - _reply->paintRequest() | rpl::start_with_next([=] { - auto p = QPainter(_reply.get()); - _bgRound.paint(p, _reply->rect()); - - p.setPen(st::storiesComposeGrayText); - p.setFont(st::normalFont); - p.drawText( - _reply->rect(), - tr::lng_stories_cant_reply(tr::now), - style::al_center); - }, _reply->lifetime()); - } - _controller->layoutValue( ) | rpl::start_with_next([=](const Layout &layout) { _bg->setGeometry(layout.content); - if (_reply) { - const auto height = st::storiesComposeControls.attach.height; - const auto position = layout.controlsBottomPosition - - QPoint(0, height); - _reply->setGeometry( - { position, QSize{ layout.controlsWidth, height } }); - } }, _bg->lifetime()); _text = std::make_unique( @@ -1141,7 +1117,6 @@ void Controller::rebuildCachedSourcesList( } else { // All that go before the current push to front. for (auto before = index; before > 0;) { - --before; const auto peerId = lists[--before].id; if (!ranges::contains(_cachedSourcesList, peerId)) { _cachedSourcesList.insert( @@ -1160,12 +1135,8 @@ void Controller::rebuildCachedSourcesList( } Ensures(_cachedSourcesList.size() == lists.size()); - Ensures(ranges::equal( - lists, - _cachedSourcesList, - ranges::equal_to(), - &Data::StoriesSourceInfo::id)); - Ensures(_cachedSourceIndex >= 0 && _cachedSourceIndex < _cachedSourcesList.size()); + Ensures(_cachedSourceIndex >= 0 + && _cachedSourceIndex < _cachedSourcesList.size()); } void Controller::refreshViewsFromData() { diff --git a/Telegram/SourceFiles/media/stories/media_stories_reply.cpp b/Telegram/SourceFiles/media/stories/media_stories_reply.cpp index 2929d52c9..d032533b3 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_reply.cpp +++ b/Telegram/SourceFiles/media/stories/media_stories_reply.cpp @@ -35,6 +35,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "storage/storage_account.h" #include "storage/storage_media_prepare.h" #include "ui/chat/attach/attach_prepare.h" +#include "ui/round_rect.h" #include "window/section_widget.h" #include "styles/style_boxes.h" // sendMediaPreviewSize. #include "styles/style_chat_helpers.h" @@ -42,6 +43,35 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL namespace Media::Stories { +class ReplyArea::Cant final : public Ui::RpWidget { +public: + explicit Cant(not_null parent); + +private: + void paintEvent(QPaintEvent *e) override; + + Ui::RoundRect _bg; + +}; + +ReplyArea::Cant::Cant(not_null parent) +: RpWidget(parent) +, _bg(st::storiesRadius, st::storiesComposeBg) { + show(); +} + +void ReplyArea::Cant::paintEvent(QPaintEvent *e) { + auto p = QPainter(this); + _bg.paint(p, rect()); + + p.setPen(st::storiesComposeGrayText); + p.setFont(st::normalFont); + p.drawText( + rect(), + tr::lng_stories_cant_reply(tr::now), + style::al_center); +} + ReplyArea::ReplyArea(not_null controller) : _controller(controller) , _controls(std::make_unique( @@ -599,10 +629,25 @@ void ReplyArea::show(ReplyAreaData data) { .history = history, }); _controls->clear(); - if (!user || user->isSelf()) { - _controls->hide(); - } else { + const auto hidden = user && user->isSelf(); + const auto cant = !user || user->isServiceUser(); + if (!hidden && !cant) { _controls->show(); + } else { + _controls->hide(); + if (cant) { + _cant = std::make_unique(_controller->wrap()); + _controller->layoutValue( + ) | rpl::start_with_next([=](const Layout &layout) { + const auto height = st::storiesComposeControls.attach.height; + const auto position = layout.controlsBottomPosition + - QPoint(0, height); + _cant->setGeometry( + { position, QSize{ layout.controlsWidth, height } }); + }, _cant->lifetime()); + } else { + _cant = nullptr; + } } } diff --git a/Telegram/SourceFiles/media/stories/media_stories_reply.h b/Telegram/SourceFiles/media/stories/media_stories_reply.h index 5853ffc0e..eeaa54726 100644 --- a/Telegram/SourceFiles/media/stories/media_stories_reply.h +++ b/Telegram/SourceFiles/media/stories/media_stories_reply.h @@ -68,6 +68,8 @@ public: [[nodiscard]] rpl::producer hasSendTextValue() const; private: + class Cant; + using VoiceToSend = HistoryView::Controls::VoiceToSend; [[nodiscard]] Main::Session &session() const; @@ -134,6 +136,7 @@ private: const not_null _controller; const std::unique_ptr _controls; + std::unique_ptr _cant; ReplyAreaData _data; base::has_weak_ptr _shownUserGuard;