From 2c3190ce2ab0e461fc43f347fad44b71831a2b31 Mon Sep 17 00:00:00 2001 From: John Preston Date: Sun, 30 Dec 2018 11:34:17 +0400 Subject: [PATCH] Hide LoadMore button in search mode. --- .../SourceFiles/dialogs/dialogs_widget.cpp | 24 +++++++++---------- Telegram/SourceFiles/dialogs/dialogs_widget.h | 1 - 2 files changed, 11 insertions(+), 14 deletions(-) diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index 84d3bf75f6..323ac7bafb 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -453,7 +453,6 @@ void DialogsWidget::dialogsReceived( if (!_dialogsRequestId) { refreshLoadMoreButton(); } - refreshSupportFilteredResults(); Auth().data().moreChatsLoaded().notify(); if (_dialogsFull && _pinnedDialogsReceived) { @@ -462,15 +461,6 @@ void DialogsWidget::dialogsReceived( Auth().api().requestContacts(); } -void DialogsWidget::refreshSupportFilteredResults() { - if (!Auth().supportMode()) { - return; - } - const auto top = _scroll->scrollTop(); - applyFilterUpdate(true); - _scroll->scrollToY(top); -} - void DialogsWidget::updateDialogsOffset( const QVector &dialogs, const QVector &messages) { @@ -544,7 +534,9 @@ void DialogsWidget::refreshLoadMoreButton() { } void DialogsWidget::loadMoreBlockedByDateChats() { - if (!_loadMoreChats || _loadMoreChats->isDisabled()) { + if (!_loadMoreChats + || _loadMoreChats->isDisabled() + || _loadMoreChats->isHidden()) { return; } const auto max = Auth().settings().supportChatsTimeSlice(); @@ -1141,7 +1133,9 @@ void DialogsWidget::onListScroll() { } void DialogsWidget::applyFilterUpdate(bool force) { - if (_a_show.animating() && !force) return; + if (_a_show.animating() && !force) { + return; + } auto filterText = _filter->getLastText(); _inner->applyFilterUpdate(filterText, force); @@ -1149,6 +1143,10 @@ void DialogsWidget::applyFilterUpdate(bool force) { clearSearchCache(); } _cancelSearch->toggle(!filterText.isEmpty(), anim::type::normal); + if (_loadMoreChats) { + _loadMoreChats->setVisible(filterText.isEmpty()); + updateControlsGeometry(); + } updateJumpToDateVisibility(); if (filterText.isEmpty()) { @@ -1345,7 +1343,7 @@ void DialogsWidget::updateControlsGeometry() { auto newScrollTop = _scroll->scrollTop() + addToScroll; auto scrollHeight = height() - scrollTop; const auto putBottomButton = [&](object_ptr &button) { - if (button) { + if (button && !button->isHidden()) { const auto buttonHeight = button->height(); scrollHeight -= buttonHeight; button->setGeometry( diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.h b/Telegram/SourceFiles/dialogs/dialogs_widget.h index bbe9fb27cb..61306dfef6 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.h +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.h @@ -162,7 +162,6 @@ private: void checkUpdateStatus(); void applyFilterUpdate(bool force = false); - void refreshSupportFilteredResults(); bool loadingBlockedByDate() const; void refreshLoadMoreButton(); void loadMoreBlockedByDateChats();