From bb76818cc8bf2e5af35ea68ca5cff288036b20db Mon Sep 17 00:00:00 2001 From: 23rd <23rd@vivaldi.net> Date: Thu, 24 Jun 2021 08:33:52 +0300 Subject: [PATCH] Split adaptive changed rpl::producer into two. --- Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp | 2 +- Telegram/SourceFiles/core/core_settings.h | 3 +++ Telegram/SourceFiles/dialogs/dialogs_widget.cpp | 2 +- .../history/admin_log/history_admin_log_section.cpp | 5 +---- Telegram/SourceFiles/history/history_widget.cpp | 2 +- .../history/view/history_view_pinned_section.cpp | 5 +---- .../history/view/history_view_replies_section.cpp | 5 +---- .../history/view/history_view_scheduled_section.cpp | 5 +---- .../history/view/history_view_top_bar_widget.cpp | 2 +- Telegram/SourceFiles/mainwidget.cpp | 2 +- Telegram/SourceFiles/window/window_adaptive.cpp | 9 ++++++++- Telegram/SourceFiles/window/window_adaptive.h | 3 ++- 12 files changed, 22 insertions(+), 23 deletions(-) diff --git a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp index fed9f200e..7a00ccb87 100644 --- a/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp +++ b/Telegram/SourceFiles/chat_helpers/field_autocomplete.cpp @@ -744,7 +744,7 @@ FieldAutocomplete::Inner::Inner( update(); }, lifetime()); - controller->adaptive().changed( + controller->adaptive().value( ) | rpl::start_with_next([=] { _isOneColumn = controller->adaptive().isOneColumn(); update(); diff --git a/Telegram/SourceFiles/core/core_settings.h b/Telegram/SourceFiles/core/core_settings.h index 1eedd7592..881060db3 100644 --- a/Telegram/SourceFiles/core/core_settings.h +++ b/Telegram/SourceFiles/core/core_settings.h @@ -95,6 +95,9 @@ public: [[nodiscard]] rpl::producer adaptiveForWideValue() const { return _adaptiveForWide.value(); } + [[nodiscard]] rpl::producer adaptiveForWideChanges() const { + return _adaptiveForWide.changes(); + } void setAdaptiveForWide(bool value) { _adaptiveForWide = value; } diff --git a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp index cbf047583..bb62f9df8 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_widget.cpp @@ -266,7 +266,7 @@ Widget::Widget( }, lifetime()); } - controller->adaptive().changed( + controller->adaptive().changes( ) | rpl::start_with_next([=] { updateForwardBar(); }, lifetime()); diff --git a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp index e86f4b2bb..56086db7b 100644 --- a/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp +++ b/Telegram/SourceFiles/history/admin_log/history_admin_log_section.cpp @@ -298,10 +298,7 @@ Widget::Widget( _fixedBarShadow->raise(); - rpl::single( - rpl::empty_value() - ) | rpl::then( - controller->adaptive().changed() + controller->adaptive().value( ) | rpl::start_with_next([=] { updateAdaptiveLayout(); }, lifetime()); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 41ac9269b..91833a8f4 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -413,7 +413,7 @@ HistoryWidget::HistoryWidget( Window::ActivateWindow(controller); }); - controller->adaptive().changed( + controller->adaptive().changes( ) | rpl::start_with_next([=] { if (_history) { _history->forceFullResize(); diff --git a/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp b/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp index ba0782a7a..d5a2fc370 100644 --- a/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_pinned_section.cpp @@ -128,10 +128,7 @@ PinnedWidget::PinnedWidget( }, _topBar->lifetime()); _topBarShadow->raise(); - rpl::single( - rpl::empty_value() - ) | rpl::then( - controller->adaptive().changed() + controller->adaptive().value( ) | rpl::start_with_next([=] { updateAdaptiveLayout(); }, lifetime()); diff --git a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp index 6c1be95c1..468bb1382 100644 --- a/Telegram/SourceFiles/history/view/history_view_replies_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_replies_section.cpp @@ -193,10 +193,7 @@ RepliesWidget::RepliesWidget( _rootView->raise(); _topBarShadow->raise(); - rpl::single( - rpl::empty_value() - ) | rpl::then( - controller->adaptive().changed() + controller->adaptive().value( ) | rpl::start_with_next([=] { updateAdaptiveLayout(); }, lifetime()); diff --git a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp index ea8579d9b..bfdc92209 100644 --- a/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp +++ b/Telegram/SourceFiles/history/view/history_view_scheduled_section.cpp @@ -126,10 +126,7 @@ ScheduledWidget::ScheduledWidget( }, _topBar->lifetime()); _topBarShadow->raise(); - rpl::single( - rpl::empty_value() - ) | rpl::then( - controller->adaptive().changed() + controller->adaptive().value( ) | rpl::start_with_next([=] { updateAdaptiveLayout(); }, lifetime()); diff --git a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp index b78ec99ca..22775a663 100644 --- a/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/view/history_view_top_bar_widget.cpp @@ -117,7 +117,7 @@ TopBarWidget::TopBarWidget( _search->setForceRippled(searchInActiveChat, animated); }, lifetime()); - controller->adaptive().changed( + controller->adaptive().changes( ) | rpl::start_with_next([=] { updateAdaptiveLayout(); }, lifetime()); diff --git a/Telegram/SourceFiles/mainwidget.cpp b/Telegram/SourceFiles/mainwidget.cpp index a73f8233a..756cc7dca 100644 --- a/Telegram/SourceFiles/mainwidget.cpp +++ b/Telegram/SourceFiles/mainwidget.cpp @@ -380,7 +380,7 @@ MainWidget::MainWidget( } }); - _controller->adaptive().changed( + _controller->adaptive().changes( ) | rpl::start_with_next([=] { handleAdaptiveLayoutUpdate(); }, lifetime()); diff --git a/Telegram/SourceFiles/window/window_adaptive.cpp b/Telegram/SourceFiles/window/window_adaptive.cpp index 6e63d0fe0..784164db9 100644 --- a/Telegram/SourceFiles/window/window_adaptive.cpp +++ b/Telegram/SourceFiles/window/window_adaptive.cpp @@ -25,13 +25,20 @@ void Adaptive::setChatLayout(ChatLayout value) { _chatLayout = value; } -rpl::producer<> Adaptive::changed() const { +rpl::producer<> Adaptive::value() const { return rpl::merge( Core::App().settings().adaptiveForWideValue() | rpl::to_empty, _chatLayout.changes() | rpl::to_empty, _layout.changes() | rpl::to_empty); } +rpl::producer<> Adaptive::changes() const { + return rpl::merge( + Core::App().settings().adaptiveForWideChanges() | rpl::to_empty, + _chatLayout.changes() | rpl::to_empty, + _layout.changes() | rpl::to_empty); +} + rpl::producer Adaptive::oneColumnValue() const { return _layout.value( ) | rpl::map([=] { diff --git a/Telegram/SourceFiles/window/window_adaptive.h b/Telegram/SourceFiles/window/window_adaptive.h index 432ea9667..9a6421e31 100644 --- a/Telegram/SourceFiles/window/window_adaptive.h +++ b/Telegram/SourceFiles/window/window_adaptive.h @@ -27,7 +27,8 @@ public: void setWindowLayout(WindowLayout value); void setChatLayout(ChatLayout value); - [[nodiscard]] rpl::producer<> changed() const; + [[nodiscard]] rpl::producer<> value() const; + [[nodiscard]] rpl::producer<> changes() const; [[nodiscard]] rpl::producer oneColumnValue() const; [[nodiscard]] rpl::producer chatLayoutValue() const;