Use different indentation for rpl operators.

It works better with Visual Studio IDE.
This commit is contained in:
John Preston 2017-12-22 11:05:20 +04:00
parent 44014e62ba
commit 8e45b09083
72 changed files with 1282 additions and 1237 deletions

View File

@ -243,11 +243,10 @@ auto AuthSessionData::megagroupParticipantRemoved() const -> rpl::producer<Megag
rpl::producer<not_null<UserData*>> AuthSessionData::megagroupParticipantRemoved( rpl::producer<not_null<UserData*>> AuthSessionData::megagroupParticipantRemoved(
not_null<ChannelData*> channel) const { not_null<ChannelData*> channel) const {
return megagroupParticipantRemoved() return megagroupParticipantRemoved(
| rpl::filter([channel](auto updateChannel, auto user) { ) | rpl::filter([channel](auto updateChannel, auto user) {
return (updateChannel == channel); return (updateChannel == channel);
}) }) | rpl::map([](auto updateChannel, auto user) {
| rpl::map([](auto updateChannel, auto user) {
return user; return user;
}); });
} }
@ -264,11 +263,10 @@ auto AuthSessionData::megagroupParticipantAdded() const -> rpl::producer<Megagro
rpl::producer<not_null<UserData*>> AuthSessionData::megagroupParticipantAdded( rpl::producer<not_null<UserData*>> AuthSessionData::megagroupParticipantAdded(
not_null<ChannelData*> channel) const { not_null<ChannelData*> channel) const {
return megagroupParticipantAdded() return megagroupParticipantAdded(
| rpl::filter([channel](auto updateChannel, auto user) { ) | rpl::filter([channel](auto updateChannel, auto user) {
return (updateChannel == channel); return (updateChannel == channel);
}) }) | rpl::map([](auto updateChannel, auto user) {
| rpl::map([](auto updateChannel, auto user) {
return user; return user;
}); });
} }

View File

@ -287,8 +287,8 @@ void EditPrivacyBox::createWidgets() {
}; };
auto createExceptionLink = [this](Exception exception) { auto createExceptionLink = [this](Exception exception) {
exceptionLink(exception).create(this, object_ptr<Ui::LinkButton>(this, exceptionLinkText(exception)), exceptionLinkMargins()); exceptionLink(exception).create(this, object_ptr<Ui::LinkButton>(this, exceptionLinkText(exception)), exceptionLinkMargins());
exceptionLink(exception)->heightValue() exceptionLink(exception)->heightValue(
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
resizeToWidth(width()); resizeToWidth(width());
}, lifetime()); }, lifetime());
exceptionLink(exception)->entity()->setClickedCallback([this, exception] { editExceptionUsers(exception); }); exceptionLink(exception)->entity()->setClickedCallback([this, exception] { editExceptionUsers(exception); });

View File

@ -127,8 +127,8 @@ void NotificationsBox::prepare() {
_sampleOpacities.push_back(Animation()); _sampleOpacities.push_back(Animation());
} }
_countSlider->setActiveSectionFast(_oldCount - 1); _countSlider->setActiveSectionFast(_oldCount - 1);
_countSlider->sectionActivated() _countSlider->sectionActivated(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { countChanged(); }, [this] { countChanged(); },
lifetime()); lifetime());

View File

@ -54,8 +54,8 @@ void PeerListBox::createMultiSelect() {
auto entity = object_ptr<Ui::MultiSelect>(this, st::contactsMultiSelect, langFactory(lng_participant_filter)); auto entity = object_ptr<Ui::MultiSelect>(this, st::contactsMultiSelect, langFactory(lng_participant_filter));
_select.create(this, std::move(entity)); _select.create(this, std::move(entity));
_select->heightValue() _select->heightValue(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { updateScrollSkips(); }, [this] { updateScrollSkips(); },
lifetime()); lifetime());
_select->entity()->setSubmittedCallback([this](bool chtrlShiftEnter) { content()->submitted(); }); _select->entity()->setSubmittedCallback([this](bool chtrlShiftEnter) { content()->submitted(); });
@ -109,8 +109,8 @@ void PeerListBox::prepare() {
onScrollToY(0); onScrollToY(0);
} }
content()->scrollToRequests() content()->scrollToRequests(
| rpl::start_with_next([this](Ui::ScrollToRequest request) { ) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
onScrollToY(request.ymin, request.ymax); onScrollToY(request.ymin, request.ymax);
}, lifetime()); }, lifetime());

View File

@ -264,12 +264,12 @@ object_ptr<Ui::RpWidget> Controller::createPhotoAndTitleEdit() {
auto titleEdit = Ui::AttachParentChild( auto titleEdit = Ui::AttachParentChild(
container, container,
createTitleEdit()); createTitleEdit());
photoWrap->heightValue() photoWrap->heightValue(
| rpl::start_with_next([container](int height) { ) | rpl::start_with_next([container](int height) {
container->resize(container->width(), height); container->resize(container->width(), height);
}, photoWrap->lifetime()); }, photoWrap->lifetime());
container->widthValue() container->widthValue(
| rpl::start_with_next([titleEdit](int width) { ) | rpl::start_with_next([titleEdit](int width) {
auto left = st::editPeerPhotoMargins.left() auto left = st::editPeerPhotoMargins.left()
+ st::defaultUserpicButton.size.width(); + st::defaultUserpicButton.size.width();
titleEdit->resizeToWidth(width - left); titleEdit->resizeToWidth(width - left);
@ -439,12 +439,12 @@ object_ptr<Ui::RpWidget> Controller::createUsernameEdit() {
base::lambda<QString()>(), base::lambda<QString()>(),
channel->username, channel->username,
true)); true));
_controls.username->heightValue() _controls.username->heightValue(
| rpl::start_with_next([placeholder](int height) { ) | rpl::start_with_next([placeholder](int height) {
placeholder->resize(placeholder->width(), height); placeholder->resize(placeholder->width(), height);
}, placeholder->lifetime()); }, placeholder->lifetime());
placeholder->widthValue() placeholder->widthValue(
| rpl::start_with_next([this](int width) { ) | rpl::start_with_next([this](int width) {
_controls.username->resize( _controls.username->resize(
width, width,
_controls.username->height()); _controls.username->height());
@ -624,8 +624,8 @@ void Controller::showUsernameResult(
*st); *st);
auto label = _controls.usernameResult.get(); auto label = _controls.usernameResult.get();
label->show(); label->show();
label->widthValue() label->widthValue(
| rpl::start_with_next([label] { ) | rpl::start_with_next([label] {
label->moveToRight( label->moveToRight(
st::editPeerUsernamePosition.x(), st::editPeerUsernamePosition.x(),
st::editPeerUsernamePosition.y()); st::editPeerUsernamePosition.y());
@ -729,8 +729,8 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkEdit() {
Notify::PeerUpdateValue( Notify::PeerUpdateValue(
_peer, _peer,
Notify::PeerUpdate::Flag::InviteLinkChanged) Notify::PeerUpdate::Flag::InviteLinkChanged
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
refreshEditInviteLink(); refreshEditInviteLink();
}, _controls.editInviteLinkWrap->lifetime()); }, _controls.editInviteLinkWrap->lifetime());
@ -794,8 +794,8 @@ object_ptr<Ui::RpWidget> Controller::createInviteLinkCreate() {
Notify::PeerUpdateValue( Notify::PeerUpdateValue(
_peer, _peer,
Notify::PeerUpdate::Flag::InviteLinkChanged) Notify::PeerUpdate::Flag::InviteLinkChanged
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
refreshCreateInviteLink(); refreshCreateInviteLink();
}, _controls.createInviteLinkWrap->lifetime()); }, _controls.createInviteLinkWrap->lifetime());
@ -1437,13 +1437,13 @@ EditPeerInfoBox::EditPeerInfoBox(
void EditPeerInfoBox::prepare() { void EditPeerInfoBox::prepare() {
auto controller = std::make_unique<Controller>(this, _peer); auto controller = std::make_unique<Controller>(this, _peer);
_focusRequests.events() _focusRequests.events(
| rpl::start_with_next( ) | rpl::start_with_next(
[c = controller.get()] { c->setFocus(); }, [c = controller.get()] { c->setFocus(); },
lifetime()); lifetime());
auto content = controller->createContent(); auto content = controller->createContent();
content->heightValue() content->heightValue(
| rpl::start_with_next([this](int height) { ) | rpl::start_with_next([this](int height) {
setDimensions(st::boxWideWidth, height); setDimensions(st::boxWideWidth, height);
}, content->lifetime()); }, content->lifetime());
setInnerWidget(object_ptr<Ui::IgnoreMargins>( setInnerWidget(object_ptr<Ui::IgnoreMargins>(

View File

@ -85,8 +85,10 @@ void AddButtonWithCount(
std::move(count), std::move(count),
st::managePeerButtonLabel); st::managePeerButtonLabel);
label->setAttribute(Qt::WA_TransparentForMouseEvents); label->setAttribute(Qt::WA_TransparentForMouseEvents);
rpl::combine(button->widthValue(), label->widthValue()) rpl::combine(
| rpl::start_with_next([label](int outerWidth, int width) { button->widthValue(),
label->widthValue()
) | rpl::start_with_next([label](int outerWidth, int width) {
label->moveToRight( label->moveToRight(
st::managePeerButtonLabelPosition.x(), st::managePeerButtonLabelPosition.x(),
st::managePeerButtonLabelPosition.y(), st::managePeerButtonLabelPosition.y(),
@ -228,12 +230,12 @@ void ManagePeerBox::prepare() {
void ManagePeerBox::setupContent() { void ManagePeerBox::setupContent() {
auto content = Ui::CreateChild<Ui::VerticalLayout>(this); auto content = Ui::CreateChild<Ui::VerticalLayout>(this);
FillManageBox(controller(), _channel, content); FillManageBox(controller(), _channel, content);
widthValue() widthValue(
| rpl::start_with_next([=](int width) { ) | rpl::start_with_next([=](int width) {
content->resizeToWidth(width); content->resizeToWidth(width);
}, content->lifetime()); }, content->lifetime());
content->heightValue() content->heightValue(
| rpl::start_with_next([=](int height) { ) | rpl::start_with_next([=](int height) {
setDimensions(st::boxWidth, height); setDimensions(st::boxWidth, height);
}, content->lifetime()); }, content->lifetime());
} }

View File

@ -50,8 +50,8 @@ void StickerSetBox::prepare() {
setTitle(langFactory(lng_contacts_loading)); setTitle(langFactory(lng_contacts_loading));
_inner = setInnerWidget(object_ptr<Inner>(this, _set), st::stickersScroll); _inner = setInnerWidget(object_ptr<Inner>(this, _set), st::stickersScroll);
Auth().data().stickersUpdated() Auth().data().stickersUpdated(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { updateButtons(); }, [this] { updateButtons(); },
lifetime()); lifetime());
@ -60,8 +60,8 @@ void StickerSetBox::prepare() {
onUpdateButtons(); onUpdateButtons();
connect(_inner, SIGNAL(updateButtons()), this, SLOT(onUpdateButtons())); connect(_inner, SIGNAL(updateButtons()), this, SLOT(onUpdateButtons()));
_inner->setInstalled() _inner->setInstalled(
| rpl::start_with_next([this](auto &&setId) { ) | rpl::start_with_next([this](auto &&setId) {
Auth().api().stickerSetInstalled(setId); Auth().api().stickerSetInstalled(setId);
this->closeBox(); this->closeBox();
}, lifetime()); }, lifetime());

View File

@ -90,8 +90,8 @@ StickersBox::CounterWidget::CounterWidget(QWidget *parent)
_st.padding = st::stickersFeaturedBadgePadding; _st.padding = st::stickersFeaturedBadgePadding;
_st.font = st::stickersFeaturedBadgeFont; _st.font = st::stickersFeaturedBadgeFont;
Auth().data().featuredStickerSetsUnreadCountValue() Auth().data().featuredStickerSetsUnreadCountValue(
| rpl::start_with_next([this](int count) { ) | rpl::start_with_next([this](int count) {
setCounter(count); setCounter(count);
update(); update();
}, lifetime()); }, lifetime());
@ -242,8 +242,8 @@ void StickersBox::prepare() {
preloadArchivedSets(); preloadArchivedSets();
} }
setNoContentMargin(true); setNoContentMargin(true);
_tabs->sectionActivated() _tabs->sectionActivated(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { switchTab(); }, [this] { switchTab(); },
lifetime()); lifetime());
refreshTabs(); refreshTabs();
@ -277,8 +277,8 @@ void StickersBox::prepare() {
setInnerWidget(_tab->takeWidget(), getTopSkip()); setInnerWidget(_tab->takeWidget(), getTopSkip());
setDimensions(st::boxWideWidth, st::boxMaxListHeight); setDimensions(st::boxWideWidth, st::boxMaxListHeight);
Auth().data().stickersUpdated() Auth().data().stickersUpdated(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { handleStickersUpdated(); }, [this] { handleStickersUpdated(); },
lifetime()); lifetime());
Auth().api().updateStickers(); Auth().api().updateStickers();

View File

@ -214,8 +214,8 @@ void BoxController::Row::stopLastActionRipple() {
} }
void BoxController::prepare() { void BoxController::prepare() {
Auth().data().itemRemoved() Auth().data().itemRemoved(
| rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto item) {
if (auto row = rowForItem(item)) { if (auto row = rowForItem(item)) {
row->itemRemoved(item); row->itemRemoved(item);
if (!row->hasItems()) { if (!row->hasItems()) {

View File

@ -365,8 +365,10 @@ void Panel::initLayout() {
initGeometry(); initGeometry();
Notify::PeerUpdateValue(_user, Notify::PeerUpdate::Flag::PhotoChanged) Notify::PeerUpdateValue(
| rpl::start_with_next( _user,
Notify::PeerUpdate::Flag::PhotoChanged
) | rpl::start_with_next(
[this] { processUserPhoto(); }, [this] { processUserPhoto(); },
lifetime()); lifetime());
subscribe(Auth().downloaderTaskFinished(), [this] { subscribe(Auth().downloaderTaskFinished(), [this] {

View File

@ -148,8 +148,8 @@ GifsListWidget::GifsListWidget(
_inlineRequestTimer.setSingleShot(true); _inlineRequestTimer.setSingleShot(true);
connect(&_inlineRequestTimer, &QTimer::timeout, this, [this] { sendInlineRequest(); }); connect(&_inlineRequestTimer, &QTimer::timeout, this, [this] { sendInlineRequest(); });
Auth().data().savedGifsUpdated() Auth().data().savedGifsUpdated(
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
refreshSavedGifs(); refreshSavedGifs();
}, lifetime()); }, lifetime());
subscribe(Auth().downloaderTaskFinished(), [this] { subscribe(Auth().downloaderTaskFinished(), [this] {

View File

@ -63,8 +63,8 @@ TabbedPanel::TabbedPanel(
_controller->disableGifPauseReason(Window::GifPauseReason::SavedGifs); _controller->disableGifPauseReason(Window::GifPauseReason::SavedGifs);
} }
}); });
_selector->showRequests() _selector->showRequests(
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
this->showFromSelector(); this->showFromSelector();
}, lifetime()); }, lifetime());

View File

@ -339,8 +339,8 @@ TabbedSelector::TabbedSelector(QWidget *parent, not_null<Window::Controller*> co
} }
})); }));
Auth().api().stickerSetInstalled() Auth().api().stickerSetInstalled(
| rpl::start_with_next([this](uint64 setId) { ) | rpl::start_with_next([this](uint64 setId) {
_tabsSlider->setActiveSection( _tabsSlider->setActiveSection(
static_cast<int>(SelectorTab::Stickers)); static_cast<int>(SelectorTab::Stickers));
stickers()->showStickerSet(setId); stickers()->showStickerSet(setId);
@ -638,8 +638,8 @@ void TabbedSelector::createTabsSlider() {
_tabsSlider->setSections(sections); _tabsSlider->setSections(sections);
_tabsSlider->setActiveSectionFast(static_cast<int>(_currentTabType)); _tabsSlider->setActiveSectionFast(static_cast<int>(_currentTabType));
_tabsSlider->sectionActivated() _tabsSlider->sectionActivated(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { switchTab(); }, [this] { switchTab(); },
lifetime()); lifetime());
} }

View File

@ -576,8 +576,10 @@ void ChatData::setInviteLink(const QString &newInviteLink) {
ChannelData::ChannelData(const PeerId &id) ChannelData::ChannelData(const PeerId &id)
: PeerData(id) : PeerData(id)
, inputChannel(MTP_inputChannel(MTP_int(bareId()), MTP_long(0))) { , inputChannel(MTP_inputChannel(MTP_int(bareId()), MTP_long(0))) {
Data::PeerFlagValue(this, MTPDchannel::Flag::f_megagroup) Data::PeerFlagValue(
| rpl::start_with_next([this](bool megagroup) { this,
MTPDchannel::Flag::f_megagroup
) | rpl::start_with_next([this](bool megagroup) {
if (megagroup) { if (megagroup) {
if (!mgInfo) { if (!mgInfo) {
mgInfo = std::make_unique<MegagroupInfo>(); mgInfo = std::make_unique<MegagroupInfo>();

View File

@ -31,11 +31,11 @@ template <typename ChangeType, typename Error, typename Generator>
inline auto FlagsValueWithMask( inline auto FlagsValueWithMask(
rpl::producer<ChangeType, Error, Generator> &&value, rpl::producer<ChangeType, Error, Generator> &&value,
typename ChangeType::Type mask) { typename ChangeType::Type mask) {
return std::move(value) return std::move(
| rpl::filter([mask](const ChangeType &change) { value
) | rpl::filter([mask](const ChangeType &change) {
return change.diff & mask; return change.diff & mask;
}) }) | rpl::map([mask](const ChangeType &change) {
| rpl::map([mask](const ChangeType &change) {
return change.value & mask; return change.value & mask;
}); });
} }
@ -44,8 +44,10 @@ template <typename ChangeType, typename Error, typename Generator>
inline auto SingleFlagValue( inline auto SingleFlagValue(
rpl::producer<ChangeType, Error, Generator> &&value, rpl::producer<ChangeType, Error, Generator> &&value,
typename ChangeType::Enum flag) { typename ChangeType::Enum flag) {
return FlagsValueWithMask(std::move(value), flag) return FlagsValueWithMask(
| rpl::map([flag](typename ChangeType::Type value) { std::move(value),
flag
) | rpl::map([flag](typename ChangeType::Type value) {
return !!value; return !!value;
}); });
} }

View File

@ -260,8 +260,8 @@ rpl::producer<SparseIdsSlice> SearchController::simpleIdsSlice(
aroundId, aroundId,
limitBefore, limitBefore,
limitAfter); limitAfter);
builder->insufficientAround() builder->insufficientAround(
| rpl::start_with_next([=]( ) | rpl::start_with_next([=](
const SparseIdsSliceBuilder::AroundData &data) { const SparseIdsSliceBuilder::AroundData &data) {
requestMore(data, query, listData); requestMore(data, query, listData);
}, lifetime); }, lifetime);
@ -270,37 +270,33 @@ rpl::producer<SparseIdsSlice> SearchController::simpleIdsSlice(
consumer.put_next(builder->snapshot()); consumer.put_next(builder->snapshot());
}; };
listData->list.sliceUpdated() listData->list.sliceUpdated(
| rpl::filter([=](const SliceUpdate &update) { ) | rpl::filter([=](const SliceUpdate &update) {
return builder->applyUpdate(update); return builder->applyUpdate(update);
}) }) | rpl::start_with_next(pushNextSnapshot, lifetime);
| rpl::start_with_next(pushNextSnapshot, lifetime);
Auth().data().itemRemoved() Auth().data().itemRemoved(
| rpl::filter([=](not_null<const HistoryItem*> item) { ) | rpl::filter([=](not_null<const HistoryItem*> item) {
return (item->history()->peer->id == peerId); return (item->history()->peer->id == peerId);
}) }) | rpl::filter([=](not_null<const HistoryItem*> item) {
| rpl::filter([=](not_null<const HistoryItem*> item) {
return builder->removeOne(item->id); return builder->removeOne(item->id);
}) }) | rpl::start_with_next(pushNextSnapshot, lifetime);
| rpl::start_with_next(pushNextSnapshot, lifetime);
Auth().data().historyCleared() Auth().data().historyCleared(
| rpl::filter([=](not_null<const History*> history) { ) | rpl::filter([=](not_null<const History*> history) {
return (history->peer->id == peerId); return (history->peer->id == peerId);
}) }) | rpl::filter([=] {
| rpl::filter([=] { return builder->removeAll(); }) return builder->removeAll();
| rpl::start_with_next(pushNextSnapshot, lifetime); }) | rpl::start_with_next(pushNextSnapshot, lifetime);
using Result = Storage::SparseIdsListResult; using Result = Storage::SparseIdsListResult;
listData->list.query(Storage::SparseIdsListQuery( listData->list.query(Storage::SparseIdsListQuery(
aroundId, aroundId,
limitBefore, limitBefore,
limitAfter)) limitAfter
| rpl::filter([=](const Result &result) { )) | rpl::filter([=](const Result &result) {
return builder->applyInitial(result); return builder->applyInitial(result);
}) }) | rpl::start_with_next_done(
| rpl::start_with_next_done(
pushNextSnapshot, pushNextSnapshot,
[=] { builder->checkInsufficient(); }, [=] { builder->checkInsufficient(); },
lifetime); lifetime);

View File

@ -93,53 +93,47 @@ rpl::producer<SparseIdsSlice> SharedMediaViewer(
data.aroundId, data.aroundId,
data.direction); data.direction);
}; };
builder->insufficientAround() builder->insufficientAround(
| rpl::start_with_next(requestMediaAround, lifetime); ) | rpl::start_with_next(requestMediaAround, lifetime);
auto pushNextSnapshot = [=] { auto pushNextSnapshot = [=] {
consumer.put_next(builder->snapshot()); consumer.put_next(builder->snapshot());
}; };
using SliceUpdate = Storage::SharedMediaSliceUpdate; using SliceUpdate = Storage::SharedMediaSliceUpdate;
Auth().storage().sharedMediaSliceUpdated() Auth().storage().sharedMediaSliceUpdated(
| rpl::filter([=](const SliceUpdate &update) { ) | rpl::filter([=](const SliceUpdate &update) {
return (update.peerId == key.peerId) return (update.peerId == key.peerId)
&& (update.type == key.type); && (update.type == key.type);
}) }) | rpl::filter([=](const SliceUpdate &update) {
| rpl::filter([=](const SliceUpdate &update) {
return builder->applyUpdate(update.data); return builder->applyUpdate(update.data);
}) }) | rpl::start_with_next(pushNextSnapshot, lifetime);
| rpl::start_with_next(pushNextSnapshot, lifetime);
using OneRemoved = Storage::SharedMediaRemoveOne; using OneRemoved = Storage::SharedMediaRemoveOne;
Auth().storage().sharedMediaOneRemoved() Auth().storage().sharedMediaOneRemoved(
| rpl::filter([=](const OneRemoved &update) { ) | rpl::filter([=](const OneRemoved &update) {
return (update.peerId == key.peerId) return (update.peerId == key.peerId)
&& update.types.test(key.type); && update.types.test(key.type);
}) }) | rpl::filter([=](const OneRemoved &update) {
| rpl::filter([=](const OneRemoved &update) {
return builder->removeOne(update.messageId); return builder->removeOne(update.messageId);
}) }) | rpl::start_with_next(pushNextSnapshot, lifetime);
| rpl::start_with_next(pushNextSnapshot, lifetime);
using AllRemoved = Storage::SharedMediaRemoveAll; using AllRemoved = Storage::SharedMediaRemoveAll;
Auth().storage().sharedMediaAllRemoved() Auth().storage().sharedMediaAllRemoved(
| rpl::filter([=](const AllRemoved &update) { ) | rpl::filter([=](const AllRemoved &update) {
return (update.peerId == key.peerId); return (update.peerId == key.peerId);
}) }) | rpl::filter([=] {
| rpl::filter([=] { return builder->removeAll(); }) return builder->removeAll();
| rpl::start_with_next(pushNextSnapshot, lifetime); }) | rpl::start_with_next(pushNextSnapshot, lifetime);
using Result = Storage::SharedMediaResult; using Result = Storage::SharedMediaResult;
Auth().storage().query( Auth().storage().query(Storage::SharedMediaQuery(
Storage::SharedMediaQuery(
key, key,
limitBefore, limitBefore,
limitAfter)) limitAfter
| rpl::filter([=](const Result &result) { )) | rpl::filter([=](const Result &result) {
return builder->applyInitial(result); return builder->applyInitial(result);
}) }) | rpl::start_with_next_done(
| rpl::start_with_next_done(
pushNextSnapshot, pushNextSnapshot,
[=] { builder->checkInsufficient(); }, [=] { builder->checkInsufficient(); },
lifetime); lifetime);
@ -353,8 +347,11 @@ rpl::producer<SharedMediaWithLastSlice> SharedMediaWithLastReversedViewer(
SharedMediaWithLastSlice::Key key, SharedMediaWithLastSlice::Key key,
int limitBefore, int limitBefore,
int limitAfter) { int limitAfter) {
return SharedMediaWithLastViewer(key, limitBefore, limitAfter) return SharedMediaWithLastViewer(
| rpl::map([](SharedMediaWithLastSlice &&slice) { key,
limitBefore,
limitAfter
) | rpl::map([](SharedMediaWithLastSlice &&slice) {
slice.reverse(); slice.reverse();
return std::move(slice); return std::move(slice);
}); });

View File

@ -415,8 +415,9 @@ rpl::producer<SparseIdsMergedSlice> SparseIdsMergedSlice::CreateViewer(
limitAfter limitAfter
); );
if (!key.migratedPeerId) { if (!key.migratedPeerId) {
return std::move(partViewer) return std::move(
| rpl::start_with_next([=](SparseIdsSlice &&part) { partViewer
) | rpl::start_with_next([=](SparseIdsSlice &&part) {
consumer.put_next(SparseIdsMergedSlice( consumer.put_next(SparseIdsMergedSlice(
key, key,
std::move(part), std::move(part),

View File

@ -233,8 +233,8 @@ rpl::producer<UserPhotosSlice> UserPhotosViewer(
Auth().storage().query(Storage::UserPhotosQuery( Auth().storage().query(Storage::UserPhotosQuery(
key, key,
limitBefore, limitBefore,
limitAfter)) limitAfter
| rpl::start_with_next_done( )) | rpl::start_with_next_done(
applyUpdate, applyUpdate,
[=] { builder->checkInsufficientPhotos(); }, [=] { builder->checkInsufficientPhotos(); },
lifetime); lifetime);
@ -248,8 +248,11 @@ rpl::producer<UserPhotosSlice> UserPhotosReversedViewer(
UserPhotosSlice::Key key, UserPhotosSlice::Key key,
int limitBefore, int limitBefore,
int limitAfter) { int limitAfter) {
return UserPhotosViewer(key, limitBefore, limitAfter) return UserPhotosViewer(
| rpl::map([](UserPhotosSlice &&slice) { key,
limitBefore,
limitAfter
) | rpl::map([](UserPhotosSlice &&slice) {
slice.reverse(); slice.reverse();
return std::move(slice); return std::move(slice);
}); });

View File

@ -96,12 +96,12 @@ DialogsInner::DialogsInner(QWidget *parent, not_null<Window::Controller*> contro
_cancelSearchFromUser->hide(); _cancelSearchFromUser->hide();
subscribe(Auth().downloaderTaskFinished(), [this] { update(); }); subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
Auth().data().itemRemoved() Auth().data().itemRemoved(
| rpl::start_with_next( ) | rpl::start_with_next(
[this](auto item) { itemRemoved(item); }, [this](auto item) { itemRemoved(item); },
lifetime()); lifetime());
Auth().data().itemRepaintRequest() Auth().data().itemRepaintRequest(
| rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto item) {
if (item->history()->lastMsg == item) { if (item->history()->lastMsg == item) {
item->history()->updateChatListEntry(); item->history()->updateChatListEntry();
} }

View File

@ -220,8 +220,8 @@ InnerWidget::InnerWidget(
, _emptyText(st::historyAdminLogEmptyWidth - st::historyAdminLogEmptyPadding.left() - st::historyAdminLogEmptyPadding.left()) { , _emptyText(st::historyAdminLogEmptyWidth - st::historyAdminLogEmptyPadding.left() - st::historyAdminLogEmptyPadding.left()) {
setMouseTracking(true); setMouseTracking(true);
_scrollDateHideTimer.setCallback([this] { scrollDateHideByTimer(); }); _scrollDateHideTimer.setCallback([this] { scrollDateHideByTimer(); });
Auth().data().itemRepaintRequest() Auth().data().itemRepaintRequest(
| rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto item) {
if (item->isLogEntry() && _history == item->history()) { if (item->isLogEntry() && _history == item->history()) {
repaintItem(item); repaintItem(item);
} }

View File

@ -159,17 +159,16 @@ HistoryInner::HistoryInner(
subscribe(_controller->window()->dragFinished(), [this] { subscribe(_controller->window()->dragFinished(), [this] {
mouseActionUpdate(QCursor::pos()); mouseActionUpdate(QCursor::pos());
}); });
Auth().data().itemRemoved() Auth().data().itemRemoved(
| rpl::start_with_next( ) | rpl::start_with_next(
[this](auto item) { itemRemoved(item); }, [this](auto item) { itemRemoved(item); },
lifetime()); lifetime());
rpl::merge( rpl::merge(
Auth().data().historyUnloaded(), Auth().data().historyUnloaded(),
Auth().data().historyCleared()) Auth().data().historyCleared()
| rpl::filter([this](not_null<const History*> history) { ) | rpl::filter([this](not_null<const History*> history) {
return (_history == history); return (_history == history);
}) }) | rpl::start_with_next([this] {
| rpl::start_with_next([this] {
mouseActionCancel(); mouseActionCancel();
}, lifetime()); }, lifetime());
} }

View File

@ -77,9 +77,10 @@ HistoryTopBarWidget::HistoryTopBarWidget(
rpl::combine( rpl::combine(
_controller->historyPeer.value(), _controller->historyPeer.value(),
_controller->searchInPeer.value()) _controller->searchInPeer.value()
| rpl::combine_previous(std::make_tuple(nullptr, nullptr)) ) | rpl::combine_previous(
| rpl::map([]( std::make_tuple(nullptr, nullptr)
) | rpl::map([](
const std::tuple<PeerData*, PeerData*> &previous, const std::tuple<PeerData*, PeerData*> &previous,
const std::tuple<PeerData*, PeerData*> &current) { const std::tuple<PeerData*, PeerData*> &current) {
auto peer = std::get<0>(current); auto peer = std::get<0>(current);
@ -88,8 +89,7 @@ HistoryTopBarWidget::HistoryTopBarWidget(
auto searchInPeer auto searchInPeer
= (peer != nullptr) && (peer == searchPeer); = (peer != nullptr) && (peer == searchPeer);
return std::make_tuple(searchInPeer, peerChanged); return std::make_tuple(searchInPeer, peerChanged);
}) }) | rpl::start_with_next([this](
| rpl::start_with_next([this](
bool searchInHistoryPeer, bool searchInHistoryPeer,
bool peerChanged) { bool peerChanged) {
auto animated = peerChanged auto animated = peerChanged
@ -126,8 +126,8 @@ HistoryTopBarWidget::HistoryTopBarWidget(
rpl::combine( rpl::combine(
Auth().data().thirdSectionInfoEnabledValue(), Auth().data().thirdSectionInfoEnabledValue(),
Auth().data().tabbedReplacedWithInfoValue()) Auth().data().tabbedReplacedWithInfoValue()
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { updateInfoToggleActive(); }, [this] { updateInfoToggleActive(); },
lifetime()); lifetime());

View File

@ -552,12 +552,12 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
connect(&_updateEditTimeLeftDisplay, SIGNAL(timeout()), this, SLOT(updateField())); connect(&_updateEditTimeLeftDisplay, SIGNAL(timeout()), this, SLOT(updateField()));
subscribe(Adaptive::Changed(), [this] { update(); }); subscribe(Adaptive::Changed(), [this] { update(); });
Auth().data().itemRemoved() Auth().data().itemRemoved(
| rpl::start_with_next( ) | rpl::start_with_next(
[this](auto item) { itemRemoved(item); }, [this](auto item) { itemRemoved(item); },
lifetime()); lifetime());
Auth().data().itemRepaintRequest() Auth().data().itemRepaintRequest(
| rpl::start_with_next( ) | rpl::start_with_next(
[this](auto item) { repaintHistoryItem(item); }, [this](auto item) { repaintHistoryItem(item); },
lifetime()); lifetime());
subscribe(Auth().data().contactsLoaded(), [this](bool) { subscribe(Auth().data().contactsLoaded(), [this](bool) {
@ -639,8 +639,8 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
} }
} }
}); });
Auth().data().itemLayoutChanged() Auth().data().itemLayoutChanged(
| rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto item) {
if (_peer && _list) { if (_peer && _list) {
if ((item == App::mousedItem()) if ((item == App::mousedItem())
|| (item == App::hoveredItem()) || (item == App::hoveredItem())
@ -649,8 +649,8 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
} }
} }
}, lifetime()); }, lifetime());
_topBar->membersShowAreaActive() _topBar->membersShowAreaActive(
| rpl::start_with_next([this](bool active) { ) | rpl::start_with_next([this](bool active) {
setMembersShowAreaActive(active); setMembersShowAreaActive(active);
}, _topBar->lifetime()); }, _topBar->lifetime());
@ -883,8 +883,8 @@ int HistoryWidget::itemTopForHighlight(not_null<HistoryItem*> item) const {
} }
void HistoryWidget::start() { void HistoryWidget::start() {
Auth().data().stickersUpdated() Auth().data().stickersUpdated(
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
_tabbedSelector->refreshStickers(); _tabbedSelector->refreshStickers();
updateStickersByEmoji(); updateStickersByEmoji();
}, lifetime()); }, lifetime());

View File

@ -184,8 +184,8 @@ InnerWidget::InnerWidget(
setContent(_list.data()); setContent(_list.data());
_listController->setDelegate(static_cast<PeerListDelegate*>(this)); _listController->setDelegate(static_cast<PeerListDelegate*>(this));
_controller->searchFieldController()->queryValue() _controller->searchFieldController()->queryValue(
| rpl::start_with_next([this](QString &&query) { ) | rpl::start_with_next([this](QString &&query) {
peerListScrollToTop(); peerListScrollToTop();
content()->searchQueryChanged(std::move(query)); content()->searchQueryChanged(std::move(query));
}, lifetime()); }, lifetime());
@ -224,8 +224,8 @@ object_ptr<InnerWidget::ListWidget> InnerWidget::setupList(
parent, parent,
controller, controller,
st::infoCommonGroupsList); st::infoCommonGroupsList);
result->scrollToRequests() result->scrollToRequests(
| rpl::start_with_next([this](Ui::ScrollToRequest request) { ) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
auto addmin = (request.ymin < 0) auto addmin = (request.ymin < 0)
? 0 ? 0
: st::infoCommonGroupsMargin.top(); : st::infoCommonGroupsMargin.top();
@ -237,12 +237,12 @@ object_ptr<InnerWidget::ListWidget> InnerWidget::setupList(
request.ymax + addmax }); request.ymax + addmax });
}, result->lifetime()); }, result->lifetime());
result->moveToLeft(0, st::infoCommonGroupsMargin.top()); result->moveToLeft(0, st::infoCommonGroupsMargin.top());
parent->widthValue() parent->widthValue(
| rpl::start_with_next([list = result.data()](int newWidth) { ) | rpl::start_with_next([list = result.data()](int newWidth) {
list->resizeToWidth(newWidth); list->resizeToWidth(newWidth);
}, result->lifetime()); }, result->lifetime());
result->heightValue() result->heightValue(
| rpl::start_with_next([parent](int listHeight) { ) | rpl::start_with_next([parent](int listHeight) {
auto newHeight = st::infoCommonGroupsMargin.top() auto newHeight = st::infoCommonGroupsMargin.top()
+ listHeight + listHeight
+ st::infoCommonGroupsMargin.bottom(); + st::infoCommonGroupsMargin.bottom();

View File

@ -51,8 +51,8 @@ ContentWidget::ContentWidget(
using namespace rpl::mappers; using namespace rpl::mappers;
setAttribute(Qt::WA_OpaquePaintEvent); setAttribute(Qt::WA_OpaquePaintEvent);
_controller->wrapValue() _controller->wrapValue(
| rpl::start_with_next([this](Wrap value) { ) | rpl::start_with_next([this](Wrap value) {
if (value != Wrap::Layer) { if (value != Wrap::Layer) {
applyAdditionalScroll(0); applyAdditionalScroll(0);
} }
@ -65,13 +65,13 @@ ContentWidget::ContentWidget(
rpl::combine( rpl::combine(
_controller->wrapValue(), _controller->wrapValue(),
_controller->searchEnabledByContent(), _controller->searchEnabledByContent(),
(_1 == Wrap::Layer) && _2) (_1 == Wrap::Layer) && _2
| rpl::start_with_next([this](bool shown) { ) | rpl::start_with_next([this](bool shown) {
refreshSearchField(shown); refreshSearchField(shown);
}, lifetime()); }, lifetime());
} }
_scrollTopSkip.changes() _scrollTopSkip.changes(
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
updateControlsGeometry(); updateControlsGeometry();
}, lifetime()); }, lifetime());
} }
@ -144,8 +144,8 @@ Ui::RpWidget *ContentWidget::doSetInnerWidget(
_scroll->scrollTopValue(), _scroll->scrollTopValue(),
_scroll->heightValue(), _scroll->heightValue(),
_innerWrap->entity()->desiredHeightValue(), _innerWrap->entity()->desiredHeightValue(),
tuple(_1, _1 + _2, _3)) tuple(_1, _1 + _2, _3)
| rpl::start_with_next([this]( ) | rpl::start_with_next([this](
int top, int top,
int bottom, int bottom,
int desired) { int desired) {
@ -190,16 +190,16 @@ rpl::producer<int> ContentWidget::desiredHeightValue() const {
using namespace rpl::mappers; using namespace rpl::mappers;
return rpl::combine( return rpl::combine(
_innerWrap->entity()->desiredHeightValue(), _innerWrap->entity()->desiredHeightValue(),
_scrollTopSkip.value()) _scrollTopSkip.value()
| rpl::map(_1 + _2); ) | rpl::map(_1 + _2);
} }
rpl::producer<bool> ContentWidget::desiredShadowVisibility() const { rpl::producer<bool> ContentWidget::desiredShadowVisibility() const {
using namespace rpl::mappers; using namespace rpl::mappers;
return rpl::combine( return rpl::combine(
_scroll->scrollTopValue(), _scroll->scrollTopValue(),
_scrollTopSkip.value()) _scrollTopSkip.value()
| rpl::map((_1 > 0) || (_2 > 0)); ) | rpl::map((_1 > 0) || (_2 > 0));
} }
bool ContentWidget::hasTopBarShadow() const { bool ContentWidget::hasTopBarShadow() const {
@ -248,8 +248,8 @@ void ContentWidget::refreshSearchField(bool shown) {
_searchField = rowView.field; _searchField = rowView.field;
const auto view = _searchWrap.get(); const auto view = _searchWrap.get();
widthValue() widthValue(
| rpl::start_with_next([=](int newWidth) { ) | rpl::start_with_next([=](int newWidth) {
view->resizeToWidth(newWidth); view->resizeToWidth(newWidth);
view->moveToLeft(0, 0); view->moveToLeft(0, 0);
}, view->lifetime()); }, view->lifetime());

View File

@ -93,8 +93,10 @@ void Controller::setupMigrationViewer() {
if (!_peer->isChat() && (!_peer->isChannel() || _migrated != nullptr)) { if (!_peer->isChat() && (!_peer->isChannel() || _migrated != nullptr)) {
return; return;
} }
Notify::PeerUpdateValue(_peer, Notify::PeerUpdate::Flag::MigrationChanged) Notify::PeerUpdateValue(
| rpl::start_with_next([this] { _peer,
Notify::PeerUpdate::Flag::MigrationChanged
) | rpl::start_with_next([this] {
if (_peer->migrateTo() || (_peer->migrateFrom() != _migrated)) { if (_peer->migrateTo() || (_peer->migrateFrom() != _migrated)) {
auto window = parentController(); auto window = parentController();
auto peerId = _peer->id; auto peerId = _peer->id;
@ -160,8 +162,8 @@ void Controller::updateSearchControllers(
= std::make_unique<Ui::SearchFieldController>( = std::make_unique<Ui::SearchFieldController>(
searchQuery); searchQuery);
if (_searchController) { if (_searchController) {
_searchFieldController->queryValue() _searchFieldController->queryValue(
| rpl::start_with_next([=](QString &&query) { ) | rpl::start_with_next([=](QString &&query) {
_searchController->setQuery( _searchController->setQuery(
produceSearchQuery(std::move(query))); produceSearchQuery(std::move(query)));
}, _searchFieldController->lifetime()); }, _searchFieldController->lifetime());

View File

@ -55,13 +55,14 @@ LayerWidget::LayerWidget(
} }
void LayerWidget::setupHeightConsumers() { void LayerWidget::setupHeightConsumers() {
_content->scrollTillBottomChanges() _content->scrollTillBottomChanges(
| rpl::filter([this] { return !_inResize; }) ) | rpl::filter([this] {
| rpl::start_with_next([this] { return !_inResize;
}) | rpl::start_with_next([this] {
resizeToWidth(width()); resizeToWidth(width());
}, lifetime()); }, lifetime());
_content->desiredHeightValue() _content->desiredHeightValue(
| rpl::start_with_next([this](int height) { ) | rpl::start_with_next([this](int height) {
accumulate_max(_desiredHeight, height); accumulate_max(_desiredHeight, height);
if (_content && !_inResize) { if (_content && !_inResize) {
resizeToWidth(width()); resizeToWidth(width());

View File

@ -49,8 +49,8 @@ SectionWidget::SectionWidget(
} }
void SectionWidget::init() { void SectionWidget::init() {
sizeValue() sizeValue(
| rpl::start_with_next([wrap = _content.data()](QSize size) { ) | rpl::start_with_next([wrap = _content.data()](QSize size) {
auto wrapGeometry = QRect{ { 0, 0 }, size }; auto wrapGeometry = QRect{ { 0, 0 }, size };
auto additionalScroll = 0; auto additionalScroll = 0;
wrap->updateGeometry(wrapGeometry, additionalScroll); wrap->updateGeometry(wrapGeometry, additionalScroll);

View File

@ -158,8 +158,8 @@ Ui::FadeWrap<Ui::RpWidget> *TopBar::pushButton(
weak->toggle( weak->toggle(
!selectionMode() && !_searchModeEnabled, !selectionMode() && !_searchModeEnabled,
anim::type::instant); anim::type::instant);
weak->widthValue() weak->widthValue(
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
updateControlsGeometry(width()); updateControlsGeometry(width());
}, lifetime()); }, lifetime());
return weak; return weak;
@ -207,9 +207,7 @@ void TopBar::createSearchView(
*focusLifetime = field->shownValue() *focusLifetime = field->shownValue()
| rpl::filter([](bool shown) { return shown; }) | rpl::filter([](bool shown) { return shown; })
| rpl::take(1) | rpl::take(1)
| rpl::start_with_next([=] { | rpl::start_with_next([=] { field->setFocus(); });
field->setFocus();
});
} else { } else {
focusLifetime->destroy(); focusLifetime->destroy();
} }
@ -247,8 +245,8 @@ void TopBar::createSearchView(
cancel->addClickHandler(cancelSearch); cancel->addClickHandler(cancelSearch);
field->connect(field, &Ui::InputField::cancelled, cancelSearch); field->connect(field, &Ui::InputField::cancelled, cancelSearch);
wrap->widthValue() wrap->widthValue(
| rpl::start_with_next([=](int newWidth) { ) | rpl::start_with_next([=](int newWidth) {
auto availableWidth = newWidth auto availableWidth = newWidth
- _st.searchRow.fieldCancelSkip; - _st.searchRow.fieldCancelSkip;
fieldWrap->resizeToWidth(availableWidth); fieldWrap->resizeToWidth(availableWidth);
@ -258,8 +256,8 @@ void TopBar::createSearchView(
cancel->moveToRight(0, 0); cancel->moveToRight(0, 0);
}, wrap->lifetime()); }, wrap->lifetime());
widthValue() widthValue(
| rpl::start_with_next([=](int newWidth) { ) | rpl::start_with_next([=](int newWidth) {
auto left = _back auto left = _back
? _st.back.width ? _st.back.width
: _st.titlePosition.x(); : _st.titlePosition.x();
@ -271,8 +269,8 @@ void TopBar::createSearchView(
newWidth); newWidth);
}, wrap->lifetime()); }, wrap->lifetime());
field->alive() field->alive(
| rpl::start_with_done([=] { ) | rpl::start_with_done([=] {
field->setParent(nullptr); field->setParent(nullptr);
removeButton(search); removeButton(search);
clearSearchField(); clearSearchField();
@ -281,8 +279,9 @@ void TopBar::createSearchView(
_searchModeEnabled = !field->getLastText().isEmpty() || startsFocused; _searchModeEnabled = !field->getLastText().isEmpty() || startsFocused;
updateControlsVisibility(anim::type::instant); updateControlsVisibility(anim::type::instant);
std::move(shown) std::move(
| rpl::start_with_next([=](bool visible) { shown
) | rpl::start_with_next([=](bool visible) {
auto alreadyInSearch = !field->getLastText().isEmpty(); auto alreadyInSearch = !field->getLastText().isEmpty();
_searchModeAvailable = visible || alreadyInSearch; _searchModeAvailable = visible || alreadyInSearch;
updateControlsVisibility(anim::type::instant); updateControlsVisibility(anim::type::instant);
@ -440,8 +439,8 @@ void TopBar::createSelectionControls() {
object_ptr<Ui::IconButton>(this, _st.mediaCancel), object_ptr<Ui::IconButton>(this, _st.mediaCancel),
st::infoTopBarScale)); st::infoTopBarScale));
_cancelSelection->setDuration(st::infoTopBarDuration); _cancelSelection->setDuration(st::infoTopBarDuration);
_cancelSelection->entity()->clicks() _cancelSelection->entity()->clicks(
| rpl::start_to_stream( ) | rpl::start_to_stream(
_cancelSelectionClicks, _cancelSelectionClicks,
_cancelSelection->lifetime()); _cancelSelection->lifetime());
_selectionText = wrap(Ui::CreateChild<Ui::FadeWrap<Ui::LabelWithNumbers>>( _selectionText = wrap(Ui::CreateChild<Ui::FadeWrap<Ui::LabelWithNumbers>>(

View File

@ -73,17 +73,18 @@ WrapWidget::WrapWidget(
, _wrap(wrap) , _wrap(wrap)
, _controller(createController(window, memento->content())) , _controller(createController(window, memento->content()))
, _topShadow(this) { , _topShadow(this) {
_topShadow->toggleOn(topShadowToggledValue() _topShadow->toggleOn(
| rpl::filter([](bool shown) { topShadowToggledValue(
) | rpl::filter([](bool shown) {
return true; return true;
})); }));
_wrap.changes() _wrap.changes(
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
setupTop(); setupTop();
finishShowContent(); finishShowContent();
}, lifetime()); }, lifetime());
selectedListValue() selectedListValue(
| rpl::start_with_next([this](SelectedItems &&items) { ) | rpl::start_with_next([this](SelectedItems &&items) {
InvokeQueued(this, [this, items = std::move(items)]() mutable { InvokeQueued(this, [this, items = std::move(items)]() mutable {
if (_topBar) _topBar->setSelectedItems(std::move(items)); if (_topBar) _topBar->setSelectedItems(std::move(items));
}); });
@ -116,10 +117,12 @@ void WrapWidget::startInjectingActivePeerProfiles() {
using namespace rpl::mappers; using namespace rpl::mappers;
rpl::combine( rpl::combine(
_wrap.value(), _wrap.value(),
_controller->parentController()->activePeer.value()) _controller->parentController()->activePeer.value()
| rpl::filter((_1 == Wrap::Side) && (_2 != nullptr)) ) | rpl::filter(
| rpl::map(_2) (_1 == Wrap::Side) && (_2 != nullptr)
| rpl::start_with_next([this](not_null<PeerData*> peer) { ) | rpl::map(
_2
) | rpl::start_with_next([this](not_null<PeerData*> peer) {
injectActivePeerProfile(peer); injectActivePeerProfile(peer);
}, lifetime()); }, lifetime());
@ -190,9 +193,10 @@ not_null<PeerData*> WrapWidget::peer() const {
// _topTabs->setActiveSection(static_cast<int>(_tab)); // _topTabs->setActiveSection(static_cast<int>(_tab));
// _topTabs->finishAnimating(); // _topTabs->finishAnimating();
// //
// _topTabs->sectionActivated() // _topTabs->sectionActivated(
// | rpl::map([](int index) { return static_cast<Tab>(index); }) // ) | rpl::map([](int index) {
// | rpl::start_with_next( // return static_cast<Tab>(index);
// }) | rpl::start_with_next(
// [this](Tab tab) { showTab(tab); }, // [this](Tab tab) { showTab(tab); },
// lifetime()); // lifetime());
// //
@ -310,8 +314,8 @@ void WrapWidget::createTopBar() {
? _topBar->takeSelectedItems() ? _topBar->takeSelectedItems()
: SelectedItems(Section::MediaType::kCount); : SelectedItems(Section::MediaType::kCount);
_topBar.create(this, TopBarStyle(wrapValue), std::move(selectedItems)); _topBar.create(this, TopBarStyle(wrapValue), std::move(selectedItems));
_topBar->cancelSelectionRequests() _topBar->cancelSelectionRequests(
| rpl::start_with_next([this](auto) { ) | rpl::start_with_next([this] {
_content->cancelSelection(); _content->cancelSelection();
}, _topBar->lifetime()); }, _topBar->lifetime());
@ -321,8 +325,8 @@ void WrapWidget::createTopBar() {
!hasStackHistory())); !hasStackHistory()));
if (wrapValue == Wrap::Narrow || hasStackHistory()) { if (wrapValue == Wrap::Narrow || hasStackHistory()) {
_topBar->enableBackButton(); _topBar->enableBackButton();
_topBar->backRequest() _topBar->backRequest(
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
_controller->showBackFromStack(); _controller->showBackFromStack();
}, _topBar->lifetime()); }, _topBar->lifetime());
} else if (wrapValue == Wrap::Side) { } else if (wrapValue == Wrap::Side) {
@ -425,8 +429,9 @@ void WrapWidget::addProfileNotificationsButton() {
: Data::NotifySettings::MuteChange::Mute; : Data::NotifySettings::MuteChange::Mute;
App::main()->updateNotifySettings(peer, muteState); App::main()->updateNotifySettings(peer, muteState);
}); });
Profile::NotificationsEnabledValue(peer) Profile::NotificationsEnabledValue(
| rpl::start_with_next([notifications](bool enabled) { peer
) | rpl::start_with_next([notifications](bool enabled) {
const auto iconOverride = enabled const auto iconOverride = enabled
? &st::infoNotificationsActive ? &st::infoNotificationsActive
: nullptr; : nullptr;

View File

@ -68,8 +68,9 @@ inline auto AddCountedButton(
using Button = Profile::Button; using Button = Profile::Button;
auto forked = std::move(count) auto forked = std::move(count)
| start_spawning(parent->lifetime()); | start_spawning(parent->lifetime());
auto text = rpl::duplicate(forked) auto text = rpl::duplicate(
| rpl::map([textFromCount](int count) { forked
) | rpl::map([textFromCount](int count) {
return (count > 0) return (count > 0)
? textFromCount(count) ? textFromCount(count)
: QString(); : QString();

View File

@ -33,8 +33,9 @@ EmptyWidget::EmptyWidget(QWidget *parent)
} }
void EmptyWidget::setFullHeight(rpl::producer<int> fullHeightValue) { void EmptyWidget::setFullHeight(rpl::producer<int> fullHeightValue) {
std::move(fullHeightValue) std::move(
| rpl::start_with_next([this](int fullHeight) { fullHeightValue
) | rpl::start_with_next([this](int fullHeight) {
// Make icon center be on 1/3 height. // Make icon center be on 1/3 height.
auto iconCenter = fullHeight / 3; auto iconCenter = fullHeight / 3;
auto iconHeight = st::infoEmptyFile.height(); auto iconHeight = st::infoEmptyFile.height();

View File

@ -44,8 +44,8 @@ InnerWidget::InnerWidget(
: RpWidget(parent) : RpWidget(parent)
, _controller(controller) , _controller(controller)
, _empty(this) { , _empty(this) {
_empty->heightValue() _empty->heightValue(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { refreshHeight(); }, [this] { refreshHeight(); },
_empty->lifetime()); _empty->lifetime());
_list = setupList(); _list = setupList();
@ -63,8 +63,8 @@ void InnerWidget::setupOtherTypes() {
} }
//rpl::combine( //rpl::combine(
// _controller->wrapValue(), // _controller->wrapValue(),
// _controller->searchEnabledByContent()) // _controller->searchEnabledByContent()
// | rpl::start_with_next([this](Wrap wrap, bool enabled) { //) | rpl::start_with_next([this](Wrap wrap, bool enabled) {
// _searchEnabled = enabled; // _searchEnabled = enabled;
// refreshSearchField(); // refreshSearchField();
//}, lifetime()); //}, lifetime());
@ -83,8 +83,8 @@ void InnerWidget::createOtherTypes() {
//createTabs(); //createTabs();
_otherTypes->resizeToWidth(width()); _otherTypes->resizeToWidth(width());
_otherTypes->heightValue() _otherTypes->heightValue(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { refreshHeight(); }, [this] { refreshHeight(); },
_otherTypes->lifetime()); _otherTypes->lifetime());
} }
@ -161,9 +161,10 @@ void InnerWidget::createTypeButtons() {
// _otherTabs->setActiveSection(*TypeToTabIndex(type())); // _otherTabs->setActiveSection(*TypeToTabIndex(type()));
// _otherTabs->finishAnimating(); // _otherTabs->finishAnimating();
// //
// _otherTabs->sectionActivated() // _otherTabs->sectionActivated(
// | rpl::map([](int index) { return TabIndexToType(index); }) // ) | rpl::map([](int index) {
// | rpl::start_with_next( // return TabIndexToType(index);
// }) | rpl::start_with_next(
// [this](Type newType) { // [this](Type newType) {
// if (type() != newType) { // if (type() != newType) {
// switchToTab(Memento( // switchToTab(Memento(
@ -233,8 +234,8 @@ bool InnerWidget::showInternal(not_null<Memento*> memento) {
// st::infoMediaSearch); // st::infoMediaSearch);
// _searchField->resizeToWidth(width()); // _searchField->resizeToWidth(width());
// _searchField->show(); // _searchField->show();
// search->queryChanges() // search->queryChanges(
// | rpl::start_with_next([this] { // ) | rpl::start_with_next([this] {
// scrollToSearchField(); // scrollToSearchField();
// }, _searchField->lifetime()); // }, _searchField->lifetime());
// } else { // } else {
@ -254,26 +255,25 @@ object_ptr<ListWidget> InnerWidget::setupList() {
auto result = object_ptr<ListWidget>( auto result = object_ptr<ListWidget>(
this, this,
_controller); _controller);
result->heightValue() result->heightValue(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { refreshHeight(); }, [this] { refreshHeight(); },
result->lifetime()); result->lifetime());
using namespace rpl::mappers; using namespace rpl::mappers;
result->scrollToRequests() result->scrollToRequests(
| rpl::map([widget = result.data()](int to) { ) | rpl::map([widget = result.data()](int to) {
return Ui::ScrollToRequest { return Ui::ScrollToRequest {
widget->y() + to, widget->y() + to,
-1 -1
}; };
}) }) | rpl::start_to_stream(
| rpl::start_to_stream(
_scrollToRequests, _scrollToRequests,
result->lifetime()); result->lifetime());
_selectedLists.fire(result->selectedListValue()); _selectedLists.fire(result->selectedListValue());
_listTops.fire(result->topValue()); _listTops.fire(result->topValue());
_empty->setType(_controller->section().mediaType()); _empty->setType(_controller->section().mediaType());
_controller->mediaSourceQueryValue() _controller->mediaSourceQueryValue(
| rpl::start_with_next([this](const QString &query) { ) | rpl::start_with_next([this](const QString &query) {
_empty->setSearchQuery(query); _empty->setSearchQuery(query);
}, result->lifetime()); }, result->lifetime());
return result; return result;
@ -288,8 +288,9 @@ void InnerWidget::restoreState(not_null<Memento*> memento) {
} }
rpl::producer<SelectedItems> InnerWidget::selectedListValue() const { rpl::producer<SelectedItems> InnerWidget::selectedListValue() const {
return _selectedLists.events_starting_with(_list->selectedListValue()) return _selectedLists.events_starting_with(
| rpl::flatten_latest(); _list->selectedListValue()
) | rpl::flatten_latest();
} }
void InnerWidget::cancelSelection() { void InnerWidget::cancelSelection() {
@ -352,8 +353,9 @@ void InnerWidget::setScrollHeightValue(rpl::producer<int> value) {
using namespace rpl::mappers; using namespace rpl::mappers;
_empty->setFullHeight(rpl::combine( _empty->setFullHeight(rpl::combine(
std::move(value), std::move(value),
_listTops.events_starting_with(_list->topValue()) _listTops.events_starting_with(
| rpl::flatten_latest(), _list->topValue()
) | rpl::flatten_latest(),
_1 - _2)); _1 - _2));
} }

View File

@ -560,28 +560,30 @@ ListWidget::ListWidget(
void ListWidget::start() { void ListWidget::start() {
_controller->setSearchEnabledByContent(false); _controller->setSearchEnabledByContent(false);
ObservableViewer(*Window::Theme::Background()) ObservableViewer(
| rpl::start_with_next([this](const auto &update) { *Window::Theme::Background()
) | rpl::start_with_next([this](const auto &update) {
if (update.paletteChanged()) { if (update.paletteChanged()) {
invalidatePaletteCache(); invalidatePaletteCache();
} }
}, lifetime()); }, lifetime());
ObservableViewer(Auth().downloader().taskFinished()) ObservableViewer(
| rpl::start_with_next([this] { update(); }, lifetime()); Auth().downloader().taskFinished()
Auth().data().itemLayoutChanged() ) | rpl::start_with_next([this] { update(); }, lifetime());
| rpl::start_with_next([this](auto item) { Auth().data().itemLayoutChanged(
) | rpl::start_with_next([this](auto item) {
itemLayoutChanged(item); itemLayoutChanged(item);
}, lifetime()); }, lifetime());
Auth().data().itemRemoved() Auth().data().itemRemoved(
| rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto item) {
itemRemoved(item); itemRemoved(item);
}, lifetime()); }, lifetime());
Auth().data().itemRepaintRequest() Auth().data().itemRepaintRequest(
| rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto item) {
repaintItem(item); repaintItem(item);
}, lifetime()); }, lifetime());
_controller->mediaSourceQueryValue() _controller->mediaSourceQueryValue(
| rpl::start_with_next([this]{ ) | rpl::start_with_next([this]{
restart(); restart();
}, lifetime()); }, lifetime());
} }
@ -800,8 +802,8 @@ void ListWidget::refreshViewer() {
_controller->mediaSource( _controller->mediaSource(
idForViewer, idForViewer,
_idsLimit, _idsLimit,
_idsLimit) _idsLimit
| rpl::start_with_next([=]( ) | rpl::start_with_next([=](
SparseIdsMergedSlice &&slice) { SparseIdsMergedSlice &&slice) {
if (!slice.fullCount()) { if (!slice.fullCount()) {
// Don't display anything while full count is unknown. // Don't display anything while full count is unknown.

View File

@ -88,8 +88,8 @@ Widget::Widget(
this, this,
controller)); controller));
_inner->setScrollHeightValue(scrollHeightValue()); _inner->setScrollHeightValue(scrollHeightValue());
_inner->scrollToRequests() _inner->scrollToRequests(
| rpl::start_with_next([this](Ui::ScrollToRequest request) { ) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
scrollTo(request); scrollTo(request);
}, _inner->lifetime()); }, _inner->lifetime());
} }

View File

@ -230,8 +230,9 @@ object_ptr<Ui::RpWidget> DetailsFiller::setupInfo() {
UsernameValue(user), UsernameValue(user),
lang(lng_context_copy_mention)); lang(lng_context_copy_mention));
} else { } else {
auto linkText = LinkValue(_peer) auto linkText = LinkValue(
| rpl::map([](const QString &link) { _peer
) | rpl::map([](const QString &link) {
auto result = TextWithEntities{ link, {} }; auto result = TextWithEntities{ link, {} };
if (!link.isEmpty()) { if (!link.isEmpty()) {
auto remove = qstr("https://"); auto remove = qstr("https://");
@ -487,8 +488,8 @@ void ActionsFiller::addBotCommandActions(not_null<UserData*> user) {
auto hasBotCommandValue = [=](const QString &command) { auto hasBotCommandValue = [=](const QString &command) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
user, user,
Notify::PeerUpdate::Flag::BotCommandsChanged) Notify::PeerUpdate::Flag::BotCommandsChanged
| rpl::map([=] { ) | rpl::map([=] {
return !findBotCommand(command).isEmpty(); return !findBotCommand(command).isEmpty();
}); });
}; };
@ -523,8 +524,8 @@ void ActionsFiller::addReportAction() {
void ActionsFiller::addBlockAction(not_null<UserData*> user) { void ActionsFiller::addBlockAction(not_null<UserData*> user) {
auto text = Notify::PeerUpdateValue( auto text = Notify::PeerUpdateValue(
user, user,
Notify::PeerUpdate::Flag::UserIsBlocked) Notify::PeerUpdate::Flag::UserIsBlocked
| rpl::map([user] { ) | rpl::map([user] {
switch (user->blockStatus()) { switch (user->blockStatus()) {
case UserData::BlockStatus::Blocked: case UserData::BlockStatus::Blocked:
return Lang::Viewer(user->botInfo return Lang::Viewer(user->botInfo
@ -536,12 +537,12 @@ void ActionsFiller::addBlockAction(not_null<UserData*> user) {
? lng_profile_block_bot ? lng_profile_block_bot
: lng_profile_block_user); : lng_profile_block_user);
} }
}) }) | rpl::flatten_latest(
| rpl::flatten_latest() ) | rpl::start_spawning(_wrap->lifetime());
| rpl::start_spawning(_wrap->lifetime());
auto toggleOn = rpl::duplicate(text) auto toggleOn = rpl::duplicate(
| rpl::map([](const QString &text) { text
) | rpl::map([](const QString &text) {
return !text.isEmpty(); return !text.isEmpty();
}); });
auto callback = [user] { auto callback = [user] {
@ -690,8 +691,8 @@ void SetupAddChannelMember(
add->addClickHandler([channel] { add->addClickHandler([channel] {
Window::PeerMenuAddChannelMembers(channel); Window::PeerMenuAddChannelMembers(channel);
}); });
parent->widthValue() parent->widthValue(
| rpl::start_with_next([add](int newWidth) { ) | rpl::start_with_next([add](int newWidth) {
auto availableWidth = newWidth auto availableWidth = newWidth
- st::infoMembersButtonPosition.x(); - st::infoMembersButtonPosition.x();
add->moveToLeft( add->moveToLeft(
@ -718,8 +719,9 @@ object_ptr<Ui::RpWidget> SetupChannelMembers(
channel, channel,
MTPDchannelFull::Flag::f_can_view_participants), MTPDchannelFull::Flag::f_can_view_participants),
(_1 > 0) && _2); (_1 > 0) && _2);
auto membersText = MembersCountValue(channel) auto membersText = MembersCountValue(
| rpl::map([](int count) { channel
) | rpl::map([](int count) {
return lng_chat_status_members(lt_count, count); return lng_chat_status_members(lt_count, count);
}); });
auto membersCallback = [controller, channel] { auto membersCallback = [controller, channel] {

View File

@ -39,8 +39,9 @@ Button::Button(
const style::InfoProfileButton &st) const style::InfoProfileButton &st)
: RippleButton(parent, st.ripple) : RippleButton(parent, st.ripple)
, _st(st) { , _st(st) {
std::move(text) std::move(
| rpl::start_with_next([this](QString &&value) { text
) | rpl::start_with_next([this](QString &&value) {
setText(std::move(value)); setText(std::move(value));
}, lifetime()); }, lifetime());
} }
@ -54,8 +55,9 @@ Button *Button::toggleOn(rpl::producer<bool> &&toggled) {
addClickHandler([this] { addClickHandler([this] {
_toggle->setCheckedAnimated(!_toggle->checked()); _toggle->setCheckedAnimated(!_toggle->checked());
}); });
std::move(toggled) std::move(
| rpl::start_with_next([this](bool toggled) { toggled
) | rpl::start_with_next([this](bool toggled) {
_toggle->setCheckedAnimated(toggled); _toggle->setCheckedAnimated(toggled);
}, lifetime()); }, lifetime());
_toggle->finishAnimating(); _toggle->finishAnimating();

View File

@ -174,12 +174,13 @@ SectionWithToggle *SectionWithToggle::setToggleShown(
_toggle->hide(); _toggle->hide();
_toggle->lower(); _toggle->lower();
_toggle->setCheckAlignment(style::al_right); _toggle->setCheckAlignment(style::al_right);
widthValue() widthValue(
| rpl::start_with_next([this](int newValue) { ) | rpl::start_with_next([this](int newValue) {
_toggle->setGeometry(0, 0, newValue, height()); _toggle->setGeometry(0, 0, newValue, height());
}, _toggle->lifetime()); }, _toggle->lifetime());
std::move(shown) std::move(
| rpl::start_with_next([this](bool shown) { shown
) | rpl::start_with_next([this](bool shown) {
if (_toggle->isHidden() == shown) { if (_toggle->isHidden() == shown) {
_toggle->setVisible(shown); _toggle->setVisible(shown);
_toggleShown.fire_copy(shown); _toggleShown.fire_copy(shown);
@ -203,9 +204,9 @@ bool SectionWithToggle::toggled() const {
rpl::producer<bool> SectionWithToggle::toggledValue() const { rpl::producer<bool> SectionWithToggle::toggledValue() const {
if (_toggle) { if (_toggle) {
return rpl::single(_toggle->checked()) return rpl::single(
| rpl::then( _toggle->checked()
base::ObservableViewer(_toggle->checkedChanged)); ) | rpl::then(base::ObservableViewer(_toggle->checkedChanged));
} }
return rpl::never<bool>(); return rpl::never<bool>();
} }
@ -268,12 +269,14 @@ void Cover::setupChildGeometry() {
//rpl::combine( //rpl::combine(
// toggleShownValue(), // toggleShownValue(),
// widthValue(), // widthValue(),
// _2) // _2
//) | rpl::map([](bool shown, int width) {
rpl::combine( rpl::combine(
toggleShownValue(), toggleShownValue(),
widthValue()) widthValue()
| rpl::map([](bool shown, int width) { return width; }) ) | rpl::map([](bool shown, int width) {
| rpl::start_with_next([this](int newWidth) { return width;
}) | rpl::start_with_next([this](int newWidth) {
_userpic->moveToLeft( _userpic->moveToLeft(
st::infoProfilePhotoLeft, st::infoProfilePhotoLeft,
st::infoProfilePhotoTop, st::infoProfilePhotoTop,
@ -284,8 +287,9 @@ void Cover::setupChildGeometry() {
} }
Cover *Cover::setOnlineCount(rpl::producer<int> &&count) { Cover *Cover::setOnlineCount(rpl::producer<int> &&count) {
std::move(count) std::move(
| rpl::start_with_next([this](int count) { count
) | rpl::start_with_next([this](int count) {
_onlineCount = count; _onlineCount = count;
refreshStatusText(); refreshStatusText();
}, lifetime()); }, lifetime());
@ -294,24 +298,29 @@ Cover *Cover::setOnlineCount(rpl::producer<int> &&count) {
void Cover::initViewers() { void Cover::initViewers() {
using Flag = Notify::PeerUpdate::Flag; using Flag = Notify::PeerUpdate::Flag;
Notify::PeerUpdateValue(_peer, Flag::NameChanged) Notify::PeerUpdateValue(
| rpl::start_with_next( _peer,
Flag::NameChanged
) | rpl::start_with_next(
[this] { refreshNameText(); }, [this] { refreshNameText(); },
lifetime()); lifetime());
Notify::PeerUpdateValue(_peer, Notify::PeerUpdateValue(
Flag::UserOnlineChanged | Flag::MembersChanged) _peer,
| rpl::start_with_next( Flag::UserOnlineChanged | Flag::MembersChanged
) | rpl::start_with_next(
[this] { refreshStatusText(); }, [this] { refreshStatusText(); },
lifetime()); lifetime());
if (!_peer->isUser()) { if (!_peer->isUser()) {
Notify::PeerUpdateValue(_peer, Notify::PeerUpdateValue(
Flag::ChannelRightsChanged | Flag::ChatCanEdit) _peer,
| rpl::start_with_next( Flag::ChannelRightsChanged | Flag::ChatCanEdit
) | rpl::start_with_next(
[this] { refreshUploadPhotoOverlay(); }, [this] { refreshUploadPhotoOverlay(); },
lifetime()); lifetime());
} }
VerifiedValue(_peer) VerifiedValue(
| rpl::start_with_next( _peer
) | rpl::start_with_next(
[this](bool verified) { setVerified(verified); }, [this](bool verified) { setVerified(verified); },
lifetime()); lifetime());
} }
@ -335,8 +344,8 @@ void Cover::setVerified(bool verified) {
_verifiedCheck.create(this); _verifiedCheck.create(this);
_verifiedCheck->show(); _verifiedCheck->show();
_verifiedCheck->resize(st::infoVerifiedCheck.size()); _verifiedCheck->resize(st::infoVerifiedCheck.size());
_verifiedCheck->paintRequest() _verifiedCheck->paintRequest(
| rpl::start_with_next([check = _verifiedCheck.data()] { ) | rpl::start_with_next([check = _verifiedCheck.data()] {
Painter p(check); Painter p(check);
st::infoVerifiedCheck.paint(p, 0, 0, check->width()); st::infoVerifiedCheck.paint(p, 0, 0, check->width());
}, _verifiedCheck->lifetime()); }, _verifiedCheck->lifetime());
@ -465,12 +474,14 @@ void SharedMediaCover::createLabel() {
//rpl::combine( //rpl::combine(
// toggleShownValue(), // toggleShownValue(),
// widthValue(), // widthValue(),
// _2) // _2
//) | rpl::map([](bool shown, int width) {
rpl::combine( rpl::combine(
toggleShownValue(), toggleShownValue(),
widthValue()) widthValue()
| rpl::map([](bool shown, int width) { return width; }) ) | rpl::map([](bool shown, int width) {
| rpl::start_with_next([this, weak = label.data()](int newWidth) { return width;
}) | rpl::start_with_next([this, weak = label.data()](int newWidth) {
auto availableWidth = newWidth auto availableWidth = newWidth
- st::infoBlockHeaderPosition.x() - st::infoBlockHeaderPosition.x()
- st::infoSharedMediaButton.padding.right() - st::infoSharedMediaButton.padding.right()

View File

@ -42,8 +42,8 @@ FloatingIcon::FloatingIcon(
_point.x() + _icon->width(), _point.x() + _icon->width(),
_point.y() + _icon->height()); _point.y() + _icon->height());
setAttribute(Qt::WA_TransparentForMouseEvents); setAttribute(Qt::WA_TransparentForMouseEvents);
parent->widthValue() parent->widthValue(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { moveToLeft(0, 0); }, [this] { moveToLeft(0, 0); },
lifetime()); lifetime());
} }

View File

@ -66,8 +66,8 @@ InnerWidget::InnerWidget(
, _peer(_controller->peer()) , _peer(_controller->peer())
, _migrated(_controller->migrated()) , _migrated(_controller->migrated())
, _content(setupContent(this)) { , _content(setupContent(this)) {
_content->heightValue() _content->heightValue(
| rpl::start_with_next([this](int height) { ) | rpl::start_with_next([this](int height) {
if (!_inResize) { if (!_inResize) {
resizeToWidth(width()); resizeToWidth(width());
updateDesiredHeight(); updateDesiredHeight();
@ -122,8 +122,8 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
_controller, _controller,
_peer) _peer)
); );
_members->scrollToRequests() _members->scrollToRequests(
| rpl::start_with_next([this](Ui::ScrollToRequest request) { ) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
auto min = (request.ymin < 0) auto min = (request.ymin < 0)
? request.ymin ? request.ymin
: mapFromGlobal(_members->mapToGlobal({ 0, request.ymin })).y(); : mapFromGlobal(_members->mapToGlobal({ 0, request.ymin })).y();
@ -198,9 +198,10 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
//rpl::combine( //rpl::combine(
// tracker.atLeastOneShownValue(), // tracker.atLeastOneShownValue(),
// _controller->wrapValue(), // _controller->wrapValue(),
// _isStackBottom.value()) // _isStackBottom.value()
// | rpl::combine_previous(ToggledData()) //) | rpl::combine_previous(
// | rpl::start_with_next([wrap = result.data()]( // ToggledData()
//) | rpl::start_with_next([wrap = result.data()](
// const ToggledData &was, // const ToggledData &was,
// const ToggledData &now) { // const ToggledData &now) {
// bool wasOneShown, wasStackBottom, nowOneShown, nowStackBottom; // bool wasOneShown, wasStackBottom, nowOneShown, nowStackBottom;

View File

@ -65,13 +65,14 @@ Members::Members(
setContent(_list.data()); setContent(_list.data());
_listController->setDelegate(static_cast<PeerListDelegate*>(this)); _listController->setDelegate(static_cast<PeerListDelegate*>(this));
_controller->searchFieldController()->queryValue() _controller->searchFieldController()->queryValue(
| rpl::start_with_next([this](QString &&query) { ) | rpl::start_with_next([this](QString &&query) {
peerListScrollToTop(); peerListScrollToTop();
content()->searchQueryChanged(std::move(query)); content()->searchQueryChanged(std::move(query));
}, lifetime()); }, lifetime());
MembersCountValue(_peer) MembersCountValue(
| rpl::start_with_next([this](int count) { _peer
) | rpl::start_with_next([this](int count) {
const auto enabled = (count >= kEnableSearchMembersAfterCount); const auto enabled = (count >= kEnableSearchMembersAfterCount);
_controller->setSearchEnabledByContent(enabled); _controller->setSearchEnabledByContent(enabled);
}, lifetime()); }, lifetime());
@ -159,13 +160,13 @@ void Members::setupHeader() {
setupButtons(); setupButtons();
//_controller->wrapValue() //_controller->wrapValue(
// | rpl::start_with_next([this](Wrap wrap) { //) | rpl::start_with_next([this](Wrap wrap) {
// _wrap = wrap; // _wrap = wrap;
// updateSearchOverrides(); // updateSearchOverrides();
//}, lifetime()); //}, lifetime());
widthValue() widthValue(
| rpl::start_with_next([this](int width) { ) | rpl::start_with_next([this](int width) {
_header->resizeToWidth(width); _header->resizeToWidth(width);
}, _header->lifetime()); }, _header->lifetime());
} }
@ -173,11 +174,11 @@ void Members::setupHeader() {
object_ptr<Ui::FlatLabel> Members::setupTitle() { object_ptr<Ui::FlatLabel> Members::setupTitle() {
auto result = object_ptr<Ui::FlatLabel>( auto result = object_ptr<Ui::FlatLabel>(
_titleWrap, _titleWrap,
MembersCountValue(_peer) MembersCountValue(
| rpl::map([](int count) { _peer
) | rpl::map([](int count) {
return lng_chat_status_members(lt_count, count); return lng_chat_status_members(lt_count, count);
}) }) | ToUpperValue(),
| ToUpperValue(),
st::infoBlockHeaderLabel); st::infoBlockHeaderLabel);
result->setAttribute(Qt::WA_TransparentForMouseEvents); result->setAttribute(Qt::WA_TransparentForMouseEvents);
return result; return result;
@ -214,8 +215,8 @@ void Members::setupButtons() {
rpl::combine( rpl::combine(
std::move(addMemberShown), std::move(addMemberShown),
std::move(searchShown)) std::move(searchShown)
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
updateHeaderControlsGeometry(width()); updateHeaderControlsGeometry(width());
}, lifetime()); }, lifetime());
} }
@ -226,8 +227,8 @@ void Members::setupList() {
this, this,
_listController.get(), _listController.get(),
st::infoMembersList); st::infoMembersList);
_list->scrollToRequests() _list->scrollToRequests(
| rpl::start_with_next([this](Ui::ScrollToRequest request) { ) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
auto addmin = (request.ymin < 0 || !_header) auto addmin = (request.ymin < 0 || !_header)
? 0 ? 0
: _header->height(); : _header->height();
@ -238,12 +239,12 @@ void Members::setupList() {
request.ymin + addmin, request.ymin + addmin,
request.ymax + addmax }); request.ymax + addmax });
}, _list->lifetime()); }, _list->lifetime());
widthValue() widthValue(
| rpl::start_with_next([this](int newWidth) { ) | rpl::start_with_next([this](int newWidth) {
_list->resizeToWidth(newWidth); _list->resizeToWidth(newWidth);
}, _list->lifetime()); }, _list->lifetime());
_list->heightValue() _list->heightValue(
| rpl::start_with_next([=](int listHeight) { ) | rpl::start_with_next([=](int listHeight) {
auto newHeight = (listHeight > st::membersMarginBottom) auto newHeight = (listHeight > st::membersMarginBottom)
? (topSkip ? (topSkip
+ listHeight + listHeight

View File

@ -152,8 +152,10 @@ std::unique_ptr<PeerListState> ChatMembersController::saveState() const {
auto result = PeerListController::saveState(); auto result = PeerListController::saveState();
auto my = std::make_unique<SavedState>(); auto my = std::make_unique<SavedState>();
using Flag = Notify::PeerUpdate::Flag; using Flag = Notify::PeerUpdate::Flag;
Notify::PeerUpdateViewer(_chat, Flag::MembersChanged) Notify::PeerUpdateViewer(
| rpl::start_with_next([state = result.get()](auto update) { _chat,
Flag::MembersChanged
) | rpl::start_with_next([state = result.get()](auto update) {
state->controllerState = nullptr; state->controllerState = nullptr;
}, my->lifetime); }, my->lifetime);
result->controllerState = std::move(my); result->controllerState = std::move(my);

View File

@ -45,17 +45,16 @@ TextWithLabel CreateTextWithLabel(
st::infoSlideDuration st::infoSlideDuration
); );
auto layout = result->entity(); auto layout = result->entity();
auto nonEmptyText = std::move(text) auto nonEmptyText = std::move(
| rpl::before_next([slide = result.data()]( text
) | rpl::before_next([slide = result.data()](
const TextWithEntities &value) { const TextWithEntities &value) {
if (value.text.isEmpty()) { if (value.text.isEmpty()) {
slide->hide(anim::type::normal); slide->hide(anim::type::normal);
} }
}) }) | rpl::filter([](const TextWithEntities &value) {
| rpl::filter([](const TextWithEntities &value) {
return !value.text.isEmpty(); return !value.text.isEmpty();
}) }) | rpl::after_next([slide = result.data()](
| rpl::after_next([slide = result.data()](
const TextWithEntities &value) { const TextWithEntities &value) {
slide->show(anim::type::normal); slide->show(anim::type::normal);
}); });

View File

@ -37,19 +37,18 @@ rpl::producer<TextWithEntities> PhoneValue(
not_null<UserData*> user) { not_null<UserData*> user) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
user, user,
Notify::PeerUpdate::Flag::UserPhoneChanged) Notify::PeerUpdate::Flag::UserPhoneChanged
| rpl::map([user] { ) | rpl::map([user] {
return App::formatPhone(user->phone()); return App::formatPhone(user->phone());
}) }) | WithEmptyEntities();
| WithEmptyEntities();
} }
auto PlainBioValue( auto PlainBioValue(
not_null<UserData*> user) { not_null<UserData*> user) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
user, user,
Notify::PeerUpdate::Flag::AboutChanged) Notify::PeerUpdate::Flag::AboutChanged
| rpl::map([user] { return user->about(); }); ) | rpl::map([user] { return user->about(); });
} }
rpl::producer<TextWithEntities> BioValue( rpl::producer<TextWithEntities> BioValue(
@ -63,21 +62,21 @@ auto PlainUsernameValue(
not_null<PeerData*> peer) { not_null<PeerData*> peer) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
peer, peer,
Notify::PeerUpdate::Flag::UsernameChanged) Notify::PeerUpdate::Flag::UsernameChanged
| rpl::map([peer] { ) | rpl::map([peer] {
return peer->userName(); return peer->userName();
}); });
} }
rpl::producer<TextWithEntities> UsernameValue( rpl::producer<TextWithEntities> UsernameValue(
not_null<UserData*> user) { not_null<UserData*> user) {
return PlainUsernameValue(user) return PlainUsernameValue(
| rpl::map([](QString &&username) { user
) | rpl::map([](QString &&username) {
return username.isEmpty() return username.isEmpty()
? QString() ? QString()
: ('@' + username); : ('@' + username);
}) }) | WithEmptyEntities();
| WithEmptyEntities();
} }
rpl::producer<QString> PlainAboutValue( rpl::producer<QString> PlainAboutValue(
@ -85,8 +84,8 @@ rpl::producer<QString> PlainAboutValue(
if (auto channel = peer->asChannel()) { if (auto channel = peer->asChannel()) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
channel, channel,
Notify::PeerUpdate::Flag::AboutChanged) Notify::PeerUpdate::Flag::AboutChanged
| rpl::map([channel] { return channel->about(); }); ) | rpl::map([channel] { return channel->about(); });
} else if (auto user = peer->asUser()) { } else if (auto user = peer->asUser()) {
if (user->botInfo) { if (user->botInfo) {
return PlainBioValue(user); return PlainBioValue(user);
@ -104,9 +103,10 @@ rpl::producer<TextWithEntities> AboutValue(
if (peer->isUser()) { if (peer->isUser()) {
flags |= TextParseBotCommands; flags |= TextParseBotCommands;
} }
return PlainAboutValue(peer) return PlainAboutValue(
| WithEmptyEntities() peer
| rpl::map([=](TextWithEntities &&text) { ) | WithEmptyEntities(
) | rpl::map([=](TextWithEntities &&text) {
TextUtilities::ParseEntities(text, flags); TextUtilities::ParseEntities(text, flags);
return std::move(text); return std::move(text);
}); });
@ -114,8 +114,9 @@ rpl::producer<TextWithEntities> AboutValue(
rpl::producer<QString> LinkValue( rpl::producer<QString> LinkValue(
not_null<PeerData*> peer) { not_null<PeerData*> peer) {
return PlainUsernameValue(peer) return PlainUsernameValue(
| rpl::map([](QString &&username) { peer
) | rpl::map([](QString &&username) {
return username.isEmpty() return username.isEmpty()
? QString() ? QString()
: Messenger::Instance().createInternalLinkFull(username); : Messenger::Instance().createInternalLinkFull(username);
@ -126,17 +127,18 @@ rpl::producer<bool> NotificationsEnabledValue(
not_null<PeerData*> peer) { not_null<PeerData*> peer) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
peer, peer,
Notify::PeerUpdate::Flag::NotificationsEnabled) Notify::PeerUpdate::Flag::NotificationsEnabled
| rpl::map([peer] { return !peer->isMuted(); }) ) | rpl::map([peer] {
| rpl::distinct_until_changed(); return !peer->isMuted();
}) | rpl::distinct_until_changed();
} }
rpl::producer<bool> IsContactValue( rpl::producer<bool> IsContactValue(
not_null<UserData*> user) { not_null<UserData*> user) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
user, user,
Notify::PeerUpdate::Flag::UserIsContact) Notify::PeerUpdate::Flag::UserIsContact
| rpl::map([user] { return user->isContact(); }); ) | rpl::map([user] { return user->isContact(); });
} }
rpl::producer<bool> CanInviteBotToGroupValue( rpl::producer<bool> CanInviteBotToGroupValue(
@ -146,8 +148,8 @@ rpl::producer<bool> CanInviteBotToGroupValue(
} }
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
user, user,
Notify::PeerUpdate::Flag::BotCanAddToGroups) Notify::PeerUpdate::Flag::BotCanAddToGroups
| rpl::map([user] { ) | rpl::map([user] {
return !user->botInfo->cantJoinGroups; return !user->botInfo->cantJoinGroups;
}); });
} }
@ -156,8 +158,8 @@ rpl::producer<bool> CanShareContactValue(
not_null<UserData*> user) { not_null<UserData*> user) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
user, user,
Notify::PeerUpdate::Flag::UserCanShareContact) Notify::PeerUpdate::Flag::UserCanShareContact
| rpl::map([user] { ) | rpl::map([user] {
return user->canShareThisContact(); return user->canShareThisContact();
}); });
} }
@ -175,8 +177,8 @@ rpl::producer<bool> AmInChannelValue(
not_null<ChannelData*> channel) { not_null<ChannelData*> channel) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
channel, channel,
Notify::PeerUpdate::Flag::ChannelAmIn) Notify::PeerUpdate::Flag::ChannelAmIn
| rpl::map([channel] { return channel->amIn(); }); ) | rpl::map([channel] { return channel->amIn(); });
} }
rpl::producer<int> MembersCountValue( rpl::producer<int> MembersCountValue(
@ -184,8 +186,8 @@ rpl::producer<int> MembersCountValue(
if (auto chat = peer->asChat()) { if (auto chat = peer->asChat()) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
peer, peer,
Notify::PeerUpdate::Flag::MembersChanged) Notify::PeerUpdate::Flag::MembersChanged
| rpl::map([chat] { ) | rpl::map([chat] {
return chat->amIn() return chat->amIn()
? std::max(chat->count, int(chat->participants.size())) ? std::max(chat->count, int(chat->participants.size()))
: 0; : 0;
@ -193,8 +195,8 @@ rpl::producer<int> MembersCountValue(
} else if (auto channel = peer->asChannel()) { } else if (auto channel = peer->asChannel()) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
channel, channel,
Notify::PeerUpdate::Flag::MembersChanged) Notify::PeerUpdate::Flag::MembersChanged
| rpl::map([channel] { ) | rpl::map([channel] {
return channel->membersCount(); return channel->membersCount();
}); });
} }
@ -206,8 +208,8 @@ rpl::producer<int> AdminsCountValue(
using Flag = Notify::PeerUpdate::Flag; using Flag = Notify::PeerUpdate::Flag;
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
channel, channel,
Flag::AdminsChanged | Flag::ChannelRightsChanged) Flag::AdminsChanged | Flag::ChannelRightsChanged
| rpl::map([channel] { ) | rpl::map([channel] {
return channel->canViewAdmins() return channel->canViewAdmins()
? channel->adminsCount() ? channel->adminsCount()
: 0; : 0;
@ -219,8 +221,8 @@ rpl::producer<int> RestrictedCountValue(
using Flag = Notify::PeerUpdate::Flag; using Flag = Notify::PeerUpdate::Flag;
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
channel, channel,
Flag::BannedUsersChanged | Flag::ChannelRightsChanged) Flag::BannedUsersChanged | Flag::ChannelRightsChanged
| rpl::map([channel] { ) | rpl::map([channel] {
return channel->canViewBanned() return channel->canViewBanned()
? channel->restrictedCount() ? channel->restrictedCount()
: 0; : 0;
@ -232,8 +234,8 @@ rpl::producer<int> KickedCountValue(
using Flag = Notify::PeerUpdate::Flag; using Flag = Notify::PeerUpdate::Flag;
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
channel, channel,
Flag::BannedUsersChanged | Flag::ChannelRightsChanged) Flag::BannedUsersChanged | Flag::ChannelRightsChanged
| rpl::map([channel] { ) | rpl::map([channel] {
return channel->canViewBanned() return channel->canViewBanned()
? channel->kickedCount() ? channel->kickedCount()
: 0; : 0;
@ -254,11 +256,10 @@ rpl::producer<int> SharedMediaCountValue(
aroundId), aroundId),
type), type),
limit, limit,
limit) limit
| rpl::map([](const SparseIdsMergedSlice &slice) { ) | rpl::map([](const SparseIdsMergedSlice &slice) {
return slice.fullCount(); return slice.fullCount();
}) }) | rpl::filter_optional();
| rpl::filter_optional();
return rpl::single(0) | rpl::then(std::move(updated)); return rpl::single(0) | rpl::then(std::move(updated));
} }
@ -266,8 +267,8 @@ rpl::producer<int> CommonGroupsCountValue(
not_null<UserData*> user) { not_null<UserData*> user) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
user, user,
Notify::PeerUpdate::Flag::UserCommonChatsChanged) Notify::PeerUpdate::Flag::UserCommonChatsChanged
| rpl::map([user] { ) | rpl::map([user] {
return user->commonChatsCount(); return user->commonChatsCount();
}); });
} }
@ -277,15 +278,15 @@ rpl::producer<bool> CanAddMemberValue(
if (auto chat = peer->asChat()) { if (auto chat = peer->asChat()) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
chat, chat,
Notify::PeerUpdate::Flag::ChatCanEdit) Notify::PeerUpdate::Flag::ChatCanEdit
| rpl::map([chat] { ) | rpl::map([chat] {
return chat->canEdit(); return chat->canEdit();
}); });
} else if (auto channel = peer->asChannel()) { } else if (auto channel = peer->asChannel()) {
return Notify::PeerUpdateValue( return Notify::PeerUpdateValue(
channel, channel,
Notify::PeerUpdate::Flag::ChannelRightsChanged) Notify::PeerUpdate::Flag::ChannelRightsChanged
| rpl::map([channel] { ) | rpl::map([channel] {
return channel->canAddMembers(); return channel->canAddMembers();
}); });
} }

View File

@ -69,8 +69,8 @@ Widget::Widget(
this, this,
controller)); controller));
_inner->move(0, 0); _inner->move(0, 0);
_inner->scrollToRequests() _inner->scrollToRequests(
| rpl::start_with_next([this](Ui::ScrollToRequest request) { ) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
if (request.ymin < 0) { if (request.ymin < 0) {
scrollTopRestore( scrollTopRestore(
qMin(scrollTopSave(), request.ymax)); qMin(scrollTopSave(), request.ymax));

View File

@ -500,11 +500,11 @@ Instance &Current() {
} }
rpl::producer<QString> Viewer(LangKey key) { rpl::producer<QString> Viewer(LangKey key) {
return return rpl::single(
rpl::single(Current().getValue(key)) Current().getValue(key)
| then( ) | then(base::ObservableViewer(
base::ObservableViewer(Current().updated()) Current().updated()
| rpl::map([=] { ) | rpl::map([=] {
return Current().getValue(key); return Current().getValue(key);
})); }));
} }

View File

@ -237,8 +237,8 @@ MainWidget::MainWidget(
Auth().data().dialogsWidthRatioChanges() Auth().data().dialogsWidthRatioChanges()
| rpl::map([] { return rpl::empty_value(); }), | rpl::map([] { return rpl::empty_value(); }),
Auth().data().thirdColumnWidthChanges() Auth().data().thirdColumnWidthChanges()
| rpl::map([] { return rpl::empty_value(); })) | rpl::map([] { return rpl::empty_value(); })
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { updateControlsGeometry(); }, [this] { updateControlsGeometry(); },
lifetime()); lifetime());
subscribe(_controller->floatPlayerAreaUpdated(), [this] { subscribe(_controller->floatPlayerAreaUpdated(), [this] {
@ -246,16 +246,14 @@ MainWidget::MainWidget(
}); });
using namespace rpl::mappers; using namespace rpl::mappers;
_controller->activePeer.value() _controller->activePeer.value(
| rpl::map([](PeerData *peer) { ) | rpl::map([](PeerData *peer) {
auto canWrite = peer auto canWrite = peer
? Data::CanWriteValue(peer) ? Data::CanWriteValue(peer)
: rpl::single(false); : rpl::single(false);
return std::move(canWrite) return std::move(canWrite) | rpl::map(tuple(peer, _1));
| rpl::map(tuple(peer, _1)); }) | rpl::flatten_latest(
}) ) | rpl::start_with_next([this](PeerData *peer, bool canWrite) {
| rpl::flatten_latest()
| rpl::start_with_next([this](PeerData *peer, bool canWrite) {
updateThirdColumnToCurrentPeer(peer, canWrite); updateThirdColumnToCurrentPeer(peer, canWrite);
}, lifetime()); }, lifetime());
@ -1758,8 +1756,8 @@ void MainWidget::createPlayer() {
_player.create(this); _player.create(this);
rpl::merge( rpl::merge(
_player->heightValue() | rpl::map([] { return true; }), _player->heightValue() | rpl::map([] { return true; }),
_player->shownValue()) _player->shownValue()
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { playerHeightUpdated(); }, [this] { playerHeightUpdated(); },
lifetime()); lifetime());
_player->entity()->setCloseCallback([this] { closeBothPlayers(); }); _player->entity()->setCloseCallback([this] { closeBothPlayers(); });
@ -1819,8 +1817,8 @@ void MainWidget::setCurrentCall(Calls::Call *call) {
void MainWidget::createCallTopBar() { void MainWidget::createCallTopBar() {
Expects(_currentCall != nullptr); Expects(_currentCall != nullptr);
_callTopBar.create(this, object_ptr<Calls::TopBar>(this, _currentCall)); _callTopBar.create(this, object_ptr<Calls::TopBar>(this, _currentCall));
_callTopBar->heightValue() _callTopBar->heightValue(
| rpl::start_with_next([this](int value) { ) | rpl::start_with_next([this](int value) {
callTopBarHeightUpdated(value); callTopBarHeightUpdated(value);
}, lifetime()); }, lifetime());
orderWidgets(); orderWidgets();

View File

@ -55,17 +55,16 @@ Float::Float(
prepareShadow(); prepareShadow();
// #TODO rpl::merge
rpl::merge( rpl::merge(
Auth().data().itemLayoutChanged(), Auth().data().itemLayoutChanged(),
Auth().data().itemRepaintRequest()) Auth().data().itemRepaintRequest()
| rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto item) {
if (_item == item) { if (_item == item) {
repaintItem(); repaintItem();
} }
}, lifetime()); }, lifetime());
Auth().data().itemRemoved() Auth().data().itemRemoved(
| rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this](auto item) {
if (_item == item) { if (_item == item) {
detach(); detach();
} }

View File

@ -1008,8 +1008,8 @@ void Messenger::registerLeaveSubscription(QWidget *widget) {
if (auto topLevel = widget->window()) { if (auto topLevel = widget->window()) {
if (topLevel == _window.get()) { if (topLevel == _window.get()) {
auto weak = make_weak(widget); auto weak = make_weak(widget);
auto subscription = _window->leaveEvents() auto subscription = _window->leaveEvents(
| rpl::start_with_next([weak] { ) | rpl::start_with_next([weak] {
if (const auto window = weak.data()) { if (const auto window = weak.data()) {
QEvent ev(QEvent::Leave); QEvent ev(QEvent::Leave);
QGuiApplication::sendEvent(window, &ev); QGuiApplication::sendEvent(window, &ev);

View File

@ -260,7 +260,9 @@ private:
base::DelayedCallTimer _callDelayedTimer; base::DelayedCallTimer _callDelayedTimer;
struct LeaveSubscription { struct LeaveSubscription {
LeaveSubscription(QPointer<QWidget> pointer, rpl::lifetime &&subscription) LeaveSubscription(
QPointer<QWidget> pointer,
rpl::lifetime &&subscription)
: pointer(pointer), subscription(std::move(subscription)) { : pointer(pointer), subscription(std::move(subscription)) {
} }

View File

@ -121,8 +121,9 @@ rpl::producer<PeerUpdate> PeerUpdateViewer(
rpl::producer<PeerUpdate> PeerUpdateViewer( rpl::producer<PeerUpdate> PeerUpdateViewer(
not_null<PeerData*> peer, not_null<PeerData*> peer,
PeerUpdate::Flags flags) { PeerUpdate::Flags flags) {
return PeerUpdateViewer(flags) return PeerUpdateViewer(
| rpl::filter([=](const PeerUpdate &update) { flags
) | rpl::filter([=](const PeerUpdate &update) {
return (update.peer == peer); return (update.peer == peer);
}); });
} }
@ -132,8 +133,9 @@ rpl::producer<PeerUpdate> PeerUpdateValue(
PeerUpdate::Flags flags) { PeerUpdate::Flags flags) {
auto initial = PeerUpdate(peer); auto initial = PeerUpdate(peer);
initial.flags = flags; initial.flags = flags;
return rpl::single(initial) return rpl::single(
| rpl::then(PeerUpdateViewer(peer, flags)); initial
) | rpl::then(PeerUpdateViewer(peer, flags));
} }
} // namespace Notify } // namespace Notify

View File

@ -80,8 +80,9 @@ void ParticipantsBoxController::setupListChangeViewers() {
if (!_channel->isMegagroup()) { if (!_channel->isMegagroup()) {
return; return;
} }
Auth().data().megagroupParticipantAdded(_channel) Auth().data().megagroupParticipantAdded(
| rpl::start_with_next([this](not_null<UserData*> user) { _channel
) | rpl::start_with_next([this](not_null<UserData*> user) {
if (delegate()->peerListFullRowsCount() > 0) { if (delegate()->peerListFullRowsCount() > 0) {
if (delegate()->peerListRowAt(0)->peer() == user) { if (delegate()->peerListRowAt(0)->peer() == user) {
return; return;
@ -97,8 +98,9 @@ void ParticipantsBoxController::setupListChangeViewers() {
sortByOnline(); sortByOnline();
} }
}, lifetime()); }, lifetime());
Auth().data().megagroupParticipantRemoved(_channel) Auth().data().megagroupParticipantRemoved(
| rpl::start_with_next([this](not_null<UserData*> user) { _channel
) | rpl::start_with_next([this](not_null<UserData*> user) {
if (auto row = delegate()->peerListFindRow(user->id)) { if (auto row = delegate()->peerListFindRow(user->id)) {
delegate()->peerListRemoveRow(row); delegate()->peerListRemoveRow(row);
} }
@ -270,8 +272,9 @@ std::unique_ptr<PeerListState> ParticipantsBoxController::saveState() const {
if (_channel->isMegagroup()) { if (_channel->isMegagroup()) {
auto weak = result.get(); auto weak = result.get();
Auth().data().megagroupParticipantAdded(_channel) Auth().data().megagroupParticipantAdded(
| rpl::start_with_next([weak](not_null<UserData*> user) { _channel
) | rpl::start_with_next([weak](not_null<UserData*> user) {
if (!weak->list.empty()) { if (!weak->list.empty()) {
if (weak->list[0] == user) { if (weak->list[0] == user) {
return; return;
@ -285,8 +288,9 @@ std::unique_ptr<PeerListState> ParticipantsBoxController::saveState() const {
weak->list, weak->list,
[user](auto peer) { return (peer == user); }); [user](auto peer) { return (peer == user); });
}, my->lifetime); }, my->lifetime);
Auth().data().megagroupParticipantRemoved(_channel) Auth().data().megagroupParticipantRemoved(
| rpl::start_with_next([weak](not_null<UserData*> user) { _channel
) | rpl::start_with_next([weak](not_null<UserData*> user) {
weak->list.erase(std::remove( weak->list.erase(std::remove(
weak->list.begin(), weak->list.begin(),
weak->list.end(), weak->list.end(),

View File

@ -258,7 +258,7 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
{ {
rpl::lifetime lifetime; rpl::lifetime lifetime;
{ {
rpl::event_stream<int> stream; event_stream<int> stream;
single(single(1) | then(single(2))) single(single(1) | then(single(2)))
| then(single(single(3) | then(single(4)))) | then(single(single(3) | then(single(4))))
| then(single(single(5) | then(stream.events()))) | then(single(single(5) | then(stream.events())))
@ -291,11 +291,11 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
auto sum = std::make_shared<std::string>(""); auto sum = std::make_shared<std::string>("");
{ {
rpl::lifetime lifetime; rpl::lifetime lifetime;
rpl::event_stream<bool> a; event_stream<bool> a;
rpl::event_stream<bool> b; event_stream<bool> b;
rpl::event_stream<bool> c; event_stream<bool> c;
std::vector<rpl::producer<bool>> v; std::vector<producer<bool>> v;
v.push_back(a.events()); v.push_back(a.events());
v.push_back(b.events()); v.push_back(b.events());
v.push_back(c.events()); v.push_back(c.events());
@ -322,9 +322,9 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
auto sum = std::make_shared<std::string>(""); auto sum = std::make_shared<std::string>("");
{ {
rpl::lifetime lifetime; rpl::lifetime lifetime;
rpl::event_stream<int> a; event_stream<int> a;
rpl::event_stream<short> b; event_stream<short> b;
rpl::event_stream<char> c; event_stream<char> c;
combine( combine(
a.events(), a.events(),
@ -374,9 +374,9 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
auto sum = std::make_shared<std::string>(""); auto sum = std::make_shared<std::string>("");
{ {
rpl::lifetime lifetime; rpl::lifetime lifetime;
rpl::event_stream<int> a; event_stream<int> a;
rpl::event_stream<short> b; event_stream<short> b;
rpl::event_stream<char> c; event_stream<char> c;
using namespace mappers; using namespace mappers;
@ -403,7 +403,7 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
auto sum = std::make_shared<std::string>(""); auto sum = std::make_shared<std::string>("");
{ {
rpl::lifetime lifetime; rpl::lifetime lifetime;
rpl::ints(3) ints(3)
| after_next([=](int value) { | after_next([=](int value) {
*sum += std::to_string(-value-1); *sum += std::to_string(-value-1);
}) })
@ -418,7 +418,7 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
auto sum = std::make_shared<std::string>(""); auto sum = std::make_shared<std::string>("");
{ {
rpl::lifetime lifetime; rpl::lifetime lifetime;
rpl::ints(10) | take(3) ints(10) | take(3)
| start_with_next_done([=](int value) { | start_with_next_done([=](int value) {
*sum += std::to_string(value); *sum += std::to_string(value);
}, [=] { }, [=] {
@ -427,7 +427,7 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
} }
{ {
rpl::lifetime lifetime; rpl::lifetime lifetime;
rpl::ints(3) | take(3) ints(3) | take(3)
| start_with_next_done([=](int value) { | start_with_next_done([=](int value) {
*sum += std::to_string(value); *sum += std::to_string(value);
}, [=] { }, [=] {
@ -436,7 +436,7 @@ TEST_CASE("basic operators tests", "[rpl::operators]") {
} }
{ {
rpl::lifetime lifetime; rpl::lifetime lifetime;
rpl::ints(3) | take(10) ints(3) | take(10)
| start_with_next_done([=](int value) { | start_with_next_done([=](int value) {
*sum += std::to_string(value); *sum += std::to_string(value);
}, [=] { }, [=] {

View File

@ -31,8 +31,8 @@ BlockWidget::BlockWidget(QWidget *parent, UserData *self, const QString &title)
, _content(this) , _content(this)
, _self(self) , _self(self)
, _title(title) { , _title(title) {
_content->heightValue() _content->heightValue(
| rpl::start_with_next([this](int contentHeight) { ) | rpl::start_with_next([this](int contentHeight) {
resize( resize(
width(), width(),
contentTop() contentTop()

View File

@ -383,8 +383,8 @@ void CoverWidget::showSetPhotoBox(const QImage &img) {
auto peer = _self; auto peer = _self;
auto box = Ui::show(Box<PhotoCropBox>(img, peer)); auto box = Ui::show(Box<PhotoCropBox>(img, peer));
box->ready() box->ready(
| rpl::start_with_next([=](QImage &&image) { ) | rpl::start_with_next([=](QImage &&image) {
Messenger::Instance().uploadProfilePhoto( Messenger::Instance().uploadProfilePhoto(
std::move(image), std::move(image),
peer->id); peer->id);

View File

@ -79,8 +79,8 @@ void InnerWidget::refreshBlocks() {
_cover->show(); _cover->show();
} }
_blocks->show(); _blocks->show();
_blocks->heightValue() _blocks->heightValue(
| rpl::start_with_next([this](int blocksHeight) { ) | rpl::start_with_next([this](int blocksHeight) {
resize(width(), _blocks->y() + blocksHeight); resize(width(), _blocks->y() + blocksHeight);
}, lifetime()); }, lifetime());
} }

View File

@ -71,8 +71,8 @@ void Layer::resizeToWidth(int newWidth, int newContentLeft) {
void Layer::doSetInnerWidget(object_ptr<LayerInner> widget) { void Layer::doSetInnerWidget(object_ptr<LayerInner> widget) {
_inner = _scroll->setOwnedWidget(std::move(widget)); _inner = _scroll->setOwnedWidget(std::move(widget));
_inner->heightValue() _inner->heightValue(
| rpl::start_with_next([this](int innerHeight) { ) | rpl::start_with_next([this](int innerHeight) {
resizeUsingInnerHeight(width(), innerHeight); resizeUsingInnerHeight(width(), innerHeight);
}, lifetime()); }, lifetime());
} }

View File

@ -60,8 +60,8 @@ void ScaleWidget::createControls() {
_scale->addSection(scaleLabel(dbisOneAndHalf)); _scale->addSection(scaleLabel(dbisOneAndHalf));
_scale->addSection(scaleLabel(dbisTwo)); _scale->addSection(scaleLabel(dbisTwo));
_scale->setActiveSectionFast(cEvalScale(cConfigScale()) - 1); _scale->setActiveSectionFast(cEvalScale(cConfigScale()) - 1);
_scale->sectionActivated() _scale->sectionActivated(
| rpl::start_with_next( ) | rpl::start_with_next(
[this] { scaleChanged(); }, [this] { scaleChanged(); },
lifetime()); lifetime());
} }

View File

@ -36,14 +36,13 @@ std::map<PeerId, SharedMedia::Lists>::iterator
auto &list = result->second[index]; auto &list = result->second[index];
auto type = static_cast<SharedMediaType>(index); auto type = static_cast<SharedMediaType>(index);
list.sliceUpdated() list.sliceUpdated(
| rpl::map([=](const SparseIdsSliceUpdate &update) { ) | rpl::map([=](const SparseIdsSliceUpdate &update) {
return SharedMediaSliceUpdate( return SharedMediaSliceUpdate(
peer, peer,
type, type,
update); update);
}) }) | rpl::start_to_stream(_sliceUpdated, _lifetime);
| rpl::start_to_stream(_sliceUpdated, _lifetime);
} }
return result; return result;
} }

View File

@ -61,7 +61,8 @@ public:
} }
template <typename Handler> template <typename Handler>
void addClickHandler(Handler &&handler) { void addClickHandler(Handler &&handler) {
clicks() | rpl::start_with_next( clicks(
) | rpl::start_with_next(
std::forward<Handler>(handler), std::forward<Handler>(handler),
lifetime()); lifetime());
} }

View File

@ -35,8 +35,8 @@ public:
} }
template <typename Callback> template <typename Callback>
void addMoveLeftCallback(Callback &&callback) { void addMoveLeftCallback(Callback &&callback) {
moveLeft() moveLeft(
| rpl::start_with_next( ) | rpl::start_with_next(
std::forward<Callback>(callback), std::forward<Callback>(callback),
lifetime()); lifetime());
} }
@ -46,8 +46,8 @@ public:
} }
template <typename Callback> template <typename Callback>
void addMoveFinishedCallback(Callback &&callback) { void addMoveFinishedCallback(Callback &&callback) {
moveFinished() moveFinished(
| rpl::start_with_next( ) | rpl::start_with_next(
std::forward<Callback>(callback), std::forward<Callback>(callback),
lifetime()); lifetime());
} }

View File

@ -92,8 +92,9 @@ public:
template <typename Error, typename Generator> template <typename Error, typename Generator>
void showOn(rpl::producer<bool, Error, Generator> &&shown) { void showOn(rpl::producer<bool, Error, Generator> &&shown) {
std::move(shown) std::move(
| rpl::start_with_next([this](bool visible) { shown
) | rpl::start_with_next([this](bool visible) {
callSetVisible(visible); callSetVisible(visible);
}, lifetime()); }, lifetime());
} }

View File

@ -53,11 +53,10 @@ auto SearchFieldController::createRowView(
cancel->addClickHandler([=] { cancel->addClickHandler([=] {
field->setText(QString()); field->setText(QString());
}); });
queryValue() queryValue(
| rpl::map([](const QString &value) { ) | rpl::map([](const QString &value) {
return !value.isEmpty(); return !value.isEmpty();
}) }) | rpl::start_with_next([cancel](bool shown) {
| rpl::start_with_next([cancel](bool shown) {
cancel->toggle(shown, anim::type::normal); cancel->toggle(shown, anim::type::normal);
}, cancel->lifetime()); }, cancel->lifetime());
cancel->finishAnimating(); cancel->finishAnimating();
@ -65,8 +64,8 @@ auto SearchFieldController::createRowView(
auto shadow = CreateChild<Ui::PlainShadow>(wrap); auto shadow = CreateChild<Ui::PlainShadow>(wrap);
shadow->show(); shadow->show();
wrap->widthValue() wrap->widthValue(
| rpl::start_with_next([=, &st](int newWidth) { ) | rpl::start_with_next([=, &st](int newWidth) {
auto availableWidth = newWidth auto availableWidth = newWidth
- st.fieldIconSkip - st.fieldIconSkip
- st.fieldCancelSkip; - st.fieldCancelSkip;
@ -82,8 +81,8 @@ auto SearchFieldController::createRowView(
newWidth, newWidth,
st::lineWidth); st::lineWidth);
}, wrap->lifetime()); }, wrap->lifetime());
wrap->paintRequest() wrap->paintRequest(
| rpl::start_with_next([=, &st] { ) | rpl::start_with_next([=, &st] {
Painter p(wrap); Painter p(wrap);
st.fieldIcon.paint( st.fieldIcon.paint(
p, p,

View File

@ -74,8 +74,8 @@ void SuggestPhoto(
auto box = Ui::show( auto box = Ui::show(
Box<PhotoCropBox>(image, peerForCrop), Box<PhotoCropBox>(image, peerForCrop),
LayerOption::KeepOther); LayerOption::KeepOther);
box->ready() box->ready(
| rpl::start_with_next( ) | rpl::start_with_next(
std::forward<Callback>(callback), std::forward<Callback>(callback),
box->lifetime()); box->lifetime());
} }
@ -498,13 +498,14 @@ void UserpicButton::openPeerPhoto() {
void UserpicButton::setupPeerViewers() { void UserpicButton::setupPeerViewers() {
Notify::PeerUpdateViewer( Notify::PeerUpdateViewer(
_peer, _peer,
Notify::PeerUpdate::Flag::PhotoChanged) Notify::PeerUpdate::Flag::PhotoChanged
| rpl::start_with_next([this] { ) | rpl::start_with_next([this] {
processNewPeerPhoto(); processNewPeerPhoto();
update(); update();
}, lifetime()); }, lifetime());
base::ObservableViewer(Auth().downloaderTaskFinished()) base::ObservableViewer(
| rpl::start_with_next([this] { Auth().downloaderTaskFinished()
) | rpl::start_with_next([this] {
if (_waiting && _peer->userpicLoaded()) { if (_waiting && _peer->userpicLoaded()) {
_waiting = false; _waiting = false;
startNewPhotoShowing(); startNewPhotoShowing();

View File

@ -171,8 +171,9 @@ FlatLabel::FlatLabel(
, _st(st) , _st(st)
, _contextCopyText(lang(lng_context_copy_text)) { , _contextCopyText(lang(lng_context_copy_text)) {
textUpdated(); textUpdated();
std::move(text) std::move(
| rpl::start_with_next([this](const QString &value) { text
) | rpl::start_with_next([this](const QString &value) {
setText(value); setText(value);
}, lifetime()); }, lifetime());
} }
@ -186,8 +187,9 @@ FlatLabel::FlatLabel(
, _st(st) , _st(st)
, _contextCopyText(lang(lng_context_copy_text)) { , _contextCopyText(lang(lng_context_copy_text)) {
textUpdated(); textUpdated();
std::move(text) std::move(
| rpl::start_with_next([this](const TextWithEntities &value) { text
) | rpl::start_with_next([this](const TextWithEntities &value) {
setMarkedText(value); setMarkedText(value);
}, lifetime()); }, lifetime());
} }

View File

@ -71,8 +71,9 @@ FadeWrap<RpWidget> *FadeWrap<RpWidget>::finishAnimating() {
FadeWrap<RpWidget> *FadeWrap<RpWidget>::toggleOn( FadeWrap<RpWidget> *FadeWrap<RpWidget>::toggleOn(
rpl::producer<bool> &&shown) { rpl::producer<bool> &&shown) {
std::move(shown) std::move(
| rpl::start_with_next([this](bool shown) { shown
) | rpl::start_with_next([this](bool shown) {
toggle(shown, anim::type::normal); toggle(shown, anim::type::normal);
}, lifetime()); }, lifetime());
finishAnimating(); finishAnimating();

View File

@ -93,8 +93,9 @@ SlideWrap<RpWidget> *SlideWrap<RpWidget>::finishAnimating() {
SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleOn( SlideWrap<RpWidget> *SlideWrap<RpWidget>::toggleOn(
rpl::producer<bool> &&shown) { rpl::producer<bool> &&shown) {
std::move(shown) std::move(
| rpl::start_with_next([this](bool shown) { shown
) | rpl::start_with_next([this](bool shown) {
toggle(shown, anim::type::normal); toggle(shown, anim::type::normal);
}, lifetime()); }, lifetime());
finishAnimating(); finishAnimating();

View File

@ -117,8 +117,8 @@ RpWidget *VerticalLayout::addChild(
margin, margin,
width() - margins.left() - margins.right(), width() - margins.left() - margins.right(),
height() - margins.top() - margins.bottom()); height() - margins.top() - margins.bottom());
weak->heightValue() weak->heightValue(
| rpl::start_with_next_done([this, weak] { ) | rpl::start_with_next_done([this, weak] {
if (!_inResize) { if (!_inResize) {
childHeightUpdated(weak); childHeightUpdated(weak);
} }

View File

@ -121,14 +121,14 @@ Wrap<Widget, RpWidget>::Wrap(
: RpWidget(parent) : RpWidget(parent)
, _wrapped(std::move(child)) { , _wrapped(std::move(child)) {
if (_wrapped) { if (_wrapped) {
_wrapped->sizeValue() _wrapped->sizeValue(
| rpl::start_with_next([this](const QSize &value) { ) | rpl::start_with_next([this](const QSize &value) {
wrappedSizeUpdated(value); wrappedSizeUpdated(value);
}, lifetime()); }, lifetime());
AttachParentChild(this, _wrapped); AttachParentChild(this, _wrapped);
_wrapped->move(0, 0); _wrapped->move(0, 0);
_wrapped->alive() _wrapped->alive(
| rpl::start_with_done([this] { ) | rpl::start_with_done([this] {
_wrapped->setParent(nullptr); _wrapped->setParent(nullptr);
_wrapped = nullptr; _wrapped = nullptr;
delete this; delete this;

View File

@ -26,8 +26,8 @@ namespace Window {
PlayerWrapWidget::PlayerWrapWidget(QWidget *parent) PlayerWrapWidget::PlayerWrapWidget(QWidget *parent)
: Parent(parent, object_ptr<Media::Player::Widget>(parent)) { : Parent(parent, object_ptr<Media::Player::Widget>(parent)) {
sizeValue() sizeValue(
| rpl::start_with_next([this](const QSize &size) { ) | rpl::start_with_next([this](const QSize &size) {
updateShadowGeometry(size); updateShadowGeometry(size);
}, lifetime()); }, lifetime());
} }

View File

@ -161,8 +161,8 @@ void Filler::addPinToggle() {
auto lifetime = Notify::PeerUpdateViewer( auto lifetime = Notify::PeerUpdateViewer(
peer, peer,
Notify::PeerUpdate::Flag::PinnedChanged) Notify::PeerUpdate::Flag::PinnedChanged
| rpl::start_with_next([peer, pinAction, pinText] { ) | rpl::start_with_next([peer, pinAction, pinText] {
auto isPinned = App::history(peer)->isPinnedDialog(); auto isPinned = App::history(peer)->isPinnedDialog();
pinAction->setText(pinText(isPinned)); pinAction->setText(pinText(isPinned));
}); });
@ -202,10 +202,11 @@ void Filler::addNotifications() {
auto lifetime = Notify::PeerUpdateViewer( auto lifetime = Notify::PeerUpdateViewer(
_peer, _peer,
Notify::PeerUpdate::Flag::NotificationsEnabled) Notify::PeerUpdate::Flag::NotificationsEnabled
| rpl::map([=] { return peer->isMuted(); }) ) | rpl::map([=] {
| rpl::distinct_until_changed() return peer->isMuted();
| rpl::start_with_next([=](bool muted) { }) | rpl::distinct_until_changed(
) | rpl::start_with_next([=](bool muted) {
muteAction->setText(muteText(muted)); muteAction->setText(muteText(muted));
}); });
@ -248,8 +249,8 @@ void Filler::addBlockUser(not_null<UserData*> user) {
auto lifetime = Notify::PeerUpdateViewer( auto lifetime = Notify::PeerUpdateViewer(
_peer, _peer,
Notify::PeerUpdate::Flag::UserIsBlocked) Notify::PeerUpdate::Flag::UserIsBlocked
| rpl::start_with_next([=] { ) | rpl::start_with_next([=] {
blockAction->setText(blockText(user)); blockAction->setText(blockText(user));
}); });