mirror of
https://github.com/AyuGram/AyuGramDesktop.git
synced 2026-08-08 04:34:05 +00:00
Fixed profile tab search closing while filtering.
This commit is contained in:
@@ -700,13 +700,30 @@ rpl::producer<Ui::ScrollToRequest> TabsHost::scrollToRequests() const {
|
||||
return _scrollToRequests.events();
|
||||
}
|
||||
|
||||
rpl::producer<TabTopBarBindings> TabsHost::activeTabBindings() const {
|
||||
rpl::producer<TabTopBarBindings> TabsHost::activeTabBindings() {
|
||||
return _activeTab.value(
|
||||
) | rpl::map([](MediaTabContent *tab) {
|
||||
return tab ? tab->topBarBindings() : TabTopBarBindings();
|
||||
) | rpl::map([=](MediaTabContent *tab) {
|
||||
_searching = false;
|
||||
auto result = tab ? tab->topBarBindings() : TabTopBarBindings();
|
||||
if (auto apply = base::take(result.applySearchQuery)) {
|
||||
result.applySearchQuery = crl::guard(this, [=](QString query) {
|
||||
_searching = !query.isEmpty();
|
||||
apply(query);
|
||||
if (_searching) {
|
||||
scrollToBodyTop();
|
||||
}
|
||||
});
|
||||
}
|
||||
return result;
|
||||
});
|
||||
}
|
||||
|
||||
void TabsHost::scrollToBodyTop() {
|
||||
if (_visibleTop >= 0) {
|
||||
_scrollToRequests.fire({ 0, -1 });
|
||||
}
|
||||
}
|
||||
|
||||
not_null<Ui::RpWidget*> TabsHost::stripWidget() const {
|
||||
return _strip;
|
||||
}
|
||||
@@ -765,7 +782,9 @@ int TabsHost::resizeGetHeight(int newWidth) {
|
||||
_body->moveToLeft(0, bodyTop);
|
||||
|
||||
const auto natural = bodyTop + _body->height();
|
||||
if (_keepMinHeight
|
||||
if (_searching && !_scrolledToTop && (natural < _visibleBottom)) {
|
||||
_keepMinHeight = std::max(_keepMinHeight, _visibleBottom);
|
||||
} else if (_keepMinHeight
|
||||
&& ((natural >= _keepMinHeight)
|
||||
|| (natural >= _visibleBottom)
|
||||
|| _scrolledToTop)) {
|
||||
|
||||
@@ -39,7 +39,7 @@ public:
|
||||
~TabsHost();
|
||||
|
||||
[[nodiscard]] rpl::producer<MediaTabContent*> activeTabValue() const;
|
||||
[[nodiscard]] rpl::producer<TabTopBarBindings> activeTabBindings() const;
|
||||
[[nodiscard]] rpl::producer<TabTopBarBindings> activeTabBindings();
|
||||
[[nodiscard]] rpl::producer<Ui::ScrollToRequest> scrollToRequests() const;
|
||||
|
||||
[[nodiscard]] not_null<Ui::RpWidget*> stripWidget() const;
|
||||
@@ -51,6 +51,9 @@ public:
|
||||
[[nodiscard]] QString activeId() const {
|
||||
return _activeId;
|
||||
}
|
||||
[[nodiscard]] bool searching() const {
|
||||
return _searching;
|
||||
}
|
||||
void activateTab(const QString &id, bool animated = true);
|
||||
void restoreActiveTab(const QString &id);
|
||||
|
||||
@@ -85,6 +88,7 @@ private:
|
||||
void scheduleHeightSync();
|
||||
void syncBodyNow();
|
||||
void syncHeightNow();
|
||||
void scrollToBodyTop();
|
||||
[[nodiscard]] QRect bodyVisibleRect() const;
|
||||
void startSlideAnimation(
|
||||
QPixmap wasCache,
|
||||
@@ -118,6 +122,7 @@ private:
|
||||
bool _bodySyncQueued = false;
|
||||
bool _heightSyncQueued = false;
|
||||
bool _scrolledToTop = true;
|
||||
bool _searching = false;
|
||||
int _keepMinHeight = 0;
|
||||
rpl::variable<MediaTabContent*> _activeTab = nullptr;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user