diff --git a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp index 32d9e15f1..16fddacf8 100644 --- a/Telegram/SourceFiles/history/view/history_view_list_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_list_widget.cpp @@ -452,6 +452,7 @@ void ListWidget::refreshRows(const Data::MessagesSlice &old) { 1 ) - 1; + auto destroyingBarElement = _bar.element; _items.clear(); _items.reserve(_slice.ids.size()); auto nearestIndex = -1; @@ -460,9 +461,17 @@ void ListWidget::refreshRows(const Data::MessagesSlice &old) { if (_slice.nearestToAround == fullId) { nearestIndex = int(_items.size()); } - _items.push_back(enforceViewForItem(item)); + const auto view = enforceViewForItem(item); + _items.push_back(view); + if (destroyingBarElement == view) { + destroyingBarElement = nullptr; + } } } + if (destroyingBarElement) { + destroyingBarElement->destroyUnreadBar(); + _bar = {}; + } for (auto e = end(_items), i = e - addedToEndCount; i != e; ++i) { _itemRevealPending.emplace(*i); } diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index 762943c5d..e99748fae 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -164,13 +164,6 @@ void RepliesMemento::setReadInformation( } _replies->setInboxReadTill(inboxReadTillId, unreadCount); _replies->setOutboxReadTill(outboxReadTillId); - if (!_list.aroundPosition().fullId - && _replies->computeInboxReadTillFull() == MsgId(1)) { - _list.setAroundPosition(Data::MinMessagePosition); - _list.setScrollTopState(ListMemento::ScrollTopState{ - Data::MinMessagePosition - }); - } } object_ptr RepliesMemento::createWidget( @@ -181,6 +174,14 @@ object_ptr RepliesMemento::createWidget( if (column == Window::Column::Third) { return nullptr; } + if (!_list.aroundPosition().fullId + && _replies + && _replies->computeInboxReadTillFull() == MsgId(1)) { + _list.setAroundPosition(Data::MinMessagePosition); + _list.setScrollTopState(ListMemento::ScrollTopState{ + Data::MinMessagePosition + }); + } auto result = object_ptr( parent, controller, @@ -1886,6 +1887,9 @@ bool RepliesWidget::showInternal( if (logMemento->getHistory() == history() && logMemento->getRootId() == _rootId) { restoreState(logMemento); + if (!logMemento->getHighlightId()) { + showAtPosition(Data::UnreadMessagePosition); + } return true; } } @@ -2073,9 +2077,11 @@ void RepliesWidget::updateControlsGeometry() { const auto newScrollTop = _scroll->isHidden() ? std::nullopt - : base::make_optional(_scroll->scrollTop() + : _scroll->scrollTop() + ? base::make_optional(_scroll->scrollTop() + topDelta() - + _scrollTopDelta); + + _scrollTopDelta) + : 0; _topBar->resizeToWidth(contentWidth); _topBarShadow->resize(contentWidth, st::lineWidth); if (_rootView) {