diff --git a/Telegram/CMakeLists.txt b/Telegram/CMakeLists.txt index 92ce8f31a3..1d52a00a53 100644 --- a/Telegram/CMakeLists.txt +++ b/Telegram/CMakeLists.txt @@ -836,6 +836,8 @@ PRIVATE history/view/history_view_bottom_info.h history/view/history_view_chat_preview.cpp history/view/history_view_chat_preview.h + history/view/history_view_chat_section.cpp + history/view/history_view_chat_section.h history/view/history_view_contact_status.cpp history/view/history_view_contact_status.h history/view/history_view_context_menu.cpp @@ -870,8 +872,6 @@ PRIVATE history/view/history_view_pinned_tracker.h history/view/history_view_quick_action.cpp history/view/history_view_quick_action.h - history/view/history_view_replies_section.cpp - history/view/history_view_replies_section.h history/view/history_view_reply.cpp history/view/history_view_reply.h history/view/history_view_requests_bar.cpp diff --git a/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp index fe675532a1..1e6ab6206b 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_forum_topic_box.cpp @@ -27,7 +27,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "boxes/premium_preview_box.h" #include "main/main_session.h" #include "history/history.h" -#include "history/view/history_view_replies_section.h" +#include "history/view/history_view_chat_section.h" #include "history/view/history_view_sticker_toast.h" #include "lang/lang_keys.h" #include "info/profile/info_profile_emoji_status_panel.h" @@ -518,13 +518,15 @@ void EditForumTopicBox( title->showError(); return; } + using namespace HistoryView; controller->showSection( - std::make_shared( - forum, - channel->forum()->reserveCreatingId( + std::make_shared(ChatViewId{ + .history = forum, + .repliesRootId = channel->forum()->reserveCreatingId( title->getLastText().trimmed(), state->defaultIcon.current().colorId, - state->iconId.current())), + state->iconId.current()), + }), Window::SectionShow::Way::ClearStack); }; diff --git a/Telegram/SourceFiles/data/data_forum_topic.cpp b/Telegram/SourceFiles/data/data_forum_topic.cpp index 7e7998897c..eb93c36375 100644 --- a/Telegram/SourceFiles/data/data_forum_topic.cpp +++ b/Telegram/SourceFiles/data/data_forum_topic.cpp @@ -26,7 +26,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_item.h" #include "history/history_unread_things.h" #include "history/view/history_view_item_preview.h" -#include "history/view/history_view_replies_section.h" +#include "history/view/history_view_chat_section.h" #include "main/main_session.h" #include "base/unixtime.h" #include "ui/painter.h" diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 9e829886f7..85682e38eb 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -5311,7 +5311,7 @@ void HistoryWidget::updateSendButtonType() { using Type = Ui::SendButton::Type; const auto type = computeSendButtonType(); - // This logic is duplicated in RepliesWidget. + // This logic is duplicated in ChatWidget. const auto disabledBySlowmode = _peer && _peer->slowmodeApplied() && (_history->latestSendingMessage() != nullptr); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_chat_section.cpp similarity index 82% rename from Telegram/SourceFiles/history/view/history_view_replies_section.cpp rename to Telegram/SourceFiles/history/view/history_view_chat_section.cpp index 768f42b178..250d952f0c 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_chat_section.cpp @@ -5,7 +5,7 @@ the official desktop application for the Telegram messaging service. For license and copyright information please follow this link: https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL */ -#include "history/view/history_view_replies_section.h" +#include "history/view/history_view_chat_section.h" #include "history/view/controls/history_view_compose_controls.h" #include "history/view/controls/history_view_compose_search.h" @@ -111,32 +111,34 @@ rpl::producer RootViewContent( } // namespace -RepliesMemento::RepliesMemento( - not_null history, - MsgId rootId, +ChatMemento::ChatMemento( + ChatViewId id, MsgId highlightId, const TextWithEntities &highlightPart, int highlightPartOffsetHint) -: _history(history) -, _rootId(rootId) +: _id(id) , _highlightPart(highlightPart) , _highlightPartOffsetHint(highlightPartOffsetHint) , _highlightId(highlightId) { if (highlightId) { _list.setAroundPosition({ - .fullId = FullMsgId(_history->peer->id, highlightId), + .fullId = FullMsgId(_id.history->peer->id, highlightId), .date = TimeId(0), }); } } -RepliesMemento::RepliesMemento( +ChatMemento::ChatMemento( + Comments, not_null commentsItem, MsgId commentId) -: RepliesMemento(commentsItem->history(), commentsItem->id, commentId) { +: ChatMemento({ + .history = commentsItem->history(), + .repliesRootId = commentsItem->id, +}, commentId) { } -void RepliesMemento::setFromTopic(not_null topic) { +void ChatMemento::setFromTopic(not_null topic) { _replies = topic->replies(); if (!_list.aroundPosition()) { _list = *topic->listMemento(); @@ -144,31 +146,35 @@ void RepliesMemento::setFromTopic(not_null topic) { } -Data::ForumTopic *RepliesMemento::topicForRemoveRequests() const { - return _history->peer->forumTopicFor(_rootId); +Data::ForumTopic *ChatMemento::topicForRemoveRequests() const { + return _id.repliesRootId + ? _id.history->peer->forumTopicFor(_id.repliesRootId) + : nullptr; } -void RepliesMemento::setReadInformation( +void ChatMemento::setReadInformation( MsgId inboxReadTillId, int unreadCount, MsgId outboxReadTillId) { - if (!_replies) { - if (const auto forum = _history->asForum()) { - if (const auto topic = forum->topicFor(_rootId)) { + if (!_id.repliesRootId) { + return; + } else if (!_replies) { + if (const auto forum = _id.history->asForum()) { + if (const auto topic = forum->topicFor(_id.repliesRootId)) { _replies = topic->replies(); } } if (!_replies) { _replies = std::make_shared( - _history, - _rootId); + _id.history, + _id.repliesRootId); } } _replies->setInboxReadTill(inboxReadTillId, unreadCount); _replies->setOutboxReadTill(outboxReadTillId); } -object_ptr RepliesMemento::createWidget( +object_ptr ChatMemento::createWidget( QWidget *parent, not_null controller, Window::Column column, @@ -184,40 +190,42 @@ object_ptr RepliesMemento::createWidget( Data::MinMessagePosition }); } - auto result = object_ptr( - parent, - controller, - _history, - _rootId); + auto result = object_ptr(parent, controller, _id); result->setInternalState(geometry, this); return result; } -void RepliesMemento::setupTopicViewer() { - _history->owner().itemIdChanged( - ) | rpl::start_with_next([=](const Data::Session::IdChange &change) { - if (_rootId == change.oldId) { - _rootId = change.newId.msg; - _replies = nullptr; - } - }, _lifetime); +void ChatMemento::setupTopicViewer() { + if (_id.repliesRootId) { + _id.history->owner().itemIdChanged( + ) | rpl::start_with_next([=](const Data::Session::IdChange &change) { + if (_id.repliesRootId == change.oldId) { + _id.repliesRootId = change.newId.msg; + _replies = nullptr; + } + }, _lifetime); + } } -RepliesWidget::RepliesWidget( +ChatWidget::ChatWidget( QWidget *parent, not_null controller, - not_null history, - MsgId rootId) -: Window::SectionWidget(parent, controller, history->peer) + ChatViewId id) +: Window::SectionWidget(parent, controller, id.history->peer) , WindowListDelegate(controller) -, _history(history) -, _rootId(rootId) -, _root(lookupRoot()) +, _history(id.history) +, _peer(_history->peer) +, _id(id) +, _repliesRootId(_id.repliesRootId) +, _repliesRoot(lookupRepliesRoot()) , _topic(lookupTopic()) , _areComments(computeAreComments()) -, _sendAction(history->owner().sendActionManager().repliesPainter( - history, - rootId)) +, _sublist(_id.sublist) +, _sendAction(_repliesRootId + ? _history->owner().sendActionManager().repliesPainter( + _history, + _repliesRootId) + : nullptr) , _topBar(this, controller) , _topBarShadow(this) , _composeControls(std::make_unique( @@ -239,7 +247,7 @@ RepliesWidget::RepliesWidget( }) | rpl::type_erased() : rpl::single(false), })) -, _translateBar(std::make_unique(this, controller, history)) +, _translateBar(std::make_unique(this, controller, _history)) , _scroll(std::make_unique( this, controller->chatStyle()->value(lifetime(), st::historyScroll), @@ -255,7 +263,7 @@ RepliesWidget::RepliesWidget( Window::ChatThemeValueFromPeer( controller, - history->peer + _peer ) | rpl::start_with_next([=](std::shared_ptr &&theme) { _theme = std::move(theme); controller->setChatStyleTheme(_theme); @@ -266,7 +274,7 @@ RepliesWidget::RepliesWidget( setupShortcuts(); setupTranslateBar(); - _history->peer->updateFull(); + _peer->updateFull(); refreshTopBarActiveChat(); @@ -274,8 +282,8 @@ RepliesWidget::RepliesWidget( _topBar->resizeToWidth(width()); _topBar->show(); - if (_rootView) { - _rootView->move(0, _topBar->height()); + if (_repliesRootView) { + _repliesRootView->move(0, _topBar->height()); } _topBar->deleteSelectionRequest( @@ -331,7 +339,7 @@ RepliesWidget::RepliesWidget( ) | rpl::start_with_next([=](ListWidget::ReplyToMessageRequest request) { const auto canSendReply = _topic ? Data::CanSendAnything(_topic) - : Data::CanSendAnything(_history->peer); + : Data::CanSendAnything(_peer); const auto &to = request.to; const auto still = _history->owner().message(to.messageId); const auto allowInAnotherChat = still && still->allowsForward(); @@ -356,16 +364,18 @@ RepliesWidget::RepliesWidget( _composeControls->sendActionUpdates( ) | rpl::start_with_next([=](ComposeControls::SendActionUpdate &&data) { - if (!data.cancel) { + if (!_repliesRootId) { + return; + } else if (!data.cancel) { session().sendProgressManager().update( _history, - _rootId, + _repliesRootId, data.type, data.progress); } else { session().sendProgressManager().cancel( _history, - _rootId, + _repliesRootId, data.type); } }, lifetime()); @@ -373,8 +383,8 @@ RepliesWidget::RepliesWidget( _history->session().changes().messageUpdates( Data::MessageUpdate::Flag::Destroyed ) | rpl::start_with_next([=](const Data::MessageUpdate &update) { - if (update.item == _root) { - _root = nullptr; + if (update.item == _repliesRoot) { + _repliesRoot = nullptr; updatePinnedVisibility(); if (!_topic) { controller->showBackFromStack(); @@ -415,7 +425,7 @@ RepliesWidget::RepliesWidget( } } -RepliesWidget::~RepliesWidget() { +ChatWidget::~ChatWidget() { base::take(_sendAction); session().api().saveCurrentDraftToCloud(); controller()->sendingAnimation().clear(); @@ -428,18 +438,20 @@ RepliesWidget::~RepliesWidget() { _inner->saveState(_topic->listMemento()); } } - _history->owner().sendActionManager().repliesPainterRemoved( - _history, - _rootId); + if (_repliesRootId) { + _history->owner().sendActionManager().repliesPainterRemoved( + _history, + _repliesRootId); + } } -void RepliesWidget::orderWidgets() { +void ChatWidget::orderWidgets() { _translateBar->raise(); if (_topicReopenBar) { _topicReopenBar->bar().raise(); } - if (_rootView) { - _rootView->raise(); + if (_repliesRootView) { + _repliesRootView->raise(); } if (_pinnedBar) { _pinnedBar->raise(); @@ -451,81 +463,84 @@ void RepliesWidget::orderWidgets() { _composeControls->raisePanels(); } -void RepliesWidget::setupRoot() { - if (!_root) { +void ChatWidget::setupRoot() { + if (_repliesRootId && !_repliesRoot) { const auto done = crl::guard(this, [=] { - _root = lookupRoot(); - if (_root) { + _repliesRoot = lookupRepliesRoot(); + if (_repliesRoot) { _areComments = computeAreComments(); _inner->update(); } updatePinnedVisibility(); }); _history->session().api().requestMessageData( - _history->peer, - _rootId, + _peer, + _repliesRootId, done); } } -void RepliesWidget::setupRootView() { - if (_topic) { +void ChatWidget::setupRootView() { + if (_topic || !_repliesRootId) { return; } - _rootView = std::make_unique(this, [=] { + _repliesRootView = std::make_unique(this, [=] { return controller()->isGifPausedAtLeastFor( Window::GifPauseReason::Any); }, controller()->gifPauseLevelChanged()); - _rootView->setContent(rpl::combine( + _repliesRootView->setContent(rpl::combine( RootViewContent( _history, - _rootId, - [bar = _rootView.get()] { bar->customEmojiRepaint(); }), - _rootVisible.value() + _repliesRootId, + [bar = _repliesRootView.get()] { bar->customEmojiRepaint(); }), + _repliesRootVisible.value() ) | rpl::map([=](Ui::MessageBarContent &&content, bool show) { const auto shown = !content.title.isEmpty() && !content.text.empty(); _shownPinnedItem = shown - ? _history->owner().message(_history->peer->id, _rootId) + ? _history->owner().message(_peer->id, _repliesRootId) : nullptr; return show ? std::move(content) : Ui::MessageBarContent(); })); controller()->adaptive().oneColumnValue( ) | rpl::start_with_next([=](bool one) { - _rootView->setShadowGeometryPostprocess([=](QRect geometry) { + _repliesRootView->setShadowGeometryPostprocess([=](QRect geometry) { if (!one) { geometry.setLeft(geometry.left() + st::lineWidth); } return geometry; }); - }, _rootView->lifetime()); + }, _repliesRootView->lifetime()); - _rootView->barClicks( + _repliesRootView->barClicks( ) | rpl::start_with_next([=] { showAtStart(); }, lifetime()); - _rootViewHeight = 0; - _rootView->heightValue( + _repliesRootViewHeight = 0; + _repliesRootView->heightValue( ) | rpl::start_with_next([=](int height) { - if (const auto delta = height - _rootViewHeight) { - _rootViewHeight = height; + if (const auto delta = height - _repliesRootViewHeight) { + _repliesRootViewHeight = height; setGeometryWithTopMoved(geometry(), delta); } - }, _rootView->lifetime()); + }, _repliesRootView->lifetime()); } -void RepliesWidget::setupTopicViewer() { +void ChatWidget::setupTopicViewer() { + if (!_repliesRootId) { + return; + } const auto owner = &_history->owner(); owner->itemIdChanged( ) | rpl::start_with_next([=](const Data::Session::IdChange &change) { - if (_rootId == change.oldId) { - _rootId = change.newId.msg; - _composeControls->updateTopicRootId(_rootId); + if (_repliesRootId == change.oldId) { + _repliesRootId = _id.repliesRootId = change.newId.msg; + _composeControls->updateTopicRootId(_repliesRootId); _sendAction = owner->sendActionManager().repliesPainter( _history, - _rootId); - _root = lookupRoot(); + _repliesRootId); + _repliesRoot = lookupRepliesRoot(); if (_topic && _topic->rootId() == change.oldId) { setTopic(_topic->forum()->topicFor(change.newId.msg)); } else { @@ -544,7 +559,7 @@ void RepliesWidget::setupTopicViewer() { } } -void RepliesWidget::subscribeToTopic() { +void ChatWidget::subscribeToTopic() { Expects(_topic != nullptr); _topicReopenBar = std::make_unique(this, _topic); @@ -594,7 +609,7 @@ void RepliesWidget::subscribeToTopic() { _cornerButtons.updateUnreadThingsVisibility(); } -void RepliesWidget::subscribeToPinnedMessages() { +void ChatWidget::subscribeToPinnedMessages() { using EntryUpdateFlag = Data::EntryUpdate::Flag; session().changes().entryUpdates( EntryUpdateFlag::HasPinnedMessages @@ -609,7 +624,7 @@ void RepliesWidget::subscribeToPinnedMessages() { setupPinnedTracker(); } -void RepliesWidget::setTopic(Data::ForumTopic *topic) { +void ChatWidget::setTopic(Data::ForumTopic *topic) { if (_topic == topic) { return; } @@ -618,10 +633,10 @@ void RepliesWidget::setTopic(Data::ForumTopic *topic) { refreshReplies(); refreshTopBarActiveChat(); if (_topic) { - if (_rootView) { + if (_repliesRootView) { _shownPinnedItem = nullptr; - _rootView = nullptr; - _rootViewHeight = 0; + _repliesRootView = nullptr; + _repliesRootViewHeight = 0; } subscribeToTopic(); } @@ -632,18 +647,22 @@ void RepliesWidget::setTopic(Data::ForumTopic *topic) { } } -HistoryItem *RepliesWidget::lookupRoot() const { - return _history->owner().message(_history->peer, _rootId); +HistoryItem *ChatWidget::lookupRepliesRoot() const { + return _repliesRootId + ? _history->owner().message(_peer, _repliesRootId) + : nullptr; } -Data::ForumTopic *RepliesWidget::lookupTopic() { - if (const auto forum = _history->asForum()) { - if (const auto result = forum->topicFor(_rootId)) { +Data::ForumTopic *ChatWidget::lookupTopic() { + if (!_repliesRoot) { + return nullptr; + } else if (const auto forum = _history->asForum()) { + if (const auto result = forum->topicFor(_repliesRootId)) { return result; } else { - forum->requestTopic(_rootId, crl::guard(this, [=] { + forum->requestTopic(_repliesRootId, crl::guard(this, [=] { if (const auto forum = _history->asForum()) { - setTopic(forum->topicFor(_rootId)); + setTopic(forum->topicFor(_repliesRootId)); } })); } @@ -651,21 +670,21 @@ Data::ForumTopic *RepliesWidget::lookupTopic() { return nullptr; } -bool RepliesWidget::computeAreComments() const { - return _root && _root->isDiscussionPost(); +bool ChatWidget::computeAreComments() const { + return _repliesRoot && _repliesRoot->isDiscussionPost(); } -void RepliesWidget::setupComposeControls() { +void ChatWidget::setupComposeControls() { auto topicWriteRestrictions = rpl::single( ) | rpl::then(session().changes().topicUpdates( Data::TopicUpdate::Flag::Closed ) | rpl::filter([=](const Data::TopicUpdate &update) { return (update.topic->history() == _history) - && (update.topic->rootId() == _rootId); + && (update.topic->rootId() == _repliesRootId); }) | rpl::to_empty) | rpl::map([=] { const auto topic = _topic ? _topic - : _history->peer->forumTopicFor(_rootId); + : _peer->forumTopicFor(_repliesRootId); return (!topic || topic->canToggleClosed() || !topic->closed()) ? Data::SendError() : tr::lng_forum_topic_closed(tr::now); @@ -673,10 +692,12 @@ void RepliesWidget::setupComposeControls() { auto writeRestriction = rpl::combine( session().frozenValue(), session().changes().peerFlagsValue( - _history->peer, + _peer, Data::PeerUpdate::Flag::Rights), - Data::CanSendAnythingValue(_history->peer), - std::move(topicWriteRestrictions) + Data::CanSendAnythingValue(_peer), + (_repliesRootId + ? std::move(topicWriteRestrictions) + : (rpl::single(Data::SendError()) | rpl::type_erased())) ) | rpl::map([=]( const Main::FreezeInfo &info, auto, @@ -691,9 +712,9 @@ void RepliesWidget::setupComposeControls() { & ~ChatRestriction::SendPolls; const auto canSendAnything = _topic ? Data::CanSendAnyOf(_topic, allWithoutPolls) - : Data::CanSendAnyOf(_history->peer, allWithoutPolls); + : Data::CanSendAnyOf(_peer, allWithoutPolls); const auto restriction = Data::RestrictionError( - _history->peer, + _peer, ChatRestriction::SendOther); auto text = !canSendAnything ? (restriction @@ -716,8 +737,8 @@ void RepliesWidget::setupComposeControls() { .topicRootId = _topic ? _topic->rootId() : MsgId(0), .showSlowmodeError = [=] { return showSlowmodeError(); }, .sendActionFactory = [=] { return prepareSendAction({}); }, - .slowmodeSecondsLeft = SlowmodeSecondsLeft(_history->peer), - .sendDisabledBySlowmode = SendDisabledBySlowmode(_history->peer), + .slowmodeSecondsLeft = SlowmodeSecondsLeft(_peer), + .sendDisabledBySlowmode = SendDisabledBySlowmode(_peer), .writeRestriction = std::move(writeRestriction), }); @@ -872,7 +893,7 @@ void RepliesWidget::setupComposeControls() { _composeControls->finishAnimating(); - if (const auto channel = _history->peer->asChannel()) { + if (const auto channel = _peer->asChannel()) { channel->updateFull(); if (!channel->isBroadcast()) { rpl::combine( @@ -887,11 +908,11 @@ void RepliesWidget::setupComposeControls() { } } -void RepliesWidget::setupSwipeReplyAndBack() { +void ChatWidget::setupSwipeReplyAndBack() { const auto can = [=](not_null still) { const auto canSendReply = _topic ? Data::CanSendAnything(_topic) - : Data::CanSendAnything(_history->peer); + : Data::CanSendAnything(_peer); const auto allowInAnotherChat = still && still->allowsForward(); if (allowInAnotherChat && (_joinGroup || !canSendReply)) { return true; @@ -926,8 +947,8 @@ void RepliesWidget::setupSwipeReplyAndBack() { || (_gestureHorizontal.reachRatio != data.reachRatio); if (changed) { _gestureHorizontal = data; - const auto item = _history->peer->owner().message( - _history->peer->id, + const auto item = _peer->owner().message( + _peer->id, MsgId{ data.msgBareId }); if (item) { _history->owner().requestItemRepaint(item); @@ -985,11 +1006,11 @@ void RepliesWidget::setupSwipeReplyAndBack() { }); } -void RepliesWidget::chooseAttach( +void ChatWidget::chooseAttach( std::optional overrideSendImagesAsPhotos) { _choosingAttach = false; - if (const auto error = Data::AnyFileRestrictionError(_history->peer)) { - Data::ShowSendErrorToast(controller(), _history->peer, error); + if (const auto error = Data::AnyFileRestrictionError(_peer)) { + Data::ShowSendErrorToast(controller(), _peer, error); return; } else if (showSlowmodeError()) { return; @@ -1028,7 +1049,7 @@ void RepliesWidget::chooseAttach( }), nullptr); } -bool RepliesWidget::confirmSendingFiles( +bool ChatWidget::confirmSendingFiles( not_null data, std::optional overrideSendImagesAsPhotos, const QString &insertTextOnCancel) { @@ -1062,7 +1083,7 @@ bool RepliesWidget::confirmSendingFiles( return false; } -bool RepliesWidget::confirmSendingFiles( +bool ChatWidget::confirmSendingFiles( Ui::PreparedList &&list, const QString &insertTextOnCancel) { if (_composeControls->confirmMediaEdit(list)) { @@ -1075,7 +1096,7 @@ bool RepliesWidget::confirmSendingFiles( controller(), std::move(list), _composeControls->getTextWithAppliedMarkdown(), - _history->peer, + _peer, Api::SendType::Normal, sendMenuDetails()); @@ -1101,7 +1122,7 @@ bool RepliesWidget::confirmSendingFiles( return true; } -void RepliesWidget::sendingFilesConfirmed( +void ChatWidget::sendingFilesConfirmed( Ui::PreparedList &&list, Ui::SendFilesWay way, TextWithTags &&caption, @@ -1115,7 +1136,7 @@ void RepliesWidget::sendingFilesConfirmed( auto groups = DivideByGroups( std::move(list), way, - _history->peer->slowmodeApplied()); + _peer->slowmodeApplied()); auto bundle = PrepareFilesBundle( std::move(groups), way, @@ -1124,19 +1145,19 @@ void RepliesWidget::sendingFilesConfirmed( sendingFilesConfirmed(std::move(bundle), options); } -bool RepliesWidget::checkSendPayment( +bool ChatWidget::checkSendPayment( int messagesCount, int starsApproved, Fn withPaymentApproved) { return _sendPayment.check( controller(), - _history->peer, + _peer, messagesCount, starsApproved, std::move(withPaymentApproved)); } -void RepliesWidget::sendingFilesConfirmed( +void ChatWidget::sendingFilesConfirmed( std::shared_ptr bundle, Api::SendOptions options) { const auto withPaymentApproved = [=](int approved) { @@ -1180,7 +1201,7 @@ void RepliesWidget::sendingFilesConfirmed( finishSending(); } -bool RepliesWidget::confirmSendingFiles( +bool ChatWidget::confirmSendingFiles( QImage &&image, QByteArray &&content, std::optional overrideSendImagesAsPhotos, @@ -1197,14 +1218,14 @@ bool RepliesWidget::confirmSendingFiles( return confirmSendingFiles(std::move(list), insertTextOnCancel); } -bool RepliesWidget::showSlowmodeError() { +bool ChatWidget::showSlowmodeError() { const auto text = [&] { - if (const auto left = _history->peer->slowmodeSecondsLeft()) { + if (const auto left = _peer->slowmodeSecondsLeft()) { return tr::lng_slowmode_enabled( tr::now, lt_left, Ui::FormatDurationWordsSlowmode(left)); - } else if (_history->peer->slowmodeApplied()) { + } else if (_peer->slowmodeApplied()) { if (const auto item = _history->latestSendingMessage()) { showAtPosition(item->position()); return tr::lng_slowmode_no_many(tr::now); @@ -1219,13 +1240,15 @@ bool RepliesWidget::showSlowmodeError() { return true; } -void RepliesWidget::pushReplyReturn(not_null item) { - if (item->history() == _history && item->inThread(_rootId)) { - _cornerButtons.pushReplyReturn(item); +void ChatWidget::pushReplyReturn(not_null item) { + if (_repliesRootId) { + if (item->history() == _history && item->inThread(_repliesRootId)) { + _cornerButtons.pushReplyReturn(item); + } } } -void RepliesWidget::checkReplyReturns() { +void ChatWidget::checkReplyReturns() { const auto currentTop = _scroll->scrollTop(); while (const auto replyReturn = _cornerButtons.replyReturn()) { const auto position = replyReturn->position(); @@ -1241,26 +1264,26 @@ void RepliesWidget::checkReplyReturns() { } } -void RepliesWidget::uploadFile( +void ChatWidget::uploadFile( const QByteArray &fileContent, SendMediaType type) { session().api().sendFile(fileContent, type, prepareSendAction({})); } -bool RepliesWidget::showSendingFilesError( +bool ChatWidget::showSendingFilesError( const Ui::PreparedList &list) const { return showSendingFilesError(list, std::nullopt); } -bool RepliesWidget::showSendingFilesError( +bool ChatWidget::showSendingFilesError( const Ui::PreparedList &list, std::optional compress) const { const auto error = [&]() -> Data::SendError { - const auto peer = _history->peer; + const auto peer = _peer; const auto error = Data::FileRestrictionError(peer, list, compress); if (error) { return error; - } else if (const auto left = _history->peer->slowmodeSecondsLeft()) { + } else if (const auto left = _peer->slowmodeSecondsLeft()) { return tr::lng_slowmode_enabled( tr::now, lt_left, @@ -1288,11 +1311,11 @@ bool RepliesWidget::showSendingFilesError( return true; } - Data::ShowSendErrorToast(controller(), _history->peer, error); + Data::ShowSendErrorToast(controller(), _peer, error); return true; } -Api::SendAction RepliesWidget::prepareSendAction( +Api::SendAction ChatWidget::prepareSendAction( Api::SendOptions options) const { auto result = Api::SendAction(_history, options); result.replyTo = replyTo(); @@ -1300,14 +1323,14 @@ Api::SendAction RepliesWidget::prepareSendAction( return result; } -void RepliesWidget::send() { +void ChatWidget::send() { if (_composeControls->getTextWithAppliedMarkdown().text.isEmpty()) { return; } send({}); } -void RepliesWidget::sendVoice(const ComposeControls::VoiceToSend &data) { +void ChatWidget::sendVoice(const ComposeControls::VoiceToSend &data) { const auto withPaymentApproved = [=](int approved) { auto copy = data; copy.options.starsApproved = approved; @@ -1334,7 +1357,7 @@ void RepliesWidget::sendVoice(const ComposeControls::VoiceToSend &data) { finishSending(); } -void RepliesWidget::send(Api::SendOptions options) { +void ChatWidget::send(Api::SendOptions options) { if (!options.scheduled && showSlowmodeError()) { return; } @@ -1354,9 +1377,9 @@ void RepliesWidget::send(Api::SendOptions options) { .ignoreSlowmodeCountdown = (options.scheduled != 0), }; request.messagesCount = ComputeSendingMessagesCount(_history, request); - const auto error = GetErrorForSending(_history->peer, request); + const auto error = GetErrorForSending(_peer, request); if (error) { - Data::ShowSendErrorToast(controller(), _history->peer, error); + Data::ShowSendErrorToast(controller(), _peer, error); return; } if (!options.scheduled) { @@ -1376,11 +1399,13 @@ void RepliesWidget::send(Api::SendOptions options) { session().api().sendMessage(std::move(message)); _composeControls->clear(); - session().sendProgressManager().update( - _history, - _rootId, - Api::SendProgressType::Typing, - -1); + if (_repliesRootId) { + session().sendProgressManager().update( + _history, + _repliesRootId, + Api::SendProgressType::Typing, + -1); + } //_saveDraftText = true; //_saveDraftStart = crl::now(); @@ -1389,7 +1414,7 @@ void RepliesWidget::send(Api::SendOptions options) { finishSending(); } -void RepliesWidget::edit( +void ChatWidget::edit( not_null item, Api::SendOptions options, mtpRequestId *const saveEditMsgRequestId, @@ -1468,7 +1493,7 @@ void RepliesWidget::edit( doSetInnerFocus(); } -void RepliesWidget::refreshJoinGroupButton() { +void ChatWidget::refreshJoinGroupButton() { const auto set = [&](std::unique_ptr button) { if (!button && !_joinGroup) { return; @@ -1488,7 +1513,7 @@ void RepliesWidget::refreshJoinGroupButton() { listScrollTo(_scroll->scrollTopMax()); } }; - const auto channel = _history->peer->asChannel(); + const auto channel = _peer->asChannel(); const auto canSend = !channel->isForum() ? Data::CanSendAnything(channel) : (_topic && Data::CanSendAnything(_topic)); @@ -1512,15 +1537,15 @@ void RepliesWidget::refreshJoinGroupButton() { } } -bool RepliesWidget::sendExistingDocument( +bool ChatWidget::sendExistingDocument( not_null document, Api::MessageToSend messageToSend, std::optional localId) { const auto error = Data::RestrictionError( - _history->peer, + _peer, ChatRestriction::SendStickers); if (error) { - Data::ShowSendErrorToast(controller(), _history->peer, error); + Data::ShowSendErrorToast(controller(), _peer, error); return false; } else if (showSlowmodeError() || ShowSendPremiumError(controller(), document)) { @@ -1549,18 +1574,18 @@ bool RepliesWidget::sendExistingDocument( return true; } -void RepliesWidget::sendExistingPhoto(not_null photo) { +void ChatWidget::sendExistingPhoto(not_null photo) { sendExistingPhoto(photo, {}); } -bool RepliesWidget::sendExistingPhoto( +bool ChatWidget::sendExistingPhoto( not_null photo, Api::SendOptions options) { const auto error = Data::RestrictionError( - _history->peer, + _peer, ChatRestriction::SendPhotos); if (error) { - Data::ShowSendErrorToast(controller(), _history->peer, error); + Data::ShowSendErrorToast(controller(), _peer, error); return false; } else if (showSlowmodeError()) { return false; @@ -1588,11 +1613,11 @@ bool RepliesWidget::sendExistingPhoto( return true; } -void RepliesWidget::sendInlineResult( +void ChatWidget::sendInlineResult( std::shared_ptr result, not_null bot) { if (const auto error = result->getErrorOnSend(_history)) { - Data::ShowSendErrorToast(controller(), _history->peer, error); + Data::ShowSendErrorToast(controller(), _peer, error); return; } sendInlineResult(std::move(result), bot, {}, std::nullopt); @@ -1604,7 +1629,7 @@ void RepliesWidget::sendInlineResult( // Ui::LayerOption::KeepOther); } -void RepliesWidget::sendInlineResult( +void ChatWidget::sendInlineResult( std::shared_ptr result, not_null bot, Api::SendOptions options, @@ -1649,26 +1674,28 @@ void RepliesWidget::sendInlineResult( finishSending(); } -SendMenu::Details RepliesWidget::sendMenuDetails() const { +SendMenu::Details ChatWidget::sendMenuDetails() const { using Type = SendMenu::Type; - const auto type = (_topic && !_history->peer->starsPerMessageChecked()) + const auto type = (_topic && !_peer->starsPerMessageChecked()) ? Type::Scheduled : Type::SilentOnly; return SendMenu::Details{ .type = type }; } -FullReplyTo RepliesWidget::replyTo() const { +FullReplyTo ChatWidget::replyTo() const { if (auto custom = _composeControls->replyingToMessage()) { - custom.topicRootId = _rootId; + custom.topicRootId = _repliesRootId; return custom; } return FullReplyTo{ - .messageId = FullMsgId(_history->peer->id, _rootId), - .topicRootId = _rootId, + .messageId = (_repliesRootId + ? FullMsgId(_peer->id, _repliesRootId) + : FullMsgId()), + .topicRootId = _repliesRootId, }; } -void RepliesWidget::refreshTopBarActiveChat() { +void ChatWidget::refreshTopBarActiveChat() { using namespace Dialogs; const auto state = EntryState{ .key = (_topic ? Key{ _topic } : Key{ _history }), @@ -1680,13 +1707,13 @@ void RepliesWidget::refreshTopBarActiveChat() { controller()->setDialogsEntryState(state); } -void RepliesWidget::refreshUnreadCountBadge(std::optional count) { +void ChatWidget::refreshUnreadCountBadge(std::optional count) { if (count.has_value()) { _cornerButtons.updateJumpDownVisibility(count); } } -void RepliesWidget::updatePinnedViewer() { +void ChatWidget::updatePinnedViewer() { if (_scroll->isHidden() || !_topic || !_pinnedTracker) { return; } @@ -1704,7 +1731,7 @@ void RepliesWidget::updatePinnedViewer() { _pinnedClickedId = FullMsgId(); } if (_pinnedClickedId && !_minPinnedId) { - _minPinnedId = Data::ResolveMinPinnedId(_history->peer, _rootId); + _minPinnedId = Data::ResolveMinPinnedId(_peer, _repliesRootId); } if (_pinnedClickedId && _minPinnedId && _minPinnedId >= _pinnedClickedId) { // After click on the last pinned message we should the top one. @@ -1714,7 +1741,7 @@ void RepliesWidget::updatePinnedViewer() { } } -void RepliesWidget::checkLastPinnedClickedIdReset( +void ChatWidget::checkLastPinnedClickedIdReset( int wasScrollTop, int nowScrollTop) { if (_scroll->isHidden() || !_topic) { @@ -1728,7 +1755,7 @@ void RepliesWidget::checkLastPinnedClickedIdReset( } } -void RepliesWidget::setupTranslateBar() { +void ChatWidget::setupTranslateBar() { controller()->adaptive().oneColumnValue( ) | rpl::start_with_next([=, raw = _translateBar.get()](bool one) { raw->setShadowGeometryPostprocess([=](QRect geometry) { @@ -1751,7 +1778,7 @@ void RepliesWidget::setupTranslateBar() { _translateBar->finishAnimating(); } -void RepliesWidget::setupPinnedTracker() { +void ChatWidget::setupPinnedTracker() { Expects(_topic != nullptr); _pinnedTracker = std::make_unique(_topic); @@ -1761,7 +1788,7 @@ void RepliesWidget::setupPinnedTracker() { &_topic->session(), Storage::SharedMediaKey( _topic->channel()->id, - _rootId, + _repliesRootId, Storage::SharedMediaType::Pinned, ServerMaxMsgId - 1), 1, @@ -1772,13 +1799,13 @@ void RepliesWidget::setupPinnedTracker() { _topic->setHasPinnedMessages(*result.fullCount() != 0); if (result.skippedAfter() == 0) { auto &settings = _history->session().settings(); - const auto peerId = _history->peer->id; + const auto peerId = _peer->id; const auto hiddenId = settings.hiddenPinnedMessageId( peerId, - _rootId); + _repliesRootId); const auto last = result.size() ? result[result.size() - 1] : 0; if (hiddenId && hiddenId != last) { - settings.setHiddenPinnedMessageId(peerId, _rootId, 0); + settings.setHiddenPinnedMessageId(peerId, _repliesRootId, 0); _history->session().saveSettingsDelayed(); } } @@ -1786,17 +1813,18 @@ void RepliesWidget::setupPinnedTracker() { }, _topicLifetime); } -void RepliesWidget::checkPinnedBarState() { +void ChatWidget::checkPinnedBarState() { Expects(_pinnedTracker != nullptr); Expects(_inner != nullptr); - const auto peer = _history->peer; - const auto hiddenId = peer->canPinMessages() + const auto hiddenId = _peer->canPinMessages() ? MsgId(0) - : peer->session().settings().hiddenPinnedMessageId( - peer->id, - _rootId); - const auto currentPinnedId = Data::ResolveTopPinnedId(peer, _rootId); + : _peer->session().settings().hiddenPinnedMessageId( + _peer->id, + _repliesRootId); + const auto currentPinnedId = Data::ResolveTopPinnedId( + _peer, + _repliesRootId); const auto universalPinnedId = !currentPinnedId ? MsgId(0) : currentPinnedId.msg; @@ -1825,8 +1853,8 @@ void RepliesWidget::checkPinnedBarState() { Window::GifPauseReason::Any); }, controller()->gifPauseLevelChanged()); auto pinnedRefreshed = Info::Profile::SharedMediaCountValue( - _history->peer, - _rootId, + _peer, + _repliesRootId, nullptr, Storage::SharedMediaType::Pinned ) | rpl::distinct_until_changed( @@ -1855,7 +1883,7 @@ void RepliesWidget::checkPinnedBarState() { [bar = _pinnedBar.get()] { bar->customEmojiRepaint(); }), std::move(pinnedRefreshed), std::move(customButtonItem), - _rootVisible.value() + _repliesRootVisible.value() ) | rpl::map([=](Ui::MessageBarContent &&content, auto, auto, bool show) { const auto shown = !content.title.isEmpty() && !content.text.empty(); _shownPinnedItem = shown @@ -1910,7 +1938,7 @@ void RepliesWidget::checkPinnedBarState() { } } -void RepliesWidget::clearHidingPinnedBar() { +void ChatWidget::clearHidingPinnedBar() { if (!_hidingPinnedBar) { return; } @@ -1921,7 +1949,7 @@ void RepliesWidget::clearHidingPinnedBar() { _hidingPinnedBar = nullptr; } -void RepliesWidget::refreshPinnedBarButton(bool many, HistoryItem *item) { +void ChatWidget::refreshPinnedBarButton(bool many, HistoryItem *item) { if (!_pinnedBar) { return; // It can be in process of hiding. } @@ -1974,14 +2002,14 @@ void RepliesWidget::refreshPinnedBarButton(bool many, HistoryItem *item) { _pinnedBar->setRightButton(std::move(button)); } -void RepliesWidget::hidePinnedMessage() { +void ChatWidget::hidePinnedMessage() { Expects(_pinnedBar != nullptr); const auto id = _pinnedTracker->currentMessageId(); if (!id.message) { return; } - if (_history->peer->canPinMessages()) { + if (_peer->canPinMessages()) { Window::ToggleMessagePinned(controller(), id.message, false); } else { const auto callback = [=] { @@ -1991,30 +2019,30 @@ void RepliesWidget::hidePinnedMessage() { }; Window::HidePinnedBar( controller(), - _history->peer, - _rootId, + _peer, + _repliesRootId, crl::guard(this, callback)); } } -void RepliesWidget::cornerButtonsShowAtPosition( +void ChatWidget::cornerButtonsShowAtPosition( Data::MessagePosition position) { showAtPosition(position); } -Data::Thread *RepliesWidget::cornerButtonsThread() { +Data::Thread *ChatWidget::cornerButtonsThread() { return _topic ? static_cast(_topic) : _history; } -FullMsgId RepliesWidget::cornerButtonsCurrentId() { +FullMsgId ChatWidget::cornerButtonsCurrentId() { return _lastShownAt; } -bool RepliesWidget::cornerButtonsIgnoreVisibility() { +bool ChatWidget::cornerButtonsIgnoreVisibility() { return animatingShow(); } -std::optional RepliesWidget::cornerButtonsDownShown() { +std::optional ChatWidget::cornerButtonsDownShown() { if (_composeControls->isLockPresent() || _composeControls->isTTLButtonShown()) { return false; @@ -2028,25 +2056,25 @@ std::optional RepliesWidget::cornerButtonsDownShown() { return std::nullopt; } -bool RepliesWidget::cornerButtonsUnreadMayBeShown() { +bool ChatWidget::cornerButtonsUnreadMayBeShown() { return _loaded && !_composeControls->isLockPresent() && !_composeControls->isTTLButtonShown(); } -bool RepliesWidget::cornerButtonsHas(CornerButtonType type) { +bool ChatWidget::cornerButtonsHas(CornerButtonType type) { return _topic || (type == CornerButtonType::Down); } -void RepliesWidget::showAtStart() { +void ChatWidget::showAtStart() { showAtPosition(Data::MinMessagePosition); } -void RepliesWidget::showAtEnd() { +void ChatWidget::showAtEnd() { showAtPosition(Data::MaxMessagePosition); } -void RepliesWidget::finishSending() { +void ChatWidget::finishSending() { _composeControls->hidePanelsAnimated(); //if (_previewData && _previewData->pendingTill) previewCancel(); doSetInnerFocus(); @@ -2054,46 +2082,46 @@ void RepliesWidget::finishSending() { refreshTopBarActiveChat(); } -void RepliesWidget::showAtPosition( +void ChatWidget::showAtPosition( Data::MessagePosition position, FullMsgId originItemId) { showAtPosition(position, originItemId, {}); } -void RepliesWidget::showAtPosition( +void ChatWidget::showAtPosition( Data::MessagePosition position, FullMsgId originItemId, const Window::SectionShow ¶ms) { _lastShownAt = position.fullId; controller()->setActiveChatEntry(activeChat()); - const auto ignore = (position.fullId.msg == _rootId); + const auto ignore = (position.fullId.msg == _repliesRootId); _inner->showAtPosition( position, params, _cornerButtons.doneJumpFrom(position.fullId, originItemId, ignore)); } -void RepliesWidget::updateAdaptiveLayout() { +void ChatWidget::updateAdaptiveLayout() { _topBarShadow->moveToLeft( controller()->adaptive().isOneColumn() ? 0 : st::lineWidth, _topBar->height()); } -not_null RepliesWidget::history() const { +not_null ChatWidget::history() const { return _history; } -Dialogs::RowDescriptor RepliesWidget::activeChat() const { +Dialogs::RowDescriptor ChatWidget::activeChat() const { const auto messageId = _lastShownAt ? _lastShownAt - : FullMsgId(_history->peer->id, ShowAtUnreadMsgId); + : FullMsgId(_peer->id, ShowAtUnreadMsgId); if (_topic) { return { _topic, messageId }; } return { _history, messageId }; } -bool RepliesWidget::preventsClose(Fn &&continueCallback) const { +bool ChatWidget::preventsClose(Fn &&continueCallback) const { if (_composeControls->preventsClose(base::duplicate(continueCallback))) { return true; } else if (!_newTopicDiscarded @@ -2120,7 +2148,7 @@ bool RepliesWidget::preventsClose(Fn &&continueCallback) const { return false; } -QPixmap RepliesWidget::grabForShowAnimation(const Window::SectionSlideParams ¶ms) { +QPixmap ChatWidget::grabForShowAnimation(const Window::SectionSlideParams ¶ms) { _topBar->updateControlsVisibility(); if (params.withTopBarShadow) _topBarShadow->hide(); if (_joinGroup) { @@ -2132,8 +2160,8 @@ QPixmap RepliesWidget::grabForShowAnimation(const Window::SectionSlideParams &pa if (params.withTopBarShadow) { _topBarShadow->show(); } - if (_rootView) { - _rootView->hide(); + if (_repliesRootView) { + _repliesRootView->hide(); } if (_pinnedBar) { _pinnedBar->hide(); @@ -2142,11 +2170,11 @@ QPixmap RepliesWidget::grabForShowAnimation(const Window::SectionSlideParams &pa return result; } -void RepliesWidget::checkActivation() { +void ChatWidget::checkActivation() { _inner->checkActivation(); } -void RepliesWidget::doSetInnerFocus() { +void ChatWidget::doSetInnerFocus() { if (_composeSearch && _inner->getSelectedText().rich.text.isEmpty() && _inner->getSelectedItems().empty()) { @@ -2158,12 +2186,11 @@ void RepliesWidget::doSetInnerFocus() { } } -bool RepliesWidget::showInternal( +bool ChatWidget::showInternal( not_null memento, const Window::SectionShow ¶ms) { - if (auto logMemento = dynamic_cast(memento.get())) { - if (logMemento->getHistory() == history() - && logMemento->getRootId() == _rootId) { + if (auto logMemento = dynamic_cast(memento.get())) { + if (logMemento->id() == _id) { restoreState(logMemento); if (!logMemento->highlightId()) { showAtPosition(Data::UnreadMessagePosition); @@ -2178,15 +2205,15 @@ bool RepliesWidget::showInternal( return false; } -void RepliesWidget::setInternalState( +void ChatWidget::setInternalState( const QRect &geometry, - not_null memento) { + not_null memento) { setGeometry(geometry); Ui::SendPendingMoveResizeEvents(this); restoreState(memento); } -bool RepliesWidget::pushTabbedSelectorToThirdSection( +bool ChatWidget::pushTabbedSelectorToThirdSection( not_null thread, const Window::SectionShow ¶ms) { return _composeControls->pushTabbedSelectorToThirdSection( @@ -2194,26 +2221,31 @@ bool RepliesWidget::pushTabbedSelectorToThirdSection( params); } -bool RepliesWidget::returnTabbedSelector() { +bool ChatWidget::returnTabbedSelector() { return _composeControls->returnTabbedSelector(); } -std::shared_ptr RepliesWidget::createMemento() { - auto result = std::make_shared(history(), _rootId); +std::shared_ptr ChatWidget::createMemento() { + auto result = std::make_shared(_id); saveState(result.get()); return result; } -bool RepliesWidget::showMessage( +bool ChatWidget::showMessage( PeerId peerId, const Window::SectionShow ¶ms, MsgId messageId) { - if (peerId != _history->peer->id) { + if (peerId != _peer->id) { return false; } - const auto id = FullMsgId(_history->peer->id, messageId); + const auto id = FullMsgId(_peer->id, messageId); const auto message = _history->owner().message(id); - if (!message || (!message->inThread(_rootId) && id.msg != _rootId)) { + if (!message) { + return false; + } + if (_repliesRootId + && !message->inThread(_repliesRootId) + && id.msg != _repliesRootId) { return false; } const auto originMessage = [&]() -> HistoryItem* { @@ -2222,7 +2254,8 @@ bool RepliesWidget::showMessage( if (const auto returnTo = session().data().message(origin->id)) { if (returnTo->history() != _history) { return nullptr; - } else if (returnTo->inThread(_rootId)) { + } else if (_repliesRootId + && returnTo->inThread(_repliesRootId)) { return returnTo; } } @@ -2239,24 +2272,24 @@ bool RepliesWidget::showMessage( return true; } -Window::SectionActionResult RepliesWidget::sendBotCommand( +Window::SectionActionResult ChatWidget::sendBotCommand( Bot::SendCommandRequest request) { - if (request.peer != _history->peer) { + if (request.peer != _peer) { return Window::SectionActionResult::Ignore; } listSendBotCommand(request.command, request.context); return Window::SectionActionResult::Handle; } -bool RepliesWidget::confirmSendingFiles(const QStringList &files) { +bool ChatWidget::confirmSendingFiles(const QStringList &files) { return confirmSendingFiles(files, QString()); } -bool RepliesWidget::confirmSendingFiles(not_null data) { +bool ChatWidget::confirmSendingFiles(not_null data) { return confirmSendingFiles(data, std::nullopt); } -bool RepliesWidget::confirmSendingFiles( +bool ChatWidget::confirmSendingFiles( const QStringList &files, const QString &insertTextOnCancel) { const auto premium = controller()->session().user()->isPremium(); @@ -2265,28 +2298,31 @@ bool RepliesWidget::confirmSendingFiles( insertTextOnCancel); } -void RepliesWidget::replyToMessage(FullReplyTo id) { +void ChatWidget::replyToMessage(FullReplyTo id) { _composeControls->replyToMessage(std::move(id)); refreshTopBarActiveChat(); } -void RepliesWidget::saveState(not_null memento) { +void ChatWidget::saveState(not_null memento) { memento->setReplies(_replies); memento->setReplyReturns(_cornerButtons.replyReturns()); _inner->saveState(memento->list()); } -void RepliesWidget::refreshReplies() { +void ChatWidget::refreshReplies() { + if (!_repliesRootId) { + return; + } auto old = base::take(_replies); setReplies(_topic ? _topic->replies() - : std::make_shared(_history, _rootId)); + : std::make_shared(_history, _repliesRootId)); if (old) { _inner->refreshViewer(); } } -void RepliesWidget::setReplies(std::shared_ptr replies) { +void ChatWidget::setReplies(std::shared_ptr replies) { _replies = std::move(replies); _repliesLifetime.destroy(); @@ -2329,7 +2365,7 @@ void RepliesWidget::setReplies(std::shared_ptr replies) { }, _repliesLifetime); } -void RepliesWidget::restoreState(not_null memento) { +void ChatWidget::restoreState(not_null memento) { if (auto replies = memento->getReplies()) { setReplies(std::move(replies)); } else if (!_replies) { @@ -2344,13 +2380,13 @@ void RepliesWidget::restoreState(not_null memento) { params.highlightPart = memento->highlightPart(); params.highlightPartOffsetHint = memento->highlightPartOffsetHint(); showAtPosition(Data::MessagePosition{ - .fullId = FullMsgId(_history->peer->id, highlight), + .fullId = FullMsgId(_peer->id, highlight), .date = TimeId(0), }, {}, params); } } -void RepliesWidget::resizeEvent(QResizeEvent *e) { +void ChatWidget::resizeEvent(QResizeEvent *e) { if (!width() || !height()) { return; } @@ -2359,14 +2395,14 @@ void RepliesWidget::resizeEvent(QResizeEvent *e) { updateControlsGeometry(); } -void RepliesWidget::recountChatWidth() { +void ChatWidget::recountChatWidth() { auto layout = (width() < st::adaptiveChatWideWidth) ? Window::Adaptive::ChatLayout::Normal : Window::Adaptive::ChatLayout::Wide; controller()->adaptive().setChatLayout(layout); } -void RepliesWidget::updateControlsGeometry() { +void ChatWidget::updateControlsGeometry() { const auto contentWidth = width(); const auto newScrollTop = _scroll->isHidden() @@ -2378,10 +2414,10 @@ void RepliesWidget::updateControlsGeometry() { : 0; _topBar->resizeToWidth(contentWidth); _topBarShadow->resize(contentWidth, st::lineWidth); - if (_rootView) { - _rootView->resizeToWidth(contentWidth); + if (_repliesRootView) { + _repliesRootView->resizeToWidth(contentWidth); } - auto top = _topBar->height() + _rootViewHeight; + auto top = _topBar->height() + _repliesRootViewHeight; if (_pinnedBar) { _pinnedBar->move(0, top); _pinnedBar->resizeToWidth(contentWidth); @@ -2427,7 +2463,7 @@ void RepliesWidget::updateControlsGeometry() { _cornerButtons.updatePositions(); } -void RepliesWidget::paintEvent(QPaintEvent *e) { +void ChatWidget::paintEvent(QPaintEvent *e) { if (animatingShow()) { SectionWidget::paintEvent(e); return; @@ -2441,20 +2477,20 @@ void RepliesWidget::paintEvent(QPaintEvent *e) { SectionWidget::PaintBackground(controller(), _theme.get(), this, bg); } -bool RepliesWidget::emptyShown() const { +bool ChatWidget::emptyShown() const { return _topic && (_inner->isEmpty() - || (_topic->lastKnownServerMessageId() == _rootId)); + || (_topic->lastKnownServerMessageId() == _repliesRootId)); } -void RepliesWidget::onScroll() { +void ChatWidget::onScroll() { if (_skipScrollEvent) { return; } updateInnerVisibleArea(); } -void RepliesWidget::updateInnerVisibleArea() { +void ChatWidget::updateInnerVisibleArea() { if (!_inner->animatedScrolling()) { checkReplyReturns(); } @@ -2472,18 +2508,18 @@ void RepliesWidget::updateInnerVisibleArea() { } } -void RepliesWidget::updatePinnedVisibility() { - if (!_loaded) { +void ChatWidget::updatePinnedVisibility() { + if (!_loaded || !_repliesRootId) { return; - } else if (!_topic && (!_root || _root->isEmpty())) { - setPinnedVisibility(!_root); + } else if (!_topic && (!_repliesRoot || _repliesRoot->isEmpty())) { + setPinnedVisibility(!_repliesRoot); return; } const auto rootItem = [&] { - if (const auto group = _history->owner().groups().find(_root)) { + if (const auto group = _history->owner().groups().find(_repliesRoot)) { return group->items.front().get(); } - return _root; + return _repliesRoot; }; const auto view = _inner->viewByPosition(_topic ? Data::MinMessagePosition @@ -2493,14 +2529,14 @@ void RepliesWidget::updatePinnedVisibility() { setPinnedVisibility(visible || (_topic && !view->data()->isPinned())); } -void RepliesWidget::setPinnedVisibility(bool shown) { - if (animatingShow()) { +void ChatWidget::setPinnedVisibility(bool shown) { + if (animatingShow() || !_repliesRootId) { return; } else if (!_topic) { - if (!_rootViewInitScheduled) { + if (!_repliesRootViewInitScheduled) { const auto height = shown ? st::historyReplyHeight : 0; - if (const auto delta = height - _rootViewHeight) { - _rootViewHeight = height; + if (const auto delta = height - _repliesRootViewHeight) { + _repliesRootViewHeight = height; if (_scroll->scrollTop() == _scroll->scrollTopMax()) { setGeometryWithTopMoved(geometry(), delta); } else { @@ -2508,22 +2544,22 @@ void RepliesWidget::setPinnedVisibility(bool shown) { } } } - _rootVisible = shown; - if (!_rootViewInited) { - _rootView->finishAnimating(); - if (!_rootViewInitScheduled) { - _rootViewInitScheduled = true; + _repliesRootVisible = shown; + if (!_repliesRootViewInited) { + _repliesRootView->finishAnimating(); + if (!_repliesRootViewInitScheduled) { + _repliesRootViewInitScheduled = true; InvokeQueued(this, [=] { - _rootViewInited = true; + _repliesRootViewInited = true; }); } } } else { - _rootVisible = shown; + _repliesRootVisible = shown; } } -void RepliesWidget::showAnimatedHook( +void ChatWidget::showAnimatedHook( const Window::SectionSlideParams ¶ms) { _topBar->setAnimatingMode(true); if (params.withTopBarShadow) { @@ -2532,7 +2568,7 @@ void RepliesWidget::showAnimatedHook( _composeControls->showStarted(); } -void RepliesWidget::showFinishedHook() { +void ChatWidget::showFinishedHook() { _topBar->setAnimatingMode(false); if (_joinGroup) { if (Ui::InFocusChain(this)) { @@ -2543,8 +2579,8 @@ void RepliesWidget::showFinishedHook() { _composeControls->showFinished(); } _inner->showFinished(); - if (_rootView) { - _rootView->show(); + if (_repliesRootView) { + _repliesRootView->show(); } if (_pinnedBar) { _pinnedBar->show(); @@ -2561,19 +2597,19 @@ void RepliesWidget::showFinishedHook() { updatePinnedVisibility(); } -bool RepliesWidget::floatPlayerHandleWheelEvent(QEvent *e) { +bool ChatWidget::floatPlayerHandleWheelEvent(QEvent *e) { return _scroll->viewportEvent(e); } -QRect RepliesWidget::floatPlayerAvailableRect() { +QRect ChatWidget::floatPlayerAvailableRect() { return mapToGlobal(_scroll->geometry()); } -Context RepliesWidget::listContext() { +Context ChatWidget::listContext() { return Context::Replies; } -bool RepliesWidget::listScrollTo(int top, bool syntetic) { +bool ChatWidget::listScrollTo(int top, bool syntetic) { top = std::clamp(top, 0, _scroll->scrollTopMax()); const auto scrolled = (_scroll->scrollTop() != top); _synteticScrollEvent = syntetic; @@ -2586,7 +2622,7 @@ bool RepliesWidget::listScrollTo(int top, bool syntetic) { return scrolled; } -void RepliesWidget::listCancelRequest() { +void ChatWidget::listCancelRequest() { if (_composeSearch) { if (_inner && (!_inner->getSelectedItems().empty() @@ -2607,15 +2643,15 @@ void RepliesWidget::listCancelRequest() { controller()->showBackFromStack(); } -void RepliesWidget::listDeleteRequest() { +void ChatWidget::listDeleteRequest() { confirmDeleteSelected(); } -void RepliesWidget::listTryProcessKeyInput(not_null e) { +void ChatWidget::listTryProcessKeyInput(not_null e) { _composeControls->tryProcessKeyInput(e); } -rpl::producer RepliesWidget::listSource( +rpl::producer ChatWidget::listSource( Data::MessagePosition aroundId, int limitBefore, int limitAfter) { @@ -2633,22 +2669,22 @@ rpl::producer RepliesWidget::listSource( }); } -bool RepliesWidget::listAllowsMultiSelect() { +bool ChatWidget::listAllowsMultiSelect() { return true; } -bool RepliesWidget::listIsItemGoodForSelection( +bool ChatWidget::listIsItemGoodForSelection( not_null item) { return item->isRegular() && !item->isService(); } -bool RepliesWidget::listIsLessInOrder( +bool ChatWidget::listIsLessInOrder( not_null first, not_null second) { return first->position() < second->position(); } -void RepliesWidget::listSelectionChanged(SelectedItems &&items) { +void ChatWidget::listSelectionChanged(SelectedItems &&items) { HistoryView::TopBarWidget::SelectedState state; state.count = items.size(); for (const auto &item : items) { @@ -2668,16 +2704,16 @@ void RepliesWidget::listSelectionChanged(SelectedItems &&items) { } } -void RepliesWidget::listMarkReadTill(not_null item) { +void ChatWidget::listMarkReadTill(not_null item) { _replies->readTill(item); } -void RepliesWidget::listMarkContentsRead( +void ChatWidget::listMarkContentsRead( const base::flat_set> &items) { session().api().markContentsRead(items); } -MessagesBarData RepliesWidget::listMessagesBar( +MessagesBarData ChatWidget::listMessagesBar( const std::vector> &elements) { if (elements.empty()) { return {}; @@ -2704,10 +2740,10 @@ MessagesBarData RepliesWidget::listMessagesBar( return {}; } -void RepliesWidget::listContentRefreshed() { +void ChatWidget::listContentRefreshed() { } -void RepliesWidget::listUpdateDateLink( +void ChatWidget::listUpdateDateLink( ClickHandlerPtr &link, not_null view) { if (!_topic) { @@ -2722,17 +2758,17 @@ void RepliesWidget::listUpdateDateLink( } } -bool RepliesWidget::listElementHideReply(not_null view) { +bool ChatWidget::listElementHideReply(not_null view) { if (const auto reply = view->data()->Get()) { const auto replyToPeerId = reply->externalPeerId() ? reply->externalPeerId() - : _history->peer->id; + : _peer->id; if (reply->fields().manualQuote) { return false; - } else if (replyToPeerId == _history->peer->id) { - return (reply->messageId() == _rootId); - } else if (_root) { - const auto forwarded = _root->Get(); + } else if (replyToPeerId == _peer->id) { + return (_repliesRootId && reply->messageId() == _repliesRootId); + } else if (const auto root = _repliesRoot) { + const auto forwarded = root->Get(); if (forwarded && forwarded->savedFromPeer && forwarded->savedFromPeer->id == replyToPeerId @@ -2744,22 +2780,22 @@ bool RepliesWidget::listElementHideReply(not_null view) { return false; } -bool RepliesWidget::listElementShownUnread(not_null view) { +bool ChatWidget::listElementShownUnread(not_null view) { return _replies->isServerSideUnread(view->data()); } -bool RepliesWidget::listIsGoodForAroundPosition( +bool ChatWidget::listIsGoodForAroundPosition( not_null view) { return view->data()->isRegular(); } -void RepliesWidget::listSendBotCommand( +void ChatWidget::listSendBotCommand( const QString &command, const FullMsgId &context) { sendBotCommandWithOptions(command, context, {}); } -void RepliesWidget::sendBotCommandWithOptions( +void ChatWidget::sendBotCommandWithOptions( const QString &command, const FullMsgId &context, Api::SendOptions options) { @@ -2777,7 +2813,7 @@ void RepliesWidget::sendBotCommandWithOptions( } const auto text = Bot::WrapCommandInChat( - _history->peer, + _peer, command, context); auto message = Api::MessageToSend(prepareSendAction(options)); @@ -2786,40 +2822,40 @@ void RepliesWidget::sendBotCommandWithOptions( finishSending(); } -void RepliesWidget::listSearch( +void ChatWidget::listSearch( const QString &query, const FullMsgId &context) { controller()->searchMessages(query, _history); } -void RepliesWidget::listHandleViaClick(not_null bot) { +void ChatWidget::listHandleViaClick(not_null bot) { _composeControls->setText({ '@' + bot->username() + ' ' }); } -not_null RepliesWidget::listChatTheme() { +not_null ChatWidget::listChatTheme() { return _theme.get(); } -CopyRestrictionType RepliesWidget::listCopyRestrictionType( +CopyRestrictionType ChatWidget::listCopyRestrictionType( HistoryItem *item) { - return CopyRestrictionTypeFor(_history->peer, item); + return CopyRestrictionTypeFor(_peer, item); } -CopyRestrictionType RepliesWidget::listCopyMediaRestrictionType( +CopyRestrictionType ChatWidget::listCopyMediaRestrictionType( not_null item) { - return CopyMediaRestrictionTypeFor(_history->peer, item); + return CopyMediaRestrictionTypeFor(_peer, item); } -CopyRestrictionType RepliesWidget::listSelectRestrictionType() { - return SelectRestrictionTypeFor(_history->peer); +CopyRestrictionType ChatWidget::listSelectRestrictionType() { + return SelectRestrictionTypeFor(_peer); } -auto RepliesWidget::listAllowedReactionsValue() +auto ChatWidget::listAllowedReactionsValue() -> rpl::producer { - return Data::PeerAllowedReactionsValue(_history->peer); + return Data::PeerAllowedReactionsValue(_peer); } -void RepliesWidget::listShowPremiumToast(not_null document) { +void ChatWidget::listShowPremiumToast(not_null document) { if (!_stickerToast) { _stickerToast = std::make_unique( controller(), @@ -2829,23 +2865,23 @@ void RepliesWidget::listShowPremiumToast(not_null document) { _stickerToast->showFor(document); } -void RepliesWidget::listOpenPhoto( +void ChatWidget::listOpenPhoto( not_null photo, FullMsgId context) { - controller()->openPhoto(photo, { context, _rootId }); + controller()->openPhoto(photo, { context, _repliesRootId }); } -void RepliesWidget::listOpenDocument( +void ChatWidget::listOpenDocument( not_null document, FullMsgId context, bool showInMediaView) { controller()->openDocument( document, showInMediaView, - { context, _rootId }); + { context, _repliesRootId }); } -void RepliesWidget::listPaintEmpty( +void ChatWidget::listPaintEmpty( Painter &p, const Ui::ChatPaintContext &context) { if (!emptyShown()) { @@ -2856,29 +2892,29 @@ void RepliesWidget::listPaintEmpty( _emptyPainter->paint(p, context.st, width(), _scroll->height()); } -QString RepliesWidget::listElementAuthorRank(not_null view) { +QString ChatWidget::listElementAuthorRank(not_null view) { return (_topic && view->data()->from()->id == _topic->creatorId()) ? tr::lng_topic_author_badge(tr::now) : QString(); } -bool RepliesWidget::listElementHideTopicButton( +bool ChatWidget::listElementHideTopicButton( not_null view) { return true; } -History *RepliesWidget::listTranslateHistory() { +History *ChatWidget::listTranslateHistory() { return _history; } -void RepliesWidget::listAddTranslatedItems( +void ChatWidget::listAddTranslatedItems( not_null tracker) { if (_shownPinnedItem) { tracker->add(_shownPinnedItem); } } -Ui::ChatPaintContext RepliesWidget::listPreparePaintContext( +Ui::ChatPaintContext ChatWidget::listPreparePaintContext( Ui::ChatPaintContextArgs &&args) { auto context = WindowListDelegate::listPreparePaintContext( std::move(args)); @@ -2886,7 +2922,7 @@ Ui::ChatPaintContext RepliesWidget::listPreparePaintContext( return context; } -base::unique_qptr RepliesWidget::listFillSenderUserpicMenu( +base::unique_qptr ChatWidget::listFillSenderUserpicMenu( PeerId userpicPeerId) { const auto searchInEntry = _topic ? Dialogs::Key(_topic) @@ -2903,7 +2939,7 @@ base::unique_qptr RepliesWidget::listFillSenderUserpicMenu( return menu->empty() ? nullptr : std::move(menu); } -void RepliesWidget::setupEmptyPainter() { +void ChatWidget::setupEmptyPainter() { Expects(_topic != nullptr); _emptyPainter = std::make_unique(_topic, [=] { @@ -2918,27 +2954,26 @@ void RepliesWidget::setupEmptyPainter() { }); } -void RepliesWidget::confirmDeleteSelected() { +void ChatWidget::confirmDeleteSelected() { ConfirmDeleteSelectedItems(_inner); } -void RepliesWidget::confirmForwardSelected() { +void ChatWidget::confirmForwardSelected() { ConfirmForwardSelectedItems(_inner); } -void RepliesWidget::clearSelected() { +void ChatWidget::clearSelected() { _inner->cancelSelection(); } -void RepliesWidget::setupDragArea() { +void ChatWidget::setupDragArea() { const auto filter = [=](const auto &d) { if (!_history || _composeControls->isRecording()) { return false; } - const auto peer = _history->peer; return _topic ? Data::CanSendAnyOf(_topic, Data::FilesSendRestrictions()) - : Data::CanSendAnyOf(peer, Data::FilesSendRestrictions()); + : Data::CanSendAnyOf(_peer, Data::FilesSendRestrictions()); }; const auto areas = DragArea::SetupDragAreaToContainer( this, @@ -2956,7 +2991,7 @@ void RepliesWidget::setupDragArea() { areas.photo->setDroppedCallback(droppedCallback(true)); } -void RepliesWidget::setupShortcuts() { +void ChatWidget::setupShortcuts() { Shortcuts::Requests( ) | rpl::filter([=] { return Ui::AppInFocus() @@ -2974,7 +3009,7 @@ void RepliesWidget::setupShortcuts() { }, lifetime()); } -void RepliesWidget::searchInTopic() { +void ChatWidget::searchInTopic() { if (_topic) { controller()->searchInChat(_topic); } else { @@ -2992,7 +3027,7 @@ void RepliesWidget::searchInTopic() { controller(), _history, from); - _composeSearch->setTopMsgId(_rootId); + _composeSearch->setTopMsgId(_repliesRootId); update(); doSetInnerFocus(); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.h b/Telegram/SourceFiles/history/view/history_view_chat_section.h similarity index 92% rename from Telegram/SourceFiles/history/view/history_view_replies_section.h rename to Telegram/SourceFiles/history/view/history_view_chat_section.h index 3bbe7f5c59..f66391d801 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.h +++ b/Telegram/SourceFiles/history/view/history_view_chat_section.h @@ -64,7 +64,7 @@ struct VoiceToSend; class Element; class TopBarWidget; -class RepliesMemento; +class ChatMemento; class ComposeControls; class ComposeSearch; class SendActionPainter; @@ -74,17 +74,24 @@ class EmptyPainter; class PinnedTracker; class TranslateBar; -class RepliesWidget final +struct ChatViewId { + not_null history; + MsgId repliesRootId; + Data::SavedSublist *sublist = nullptr; + + friend inline bool operator==(ChatViewId, ChatViewId) = default; +}; + +class ChatWidget final : public Window::SectionWidget , private WindowListDelegate , private CornerButtonsDelegate { public: - RepliesWidget( + ChatWidget( QWidget *parent, not_null controller, - not_null history, - MsgId rootId); - ~RepliesWidget(); + ChatViewId id); + ~ChatWidget(); [[nodiscard]] not_null history() const; Dialogs::RowDescriptor activeChat() const override; @@ -114,7 +121,7 @@ public: void setInternalState( const QRect &geometry, - not_null memento); + not_null memento); // Tabbed selector management. bool pushTabbedSelectorToThirdSection( @@ -218,8 +225,8 @@ private: void updateInnerVisibleArea(); void updateControlsGeometry(); void updateAdaptiveLayout(); - void saveState(not_null memento); - void restoreState(not_null memento); + void saveState(not_null memento); + void restoreState(not_null memento); void setReplies(std::shared_ptr replies); void refreshReplies(); void showAtStart(); @@ -267,7 +274,7 @@ private: void chooseAttach(std::optional overrideSendImagesAsPhotos); [[nodiscard]] SendMenu::Details sendMenuDetails() const; [[nodiscard]] FullReplyTo replyTo() const; - [[nodiscard]] HistoryItem *lookupRoot() const; + [[nodiscard]] HistoryItem *lookupRepliesRoot() const; [[nodiscard]] Data::ForumTopic *lookupTopic(); [[nodiscard]] bool computeAreComments() const; void orderWidgets(); @@ -347,16 +354,21 @@ private: [[nodiscard]] bool showSlowmodeError(); const not_null _history; - MsgId _rootId = 0; - std::shared_ptr _theme; - HistoryItem *_root = nullptr; + const not_null _peer; + ChatViewId _id; + + MsgId _repliesRootId = 0; + HistoryItem *_repliesRoot = nullptr; Data::ForumTopic *_topic = nullptr; mutable bool _newTopicDiscarded = false; - std::shared_ptr _replies; rpl::lifetime _repliesLifetime; rpl::variable _areComments = false; + + Data::SavedSublist *_sublist = nullptr; + std::shared_ptr _sendAction; + std::shared_ptr _theme; QPointer _inner; object_ptr _topBar; object_ptr _topBarShadow; @@ -380,11 +392,11 @@ private: std::optional _minPinnedId; HistoryItem *_shownPinnedItem = nullptr; - std::unique_ptr _rootView; - int _rootViewHeight = 0; - bool _rootViewInited = false; - bool _rootViewInitScheduled = false; - rpl::variable _rootVisible = false; + std::unique_ptr _repliesRootView; + int _repliesRootViewHeight = 0; + bool _repliesRootViewInited = false; + bool _repliesRootViewInitScheduled = false; + rpl::variable _repliesRootVisible = false; std::unique_ptr _scroll; std::unique_ptr _stickerToast; @@ -408,15 +420,18 @@ private: }; -class RepliesMemento final : public Window::SectionMemento { +class ChatMemento final : public Window::SectionMemento { public: - RepliesMemento( - not_null history, - MsgId rootId, + explicit ChatMemento( + ChatViewId id, MsgId highlightId = 0, const TextWithEntities &highlightPart = {}, int highlightPartOffsetHint = 0); - explicit RepliesMemento( + + struct Comments { + }; + explicit ChatMemento( + Comments, not_null commentsItem, MsgId commentId = 0); @@ -431,11 +446,8 @@ public: Window::Column column, const QRect &geometry) override; - [[nodiscard]] not_null getHistory() const { - return _history; - } - [[nodiscard]] MsgId getRootId() const { - return _rootId; + [[nodiscard]] ChatViewId id() const { + return _id; } void setReplies(std::shared_ptr replies) { @@ -472,8 +484,7 @@ public: private: void setupTopicViewer(); - const not_null _history; - MsgId _rootId = 0; + ChatViewId _id; const TextWithEntities _highlightPart; const int _highlightPartOffsetHint = 0; const MsgId _highlightId = 0; diff --git a/Telegram/SourceFiles/window/notifications_manager.cpp b/Telegram/SourceFiles/window/notifications_manager.cpp index 3f312386bb..f34c3a1084 100644 --- a/Telegram/SourceFiles/window/notifications_manager.cpp +++ b/Telegram/SourceFiles/window/notifications_manager.cpp @@ -16,7 +16,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "mtproto/mtproto_config.h" #include "history/history.h" #include "history/history_item_components.h" -#include "history/view/history_view_replies_section.h" +#include "history/view/history_view_chat_section.h" #include "lang/lang_keys.h" #include "data/notify/data_notify_settings.h" #include "data/stickers/data_custom_emoji.h" @@ -1221,11 +1221,12 @@ Window::SessionController *Manager::openNotificationMessage( if (window) { window->widget()->showFromTray(); if (topic) { + using namespace HistoryView; window->showSection( - std::make_shared( - history, - topic->rootId(), - itemId), + std::make_shared(ChatViewId{ + .history = history, + .repliesRootId = topic->rootId(), + }, itemId), SectionShow::Way::Forward); } else { window->showPeerHistory( diff --git a/Telegram/SourceFiles/window/window_session_controller.cpp b/Telegram/SourceFiles/window/window_session_controller.cpp index 2d9af18ff0..d8950d56c5 100644 --- a/Telegram/SourceFiles/window/window_session_controller.cpp +++ b/Telegram/SourceFiles/window/window_session_controller.cpp @@ -25,7 +25,7 @@ https://github.com/telegramdesktop/tdesktop/blob/master/LEGAL #include "history/history_item.h" #include "history/view/reactions/history_view_reactions.h" //#include "history/view/reactions/history_view_reactions_button.h" -#include "history/view/history_view_replies_section.h" +#include "history/view/history_view_chat_section.h" #include "history/view/history_view_scheduled_section.h" #include "history/view/history_view_sublist_section.h" #include "media/player/media_player_instance.h" @@ -1140,9 +1140,12 @@ void SessionNavigation::showRepliesForMessage( if (const auto topic = history->peer->forumTopicFor(rootId)) { auto replies = topic->replies(); if (replies->unreadCountKnown()) { - auto memento = std::make_shared( - history, - rootId, + using namespace HistoryView; + auto memento = std::make_shared( + ChatViewId{ + .history = history, + .repliesRootId = rootId, + }, commentId, params.highlightPart, params.highlightPartOffsetHint); @@ -1156,7 +1159,7 @@ void SessionNavigation::showRepliesForMessage( && _showingRepliesRootId == rootId) { return; } else if (!history->peer->asChannel()) { - // HistoryView::RepliesWidget right now handles only channels. + // HistoryView::ChatWidget replies right now handles only channels. return; } _api.request(base::take(_showingRepliesRequestId)).cancel(); @@ -1211,14 +1214,16 @@ void SessionNavigation::showRepliesForMessage( } } if (deleted || item) { + using namespace HistoryView; auto memento = item - ? std::make_shared( + ? std::make_shared( + ChatMemento::Comments(), item, commentId) - : std::make_shared( - history, - rootId, - commentId); + : std::make_shared(ChatViewId{ + .history = history, + .repliesRootId = rootId, + }, commentId); memento->setReadInformation( data.vread_inbox_max_id().value_or_empty(), data.vunread_count().v,