Split adaptive changed rpl::producer into two.

This commit is contained in:
23rd 2021-06-24 08:33:52 +03:00 committed by John Preston
parent 5dcc219f1c
commit bb76818cc8
12 changed files with 22 additions and 23 deletions

View file

@ -744,7 +744,7 @@ FieldAutocomplete::Inner::Inner(
update();
}, lifetime());
controller->adaptive().changed(
controller->adaptive().value(
) | rpl::start_with_next([=] {
_isOneColumn = controller->adaptive().isOneColumn();
update();

View file

@ -95,6 +95,9 @@ public:
[[nodiscard]] rpl::producer<bool> adaptiveForWideValue() const {
return _adaptiveForWide.value();
}
[[nodiscard]] rpl::producer<bool> adaptiveForWideChanges() const {
return _adaptiveForWide.changes();
}
void setAdaptiveForWide(bool value) {
_adaptiveForWide = value;
}

View file

@ -266,7 +266,7 @@ Widget::Widget(
}, lifetime());
}
controller->adaptive().changed(
controller->adaptive().changes(
) | rpl::start_with_next([=] {
updateForwardBar();
}, lifetime());

View file

@ -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());

View file

@ -413,7 +413,7 @@ HistoryWidget::HistoryWidget(
Window::ActivateWindow(controller);
});
controller->adaptive().changed(
controller->adaptive().changes(
) | rpl::start_with_next([=] {
if (_history) {
_history->forceFullResize();

View file

@ -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());

View file

@ -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());

View file

@ -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());

View file

@ -117,7 +117,7 @@ TopBarWidget::TopBarWidget(
_search->setForceRippled(searchInActiveChat, animated);
}, lifetime());
controller->adaptive().changed(
controller->adaptive().changes(
) | rpl::start_with_next([=] {
updateAdaptiveLayout();
}, lifetime());

View file

@ -380,7 +380,7 @@ MainWidget::MainWidget(
}
});
_controller->adaptive().changed(
_controller->adaptive().changes(
) | rpl::start_with_next([=] {
handleAdaptiveLayoutUpdate();
}, lifetime());

View file

@ -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<bool> Adaptive::oneColumnValue() const {
return _layout.value(
) | rpl::map([=] {

View file

@ -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<bool> oneColumnValue() const;
[[nodiscard]] rpl::producer<ChatLayout> chatLayoutValue() const;