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,13 +243,12 @@ 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; });
});
} }
void AuthSessionData::addNewMegagroupParticipant( void AuthSessionData::addNewMegagroupParticipant(
@ -264,13 +263,12 @@ 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; });
});
} }
void AuthSessionData::setTabbedSelectorSectionEnabled(bool enabled) { void AuthSessionData::setTabbedSelectorSectionEnabled(bool enabled) {

View File

@ -287,10 +287,10 @@ 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,10 +127,10 @@ 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());
setMouseTracking(true); setMouseTracking(true);

View File

@ -54,10 +54,10 @@ 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(); });
_select->entity()->setQueryChangedCallback([this](const QString &query) { searchQueryChanged(query); }); _select->entity()->setQueryChangedCallback([this](const QString &query) { searchQueryChanged(query); });
_select->entity()->setItemRemovedCallback([this](uint64 itemId) { _select->entity()->setItemRemovedCallback([this](uint64 itemId) {
@ -109,10 +109,10 @@ 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());
if (_init) { if (_init) {
_init(this); _init(this);

View File

@ -264,17 +264,17 @@ 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);
titleEdit->moveToLeft(left, 0, width); titleEdit->moveToLeft(left, 0, width);
}, titleEdit->lifetime()); }, titleEdit->lifetime());
return result; return result;
} }
@ -439,16 +439,16 @@ 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());
}, placeholder->lifetime()); }, placeholder->lifetime());
_controls.username->move(placeholder->pos()); _controls.username->move(placeholder->pos());
QObject::connect( QObject::connect(
@ -624,12 +624,12 @@ 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());
}, label->lifetime()); }, label->lifetime());
} }
_usernameResultTexts.fire(std::move(text)); _usernameResultTexts.fire(std::move(text));
} }
@ -729,10 +729,10 @@ 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());
return std::move(result); return std::move(result);
} }
@ -794,10 +794,10 @@ 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());
return std::move(result); return std::move(result);
} }
@ -1437,15 +1437,15 @@ 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>(
this, this,
std::move(content))); std::move(content)));

View File

@ -85,13 +85,15 @@ 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->moveToRight( label->widthValue()
st::managePeerButtonLabelPosition.x(), ) | rpl::start_with_next([label](int outerWidth, int width) {
st::managePeerButtonLabelPosition.y(), label->moveToRight(
outerWidth); st::managePeerButtonLabelPosition.x(),
}, label->lifetime()); st::managePeerButtonLabelPosition.y(),
outerWidth);
}, label->lifetime());
} }
bool HasRecentActions(not_null<ChannelData*> channel) { bool HasRecentActions(not_null<ChannelData*> channel) {
@ -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,21 +50,21 @@ 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());
setDimensions(st::boxWideWidth, st::stickersMaxHeight); setDimensions(st::boxWideWidth, st::stickersMaxHeight);
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());
} }
void StickerSetBox::onAddStickers() { void StickerSetBox::onAddStickers() {

View File

@ -90,11 +90,11 @@ 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());
} }
void StickersBox::CounterWidget::setCounter(int counter) { void StickersBox::CounterWidget::setCounter(int counter) {
@ -242,10 +242,10 @@ 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();
} }
if (_installed.widget() && _section != Section::Installed) _installed.widget()->hide(); if (_installed.widget() && _section != Section::Installed) _installed.widget()->hide();
@ -277,10 +277,10 @@ 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();
if (_installed.widget()) { if (_installed.widget()) {

View File

@ -214,19 +214,19 @@ 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()) {
delegate()->peerListRemoveRow(row); delegate()->peerListRemoveRow(row);
if (!delegate()->peerListFullRowsCount()) { if (!delegate()->peerListFullRowsCount()) {
refreshAbout(); refreshAbout();
}
} }
delegate()->peerListRefreshRows();
} }
}, lifetime()); delegate()->peerListRefreshRows();
}
}, lifetime());
subscribe(Current().newServiceMessage(), [this](const FullMsgId &msgId) { subscribe(Current().newServiceMessage(), [this](const FullMsgId &msgId) {
if (auto item = App::histItemById(msgId)) { if (auto item = App::histItemById(msgId)) {
insertRow(item, InsertWay::Prepend); insertRow(item, InsertWay::Prepend);

View File

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

View File

@ -148,10 +148,10 @@ 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] {
update(); update();
}); });

View File

@ -63,10 +63,10 @@ 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());
resize(QRect(0, 0, st::emojiPanWidth, st::emojiPanMaxHeight).marginsAdded(innerPadding()).size()); resize(QRect(0, 0, st::emojiPanWidth, st::emojiPanMaxHeight).marginsAdded(innerPadding()).size());

View File

@ -339,13 +339,13 @@ 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);
_showRequests.fire({}); _showRequests.fire({});
}, lifetime()); }, lifetime());
// setAttribute(Qt::WA_AcceptTouchEvents); // setAttribute(Qt::WA_AcceptTouchEvents);
setAttribute(Qt::WA_OpaquePaintEvent, false); setAttribute(Qt::WA_OpaquePaintEvent, false);
@ -638,10 +638,10 @@ 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());
} }
bool TabbedSelector::hasSectionIcons() const { bool TabbedSelector::hasSectionIcons() const {

View File

@ -576,16 +576,18 @@ 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,
if (megagroup) { MTPDchannel::Flag::f_megagroup
if (!mgInfo) { ) | rpl::start_with_next([this](bool megagroup) {
mgInfo = std::make_unique<MegagroupInfo>(); if (megagroup) {
} if (!mgInfo) {
} else if (mgInfo) { mgInfo = std::make_unique<MegagroupInfo>();
mgInfo = nullptr;
} }
}, _lifetime); } else if (mgInfo) {
mgInfo = nullptr;
}
}, _lifetime);
} }
void ChannelData::setPhoto(const MTPChatPhoto &photo) { void ChannelData::setPhoto(const MTPChatPhoto &photo) {

View File

@ -31,23 +31,25 @@ 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
return change.diff & mask; ) | rpl::filter([mask](const ChangeType &change) {
}) return change.diff & mask;
| rpl::map([mask](const ChangeType &change) { }) | rpl::map([mask](const ChangeType &change) {
return change.value & mask; return change.value & mask;
}); });
} }
template <typename ChangeType, typename Error, typename Generator> 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),
return !!value; flag
}); ) | rpl::map([flag](typename ChangeType::Type value) {
return !!value;
});
} }
template < template <

View File

@ -260,50 +260,46 @@ 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);
auto pushNextSnapshot = [=] { auto pushNextSnapshot = [=] {
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);
return lifetime; return lifetime;
}; };

View File

@ -93,56 +93,50 @@ 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(
}) pushNextSnapshot,
| rpl::start_with_next_done( [=] { builder->checkInsufficient(); },
pushNextSnapshot, lifetime);
[=] { builder->checkInsufficient(); },
lifetime);
return lifetime; return lifetime;
}; };
@ -353,9 +347,12 @@ 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,
slice.reverse(); limitBefore,
return std::move(slice); limitAfter
}); ) | rpl::map([](SharedMediaWithLastSlice &&slice) {
slice.reverse();
return std::move(slice);
});
} }

View File

@ -415,13 +415,14 @@ 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
consumer.put_next(SparseIdsMergedSlice( ) | rpl::start_with_next([=](SparseIdsSlice &&part) {
key, consumer.put_next(SparseIdsMergedSlice(
std::move(part), key,
base::none)); std::move(part),
}); base::none));
});
} }
auto migratedViewer = simpleViewer( auto migratedViewer = simpleViewer(
key.migratedPeerId, key.migratedPeerId,

View File

@ -233,11 +233,11 @@ 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);
return lifetime; return lifetime;
}; };
@ -248,9 +248,12 @@ 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,
slice.reverse(); limitBefore,
return std::move(slice); limitAfter
}); ) | rpl::map([](UserPhotosSlice &&slice) {
slice.reverse();
return std::move(slice);
});
} }

View File

@ -96,16 +96,16 @@ 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();
} }
}, lifetime()); }, lifetime());
subscribe(App::histories().sendActionAnimationUpdated(), [this](const Histories::SendActionAnimationUpdate &update) { subscribe(App::histories().sendActionAnimationUpdated(), [this](const Histories::SendActionAnimationUpdate &update) {
auto updateRect = Dialogs::Layout::RowPainter::sendActionAnimationRect(update.width, update.height, getFullWidth(), update.textUpdated); auto updateRect = Dialogs::Layout::RowPainter::sendActionAnimationRect(update.width, update.height, getFullWidth(), update.textUpdated);
updateDialogRow(update.history->peer, MsgId(0), updateRect, UpdateRowSection::Default | UpdateRowSection::Filtered); updateDialogRow(update.history->peer, MsgId(0), updateRect, UpdateRowSection::Default | UpdateRowSection::Filtered);

View File

@ -220,12 +220,12 @@ 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);
} }
}, lifetime()); }, lifetime());
subscribe(Auth().data().pendingHistoryResize(), [this] { handlePendingHistoryResize(); }); subscribe(Auth().data().pendingHistoryResize(), [this] { handlePendingHistoryResize(); });
subscribe(Auth().data().queryItemVisibility(), [this](const AuthSessionData::ItemVisibilityQuery &query) { subscribe(Auth().data().queryItemVisibility(), [this](const AuthSessionData::ItemVisibilityQuery &query) {
if (_history != query.item->history() || !query.item->isLogEntry() || !isVisible()) { if (_history != query.item->history() || !query.item->isLogEntry() || !isVisible()) {

View File

@ -159,19 +159,18 @@ 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());
} }
void HistoryInner::messagesReceived(PeerData *peer, const QVector<MTPMessage> &messages) { void HistoryInner::messagesReceived(PeerData *peer, const QVector<MTPMessage> &messages) {

View File

@ -77,26 +77,26 @@ 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)
const std::tuple<PeerData*, PeerData*> &previous, ) | rpl::map([](
const std::tuple<PeerData*, PeerData*> &current) { const std::tuple<PeerData*, PeerData*> &previous,
auto peer = std::get<0>(current); const std::tuple<PeerData*, PeerData*> &current) {
auto searchPeer = std::get<1>(current); auto peer = std::get<0>(current);
auto peerChanged = (peer != std::get<0>(previous)); auto searchPeer = std::get<1>(current);
auto searchInPeer auto peerChanged = (peer != std::get<0>(previous));
= (peer != nullptr) && (peer == searchPeer); auto searchInPeer
return std::make_tuple(searchInPeer, peerChanged); = (peer != nullptr) && (peer == searchPeer);
}) 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
? anim::type::instant ? anim::type::instant
: anim::type::normal; : anim::type::normal;
_search->setForceRippled(searchInHistoryPeer, animated); _search->setForceRippled(searchInHistoryPeer, animated);
}, lifetime()); }, lifetime());
subscribe(Adaptive::Changed(), [this] { updateAdaptiveLayout(); }); subscribe(Adaptive::Changed(), [this] { updateAdaptiveLayout(); });
if (Adaptive::OneColumn()) { if (Adaptive::OneColumn()) {
@ -126,10 +126,10 @@ 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());
setCursor(style::cur_pointer); setCursor(style::cur_pointer);
updateControlsVisibility(); updateControlsVisibility();

View File

@ -552,14 +552,14 @@ 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) {
if (_peer) { if (_peer) {
updateReportSpamStatus(); updateReportSpamStatus();
@ -639,20 +639,20 @@ 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())
|| (item == App::hoveredLinkItem())) { || (item == App::hoveredLinkItem())) {
_list->onUpdateSelected(); _list->onUpdateSelected();
}
} }
}, lifetime()); }
_topBar->membersShowAreaActive() }, lifetime());
| rpl::start_with_next([this](bool active) { _topBar->membersShowAreaActive(
setMembersShowAreaActive(active); ) | rpl::start_with_next([this](bool active) {
}, _topBar->lifetime()); setMembersShowAreaActive(active);
}, _topBar->lifetime());
Auth().api().sendActions( Auth().api().sendActions(
) | rpl::start_with_next([this](const ApiWrap::SendOptions &options) { ) | rpl::start_with_next([this](const ApiWrap::SendOptions &options) {
@ -883,11 +883,11 @@ 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());
updateRecentStickers(); updateRecentStickers();
Auth().data().markSavedGifsUpdated(); Auth().data().markSavedGifsUpdated();
subscribe(Auth().api().fullPeerUpdated(), [this](PeerData *peer) { subscribe(Auth().api().fullPeerUpdated(), [this](PeerData *peer) {

View File

@ -184,11 +184,11 @@ 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());
} }
void InnerWidget::visibleTopBottomUpdated( void InnerWidget::visibleTopBottomUpdated(
@ -224,30 +224,30 @@ 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();
auto addmax = (request.ymax < 0) auto addmax = (request.ymax < 0)
? 0 ? 0
: st::infoCommonGroupsMargin.top(); : st::infoCommonGroupsMargin.top();
_scrollToRequests.fire({ _scrollToRequests.fire({
request.ymin + addmin, request.ymin + addmin,
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();
parent->resize(parent->width(), newHeight); parent->resize(parent->width(), newHeight);
}, result->lifetime()); }, result->lifetime());
return result; return result;
} }

View File

@ -51,29 +51,29 @@ 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);
} }
_bg = (value == Wrap::Layer) _bg = (value == Wrap::Layer)
? st::boxBg ? st::boxBg
: st::profileBg; : st::profileBg;
update(); update();
}, lifetime()); }, lifetime());
if (_controller->section().type() != Section::Type::Profile) { if (_controller->section().type() != Section::Type::Profile) {
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());
}
_scrollTopSkip.changes()
| rpl::start_with_next([this] {
updateControlsGeometry();
}, lifetime()); }, lifetime());
}
_scrollTopSkip.changes(
) | rpl::start_with_next([this] {
updateControlsGeometry();
}, lifetime());
} }
void ContentWidget::resizeEvent(QResizeEvent *e) { void ContentWidget::resizeEvent(QResizeEvent *e) {
@ -144,15 +144,15 @@ 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) {
_innerDesiredHeight = desired; _innerDesiredHeight = desired;
_innerWrap->setVisibleTopBottom(top, bottom); _innerWrap->setVisibleTopBottom(top, bottom);
_scrollTillBottomChanges.fire_copy(std::max(desired - bottom, 0)); _scrollTillBottomChanges.fire_copy(std::max(desired - bottom, 0));
}, _innerWrap->lifetime()); }, _innerWrap->lifetime());
return _innerWrap->entity(); return _innerWrap->entity();
} }
@ -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,11 +248,11 @@ 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->show(); view->show();
_searchField->setFocus(); _searchField->setFocus();
setScrollTopSkip(view->heightNoMargins() - st::lineWidth); setScrollTopSkip(view->heightNoMargins() - st::lineWidth);

View File

@ -93,22 +93,24 @@ 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,
if (_peer->migrateTo() || (_peer->migrateFrom() != _migrated)) { Notify::PeerUpdate::Flag::MigrationChanged
auto window = parentController(); ) | rpl::start_with_next([this] {
auto peerId = _peer->id; if (_peer->migrateTo() || (_peer->migrateFrom() != _migrated)) {
auto section = _section; auto window = parentController();
InvokeQueued(_widget, [=] { auto peerId = _peer->id;
window->showSection( auto section = _section;
Memento(peerId, section), InvokeQueued(_widget, [=] {
Window::SectionShow( window->showSection(
Window::SectionShow::Way::Backward, Memento(peerId, section),
anim::type::instant, Window::SectionShow(
anim::activation::background)); Window::SectionShow::Way::Backward,
}); anim::type::instant,
} anim::activation::background));
}, lifetime()); });
}
}, lifetime());
} }
Wrap Controller::wrap() const { Wrap Controller::wrap() const {
@ -160,11 +162,11 @@ 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());
} }
_seachEnabledByContent = memento->searchEnabledByContent(); _seachEnabledByContent = memento->searchEnabledByContent();
_searchStartsFocused = memento->searchStartsFocused(); _searchStartsFocused = memento->searchStartsFocused();

View File

@ -55,18 +55,19 @@ 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());
}, lifetime());
_content->desiredHeightValue(
) | rpl::start_with_next([this](int height) {
accumulate_max(_desiredHeight, height);
if (_content && !_inResize) {
resizeToWidth(width()); resizeToWidth(width());
}, lifetime()); }
_content->desiredHeightValue() }, lifetime());
| rpl::start_with_next([this](int height) {
accumulate_max(_desiredHeight, height);
if (_content && !_inResize) {
resizeToWidth(width());
}
}, lifetime());
} }
void LayerWidget::showFinished() { void LayerWidget::showFinished() {

View File

@ -49,12 +49,12 @@ 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);
}, _content->lifetime()); }, _content->lifetime());
} }
PeerData *SectionWidget::activePeer() const { PeerData *SectionWidget::activePeer() const {

View File

@ -158,10 +158,10 @@ 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,46 +245,47 @@ 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);
fieldWrap->moveToLeft( fieldWrap->moveToLeft(
_st.searchRow.padding.left(), _st.searchRow.padding.left(),
_st.searchRow.padding.top()); _st.searchRow.padding.top());
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();
wrap->setGeometryToLeft( wrap->setGeometryToLeft(
left, left,
0, 0,
newWidth - left, newWidth - left,
wrap->height(), wrap->height(),
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();
}, _searchView->lifetime()); }, _searchView->lifetime());
_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
auto alreadyInSearch = !field->getLastText().isEmpty(); ) | rpl::start_with_next([=](bool visible) {
_searchModeAvailable = visible || alreadyInSearch; auto alreadyInSearch = !field->getLastText().isEmpty();
updateControlsVisibility(anim::type::instant); _searchModeAvailable = visible || alreadyInSearch;
}, wrap->lifetime()); updateControlsVisibility(anim::type::instant);
}, wrap->lifetime());
} }
void TopBar::removeButton(not_null<Ui::RpWidget*> button) { void TopBar::removeButton(not_null<Ui::RpWidget*> button) {
@ -440,10 +439,10 @@ 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>>(
this, this,
object_ptr<Ui::LabelWithNumbers>( object_ptr<Ui::LabelWithNumbers>(

View File

@ -73,21 +73,22 @@ 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));
}); });
}, lifetime()); }, lifetime());
restoreHistoryStack(memento->takeStack()); restoreHistoryStack(memento->takeStack());
} }
@ -116,12 +117,14 @@ 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(
injectActivePeerProfile(peer); _2
}, lifetime()); ) | rpl::start_with_next([this](not_null<PeerData*> peer) {
injectActivePeerProfile(peer);
}, lifetime());
} }
@ -190,11 +193,12 @@ 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);
// [this](Tab tab) { showTab(tab); }, // }) | rpl::start_with_next(
// lifetime()); // [this](Tab tab) { showTab(tab); },
// lifetime());
// //
// _topTabs->move(0, 0); // _topTabs->move(0, 0);
// _topTabs->resizeToWidth(width()); // _topTabs->resizeToWidth(width());
@ -310,10 +314,10 @@ 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());
_topBar->setTitle(TitleValue( _topBar->setTitle(TitleValue(
_controller->section(), _controller->section(),
@ -321,10 +325,10 @@ 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) {
auto close = _topBar->addButton( auto close = _topBar->addButton(
base::make_unique_q<Ui::IconButton>( base::make_unique_q<Ui::IconButton>(
@ -425,17 +429,18 @@ 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
const auto iconOverride = enabled ) | rpl::start_with_next([notifications](bool enabled) {
? &st::infoNotificationsActive const auto iconOverride = enabled
: nullptr; ? &st::infoNotificationsActive
const auto rippleOverride = enabled : nullptr;
? &st::lightButtonBgOver const auto rippleOverride = enabled
: nullptr; ? &st::lightButtonBgOver
notifications->setIconOverride(iconOverride, iconOverride); : nullptr;
notifications->setRippleColorOverride(rippleOverride); notifications->setIconOverride(iconOverride, iconOverride);
}, notifications->lifetime()); notifications->setRippleColorOverride(rippleOverride);
}, notifications->lifetime());
} }
void WrapWidget::showProfileMenu() { void WrapWidget::showProfileMenu() {

View File

@ -68,12 +68,13 @@ 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
return (count > 0) ) | rpl::map([textFromCount](int count) {
? textFromCount(count) return (count > 0)
: QString(); ? textFromCount(count)
}); : QString();
});
auto button = parent->add(object_ptr<Ui::SlideWrap<Button>>( auto button = parent->add(object_ptr<Ui::SlideWrap<Button>>(
parent, parent,
object_ptr<Button>( object_ptr<Button>(

View File

@ -33,15 +33,16 @@ 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
// Make icon center be on 1/3 height. ) | rpl::start_with_next([this](int fullHeight) {
auto iconCenter = fullHeight / 3; // Make icon center be on 1/3 height.
auto iconHeight = st::infoEmptyFile.height(); auto iconCenter = fullHeight / 3;
auto iconTop = iconCenter - iconHeight / 2; auto iconHeight = st::infoEmptyFile.height();
_height = iconTop + st::infoEmptyIconTop; auto iconTop = iconCenter - iconHeight / 2;
resizeToWidth(width()); _height = iconTop + st::infoEmptyIconTop;
}, lifetime()); resizeToWidth(width());
}, lifetime());
} }
void EmptyWidget::setType(Type type) { void EmptyWidget::setType(Type type) {

View File

@ -44,10 +44,10 @@ 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,11 +63,11 @@ 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());
} }
void InnerWidget::createOtherTypes() { void InnerWidget::createOtherTypes() {
@ -83,10 +83,10 @@ 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());
} }
void InnerWidget::createTypeButtons() { void InnerWidget::createTypeButtons() {
@ -161,18 +161,19 @@ 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);
// [this](Type newType) { // }) | rpl::start_with_next(
// if (type() != newType) { // [this](Type newType) {
// switchToTab(Memento( // if (type() != newType) {
// _controller->peerId(), // switchToTab(Memento(
// _controller->migratedPeerId(), // _controller->peerId(),
// newType)); // _controller->migratedPeerId(),
// } // newType));
// }, // }
// _otherTabs->lifetime()); // },
// _otherTabs->lifetime());
//} //}
Type InnerWidget::type() const { Type InnerWidget::type() const {
@ -233,10 +234,10 @@ 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 {
// _searchField = nullptr; // _searchField = nullptr;
// } // }
@ -254,28 +255,27 @@ 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,30 +560,32 @@ 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()
if (update.paletteChanged()) { ) | rpl::start_with_next([this](const auto &update) {
invalidatePaletteCache(); if (update.paletteChanged()) {
} invalidatePaletteCache();
}, lifetime()); }
ObservableViewer(Auth().downloader().taskFinished()) }, lifetime());
| rpl::start_with_next([this] { update(); }, lifetime()); ObservableViewer(
Auth().data().itemLayoutChanged() Auth().downloader().taskFinished()
| rpl::start_with_next([this](auto item) { ) | rpl::start_with_next([this] { update(); }, lifetime());
itemLayoutChanged(item); Auth().data().itemLayoutChanged(
}, lifetime()); ) | rpl::start_with_next([this](auto item) {
Auth().data().itemRemoved() itemLayoutChanged(item);
| rpl::start_with_next([this](auto item) { }, lifetime());
itemRemoved(item); Auth().data().itemRemoved(
}, lifetime()); ) | rpl::start_with_next([this](auto item) {
Auth().data().itemRepaintRequest() itemRemoved(item);
| rpl::start_with_next([this](auto item) { }, lifetime());
repaintItem(item); Auth().data().itemRepaintRequest(
}, lifetime()); ) | rpl::start_with_next([this](auto item) {
_controller->mediaSourceQueryValue() repaintItem(item);
| rpl::start_with_next([this]{ }, lifetime());
restart(); _controller->mediaSourceQueryValue(
}, lifetime()); ) | rpl::start_with_next([this]{
restart();
}, lifetime());
} }
rpl::producer<int> ListWidget::scrollToRequests() const { rpl::producer<int> ListWidget::scrollToRequests() const {
@ -800,19 +802,19 @@ 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.
return; return;
} }
_slice = std::move(slice); _slice = std::move(slice);
if (auto nearest = _slice.nearest(idForViewer)) { if (auto nearest = _slice.nearest(idForViewer)) {
_universalAroundId = GetUniversalId(*nearest); _universalAroundId = GetUniversalId(*nearest);
} }
refreshRows(); refreshRows();
}, _viewerLifetime); }, _viewerLifetime);
} }
BaseLayout *ListWidget::getLayout(UniversalMsgId universalId) { BaseLayout *ListWidget::getLayout(UniversalMsgId universalId) {

View File

@ -88,10 +88,10 @@ 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());
} }
rpl::producer<SelectedItems> Widget::selectedListValue() const { rpl::producer<SelectedItems> Widget::selectedListValue() const {

View File

@ -230,22 +230,23 @@ 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
auto result = TextWithEntities{ link, {} }; ) | rpl::map([](const QString &link) {
if (!link.isEmpty()) { auto result = TextWithEntities{ link, {} };
auto remove = qstr("https://"); if (!link.isEmpty()) {
if (result.text.startsWith(remove)) { auto remove = qstr("https://");
result.text.remove(0, remove.size()); if (result.text.startsWith(remove)) {
} result.text.remove(0, remove.size());
result.entities.push_back(EntityInText(
EntityInTextCustomUrl,
0,
result.text.size(),
link));
} }
return result; result.entities.push_back(EntityInText(
}); EntityInTextCustomUrl,
0,
result.text.size(),
link));
}
return result;
});
auto link = addInfoOneLine( auto link = addInfoOneLine(
lng_info_link_label, lng_info_link_label,
std::move(linkText), std::move(linkText),
@ -487,10 +488,10 @@ 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();
}); });
}; };
auto sendBotCommand = [=](const QString &command) { auto sendBotCommand = [=](const QString &command) {
auto original = findBotCommand(command); auto original = findBotCommand(command);
@ -523,27 +524,27 @@ 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
? lng_profile_unblock_bot ? lng_profile_unblock_bot
: lng_profile_unblock_user); : lng_profile_unblock_user);
case UserData::BlockStatus::NotBlocked: case UserData::BlockStatus::NotBlocked:
default: default:
return Lang::Viewer(user->botInfo return Lang::Viewer(user->botInfo
? 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
return !text.isEmpty(); ) | rpl::map([](const QString &text) {
}); return !text.isEmpty();
});
auto callback = [user] { auto callback = [user] {
if (user->isBlocked()) { if (user->isBlocked()) {
Auth().api().unblockUser(user); Auth().api().unblockUser(user);
@ -690,15 +691,15 @@ 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(
availableWidth - add->width(), availableWidth - add->width(),
st::infoMembersButtonPosition.y(), st::infoMembersButtonPosition.y(),
newWidth); newWidth);
}, add->lifetime()); }, add->lifetime());
} }
object_ptr<Ui::RpWidget> SetupChannelMembers( object_ptr<Ui::RpWidget> SetupChannelMembers(
@ -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,10 +39,11 @@ 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
setText(std::move(value)); ) | rpl::start_with_next([this](QString &&value) {
}, lifetime()); setText(std::move(value));
}, lifetime());
} }
Button *Button::toggleOn(rpl::producer<bool> &&toggled) { Button *Button::toggleOn(rpl::producer<bool> &&toggled) {
@ -54,10 +55,11 @@ 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
_toggle->setCheckedAnimated(toggled); ) | rpl::start_with_next([this](bool toggled) {
}, lifetime()); _toggle->setCheckedAnimated(toggled);
}, lifetime());
_toggle->finishAnimating(); _toggle->finishAnimating();
return this; return this;
} }

View File

@ -174,17 +174,18 @@ 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
if (_toggle->isHidden() == shown) { ) | rpl::start_with_next([this](bool shown) {
_toggle->setVisible(shown); if (_toggle->isHidden() == shown) {
_toggleShown.fire_copy(shown); _toggle->setVisible(shown);
} _toggleShown.fire_copy(shown);
}, lifetime()); }
}, lifetime());
return this; return this;
} }
@ -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,52 +269,60 @@ 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;
_userpic->moveToLeft( }) | rpl::start_with_next([this](int newWidth) {
st::infoProfilePhotoLeft, _userpic->moveToLeft(
st::infoProfilePhotoTop, st::infoProfilePhotoLeft,
newWidth); st::infoProfilePhotoTop,
refreshNameGeometry(newWidth); newWidth);
refreshStatusGeometry(newWidth); refreshNameGeometry(newWidth);
}, lifetime()); refreshStatusGeometry(newWidth);
}, lifetime());
} }
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
_onlineCount = count; ) | rpl::start_with_next([this](int count) {
refreshStatusText(); _onlineCount = count;
}, lifetime()); refreshStatusText();
}, lifetime());
return this; return this;
} }
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,
[this] { refreshNameText(); }, Flag::NameChanged
lifetime()); ) | rpl::start_with_next(
Notify::PeerUpdateValue(_peer, [this] { refreshNameText(); },
Flag::UserOnlineChanged | Flag::MembersChanged) lifetime());
| rpl::start_with_next( Notify::PeerUpdateValue(
[this] { refreshStatusText(); }, _peer,
lifetime()); Flag::UserOnlineChanged | Flag::MembersChanged
) | rpl::start_with_next(
[this] { refreshStatusText(); },
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
[this] { refreshUploadPhotoOverlay(); }, ) | rpl::start_with_next(
lifetime()); [this] { refreshUploadPhotoOverlay(); },
}
VerifiedValue(_peer)
| rpl::start_with_next(
[this](bool verified) { setVerified(verified); },
lifetime()); lifetime());
}
VerifiedValue(
_peer
) | rpl::start_with_next(
[this](bool verified) { setVerified(verified); },
lifetime());
} }
void Cover::refreshUploadPhotoOverlay() { void Cover::refreshUploadPhotoOverlay() {
@ -335,11 +344,11 @@ 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());
} else { } else {
_verifiedCheck.destroy(); _verifiedCheck.destroy();
} }
@ -465,22 +474,24 @@ 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;
auto availableWidth = newWidth }) | rpl::start_with_next([this, weak = label.data()](int newWidth) {
- st::infoBlockHeaderPosition.x() auto availableWidth = newWidth
- st::infoSharedMediaButton.padding.right() - st::infoBlockHeaderPosition.x()
- toggleSkip(); - st::infoSharedMediaButton.padding.right()
weak->resizeToWidth(availableWidth); - toggleSkip();
weak->moveToLeft( weak->resizeToWidth(availableWidth);
st::infoBlockHeaderPosition.x(), weak->moveToLeft(
st::infoBlockHeaderPosition.y(), st::infoBlockHeaderPosition.x(),
newWidth); st::infoBlockHeaderPosition.y(),
}, label->lifetime()); newWidth);
}, label->lifetime());
} }
} // namespace Profile } // namespace Profile

View File

@ -42,10 +42,10 @@ 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());
} }
void FloatingIcon::paintEvent(QPaintEvent *e) { void FloatingIcon::paintEvent(QPaintEvent *e) {

View File

@ -66,13 +66,13 @@ 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();
} }
}, lifetime()); }, lifetime());
} }
bool InnerWidget::canHideDetailsEver() const { bool InnerWidget::canHideDetailsEver() const {
@ -122,18 +122,18 @@ 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();
auto max = (request.ymin < 0) auto max = (request.ymin < 0)
? mapFromGlobal(_members->mapToGlobal({ 0, 0 })).y() ? mapFromGlobal(_members->mapToGlobal({ 0, 0 })).y()
: (request.ymax < 0) : (request.ymax < 0)
? request.ymax ? request.ymax
: mapFromGlobal(_members->mapToGlobal({ 0, request.ymax })).y(); : mapFromGlobal(_members->mapToGlobal({ 0, request.ymax })).y();
_scrollToRequests.fire({ min, max }); _scrollToRequests.fire({ min, max });
}, _members->lifetime()); }, _members->lifetime());
_cover->setOnlineCount(_members->onlineCountValue()); _cover->setOnlineCount(_members->onlineCountValue());
} }
return std::move(result); return std::move(result);
@ -198,24 +198,25 @@ 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()
// const ToggledData &was, //) | rpl::start_with_next([wrap = result.data()](
// const ToggledData &now) { // const ToggledData &was,
// bool wasOneShown, wasStackBottom, nowOneShown, nowStackBottom; // const ToggledData &now) {
// Wrap wasWrap, nowWrap; // bool wasOneShown, wasStackBottom, nowOneShown, nowStackBottom;
// std::tie(wasOneShown, wasWrap, wasStackBottom) = was; // Wrap wasWrap, nowWrap;
// std::tie(nowOneShown, nowWrap, nowStackBottom) = now; // std::tie(wasOneShown, wasWrap, wasStackBottom) = was;
// // MSVC Internal Compiler Error // std::tie(nowOneShown, nowWrap, nowStackBottom) = now;
// //auto [wasOneShown, wasWrap, wasStackBottom] = was; // // MSVC Internal Compiler Error
// //auto [nowOneShown, nowWrap, nowStackBottom] = now; // //auto [wasOneShown, wasWrap, wasStackBottom] = was;
// wrap->toggle( // //auto [nowOneShown, nowWrap, nowStackBottom] = now;
// nowOneShown && (nowWrap != Wrap::Side || !nowStackBottom), // wrap->toggle(
// (wasStackBottom == nowStackBottom && wasWrap == nowWrap) // nowOneShown && (nowWrap != Wrap::Side || !nowStackBottom),
// ? anim::type::normal // (wasStackBottom == nowStackBottom && wasWrap == nowWrap)
// : anim::type::instant); // ? anim::type::normal
// }, result->lifetime()); // : anim::type::instant);
//}, result->lifetime());
// //
// Using that instead // Using that instead
result->setDuration( result->setDuration(

View File

@ -65,16 +65,17 @@ 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
const auto enabled = (count >= kEnableSearchMembersAfterCount); ) | rpl::start_with_next([this](int count) {
_controller->setSearchEnabledByContent(enabled); const auto enabled = (count >= kEnableSearchMembersAfterCount);
}, lifetime()); _controller->setSearchEnabledByContent(enabled);
}, lifetime());
} }
int Members::desiredHeight() const { int Members::desiredHeight() const {
@ -159,25 +160,25 @@ 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());
} }
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
return lng_chat_status_members(lt_count, count); ) | rpl::map([](int 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,10 +215,10 @@ 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());
} }
void Members::setupList() { void Members::setupList() {
@ -226,31 +227,31 @@ 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();
auto addmax = (request.ymax < 0 || !_header) auto addmax = (request.ymax < 0 || !_header)
? 0 ? 0
: _header->height(); : _header->height();
_scrollToRequests.fire({ _scrollToRequests.fire({
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
+ st::membersMarginBottom) + st::membersMarginBottom)
: 0; : 0;
resize(width(), newHeight); resize(width(), newHeight);
}, _list->lifetime()); }, _list->lifetime());
_list->moveToLeft(0, topSkip); _list->moveToLeft(0, topSkip);
} }

View File

@ -152,10 +152,12 @@ 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,
state->controllerState = nullptr; Flag::MembersChanged
}, my->lifetime); ) | rpl::start_with_next([state = result.get()](auto update) {
state->controllerState = nullptr;
}, my->lifetime);
result->controllerState = std::move(my); result->controllerState = std::move(my);
return result; return result;
} }

View File

@ -45,20 +45,19 @@ 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
const TextWithEntities &value) { ) | rpl::before_next([slide = result.data()](
if (value.text.isEmpty()) { const TextWithEntities &value) {
slide->hide(anim::type::normal); if (value.text.isEmpty()) {
} 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); });
});
auto labeled = layout->add(object_ptr<Ui::FlatLabel>( auto labeled = layout->add(object_ptr<Ui::FlatLabel>(
layout, layout,
std::move(nonEmptyText), std::move(nonEmptyText),

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
return username.isEmpty() ) | rpl::map([](QString &&username) {
? QString() return username.isEmpty()
: ('@' + username); ? QString()
}) : ('@' + 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,39 +103,42 @@ 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(
TextUtilities::ParseEntities(text, flags); ) | rpl::map([=](TextWithEntities &&text) {
return std::move(text); TextUtilities::ParseEntities(text, flags);
}); return std::move(text);
});
} }
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
return username.isEmpty() ) | rpl::map([](QString &&username) {
? QString() return username.isEmpty()
: Messenger::Instance().createInternalLinkFull(username); ? QString()
}); : Messenger::Instance().createInternalLinkFull(username);
});
} }
rpl::producer<bool> NotificationsEnabledValue( 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,20 +148,20 @@ 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;
}); });
} }
rpl::producer<bool> CanShareContactValue( 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();
}); });
} }
rpl::producer<bool> CanAddContactValue( rpl::producer<bool> CanAddContactValue(
@ -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,19 +186,19 @@ 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;
}); });
} 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();
}); });
} }
Unexpected("User in MembersCountViewer()."); Unexpected("User in MembersCountViewer().");
} }
@ -206,12 +208,12 @@ 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;
}); });
} }
rpl::producer<int> RestrictedCountValue( rpl::producer<int> RestrictedCountValue(
@ -219,12 +221,12 @@ 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;
}); });
} }
rpl::producer<int> KickedCountValue( rpl::producer<int> KickedCountValue(
@ -232,12 +234,12 @@ 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;
}); });
} }
rpl::producer<int> SharedMediaCountValue( rpl::producer<int> SharedMediaCountValue(
@ -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,10 +267,10 @@ 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();
}); });
} }
rpl::producer<bool> CanAddMemberValue( rpl::producer<bool> CanAddMemberValue(
@ -277,17 +278,17 @@ 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();
}); });
} }
return rpl::single(false); return rpl::single(false);
} }

View File

@ -69,15 +69,15 @@ 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));
} else { } else {
scrollTo(request); scrollTo(request);
} }
}, lifetime()); }, lifetime());
} }
void Widget::setIsStackBottom(bool isStackBottom) { void Widget::setIsStackBottom(bool isStackBottom) {

View File

@ -500,13 +500,13 @@ 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);
})); }));
} }
} // namespace Lang } // namespace Lang

View File

@ -237,27 +237,25 @@ 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] {
checkFloatPlayerVisibility(); checkFloatPlayerVisibility();
}); });
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() updateThirdColumnToCurrentPeer(peer, canWrite);
| rpl::start_with_next([this](PeerData *peer, bool canWrite) { }, lifetime());
updateThirdColumnToCurrentPeer(peer, canWrite);
}, lifetime());
QCoreApplication::instance()->installEventFilter(this); QCoreApplication::instance()->installEventFilter(this);
@ -1758,10 +1756,10 @@ 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(); });
_playerVolume.create(this); _playerVolume.create(this);
_player->entity()->volumeWidgetCreated(_playerVolume); _player->entity()->volumeWidgetCreated(_playerVolume);
@ -1819,10 +1817,10 @@ 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();
if (_a_show.animating()) { if (_a_show.animating()) {
_callTopBar->show(anim::type::instant); _callTopBar->show(anim::type::instant);

View File

@ -55,21 +55,20 @@ 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();
} }
}, lifetime()); }, lifetime());
setCursor(style::cur_pointer); setCursor(style::cur_pointer);
} }

View File

@ -1008,13 +1008,13 @@ 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);
} }
}); });
_leaveSubscriptions.emplace_back(weak, std::move(subscription)); _leaveSubscriptions.emplace_back(weak, std::move(subscription));
} }
} }

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,10 +121,11 @@ 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
return (update.peer == peer); ) | rpl::filter([=](const PeerUpdate &update) {
}); return (update.peer == peer);
});
} }
rpl::producer<PeerUpdate> PeerUpdateValue( rpl::producer<PeerUpdate> PeerUpdateValue(
@ -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,30 +80,32 @@ 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
if (delegate()->peerListFullRowsCount() > 0) { ) | rpl::start_with_next([this](not_null<UserData*> user) {
if (delegate()->peerListRowAt(0)->peer() == user) { if (delegate()->peerListFullRowsCount() > 0) {
return; if (delegate()->peerListRowAt(0)->peer() == user) {
} return;
}
if (auto row = delegate()->peerListFindRow(user->id)) {
delegate()->peerListPartitionRows([user](const PeerListRow &row) {
return (row.peer() == user);
});
} else {
delegate()->peerListPrependRow(createRow(user));
delegate()->peerListRefreshRows();
sortByOnline();
}
}, lifetime());
Auth().data().megagroupParticipantRemoved(_channel)
| rpl::start_with_next([this](not_null<UserData*> user) {
if (auto row = delegate()->peerListFindRow(user->id)) {
delegate()->peerListRemoveRow(row);
} }
}
if (auto row = delegate()->peerListFindRow(user->id)) {
delegate()->peerListPartitionRows([user](const PeerListRow &row) {
return (row.peer() == user);
});
} else {
delegate()->peerListPrependRow(createRow(user));
delegate()->peerListRefreshRows(); delegate()->peerListRefreshRows();
}, lifetime()); sortByOnline();
}
}, lifetime());
Auth().data().megagroupParticipantRemoved(
_channel
) | rpl::start_with_next([this](not_null<UserData*> user) {
if (auto row = delegate()->peerListFindRow(user->id)) {
delegate()->peerListRemoveRow(row);
}
delegate()->peerListRefreshRows();
}, lifetime());
} }
void ParticipantsBoxController::sortByOnlineDelayed() { void ParticipantsBoxController::sortByOnlineDelayed() {
@ -270,32 +272,34 @@ 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
if (!weak->list.empty()) { ) | rpl::start_with_next([weak](not_null<UserData*> user) {
if (weak->list[0] == user) { if (!weak->list.empty()) {
return; if (weak->list[0] == user) {
} return;
} }
auto pos = ranges::find(weak->list, user); }
if (pos == weak->list.cend()) { auto pos = ranges::find(weak->list, user);
weak->list.push_back(user); if (pos == weak->list.cend()) {
} weak->list.push_back(user);
ranges::stable_partition( }
weak->list, ranges::stable_partition(
[user](auto peer) { return (peer == user); }); weak->list,
}, my->lifetime); [user](auto peer) { return (peer == user); });
Auth().data().megagroupParticipantRemoved(_channel) }, my->lifetime);
| rpl::start_with_next([weak](not_null<UserData*> user) { Auth().data().megagroupParticipantRemoved(
weak->list.erase(std::remove( _channel
weak->list.begin(), ) | rpl::start_with_next([weak](not_null<UserData*> user) {
weak->list.end(), weak->list.erase(std::remove(
user), weak->list.end()); weak->list.begin(),
weak->filterResults.erase(std::remove( weak->list.end(),
weak->filterResults.begin(), user), weak->list.end());
weak->filterResults.end(), weak->filterResults.erase(std::remove(
user), weak->filterResults.end()); weak->filterResults.begin(),
}, my->lifetime); weak->filterResults.end(),
user), weak->filterResults.end());
}, my->lifetime);
} }
result->controllerState = std::move(my); result->controllerState = std::move(my);
return result; return result;

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,14 +31,14 @@ 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()
+ contentHeight + contentHeight
+ st::settingsBlockMarginBottom); + st::settingsBlockMarginBottom);
}, lifetime()); }, lifetime());
} }
void BlockWidget::setContentLeft(int contentLeft) { void BlockWidget::setContentLeft(int contentLeft) {

View File

@ -383,12 +383,12 @@ 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);
}, box->lifetime()); }, box->lifetime());
subscribe(box->boxClosing, [this] { onPhotoUploadStatusChanged(); }); subscribe(box->boxClosing, [this] { onPhotoUploadStatusChanged(); });
} }

View File

@ -79,10 +79,10 @@ 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());
} }
int InnerWidget::resizeGetHeight(int newWidth) { int InnerWidget::resizeGetHeight(int newWidth) {

View File

@ -71,10 +71,10 @@ 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());
} }
void Layer::paintEvent(QPaintEvent *e) { void Layer::paintEvent(QPaintEvent *e) {

View File

@ -60,10 +60,10 @@ 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());
} }
void ScaleWidget::onAutoChanged() { void ScaleWidget::onAutoChanged() {

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,10 +35,10 @@ 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());
} }
rpl::producer<> moveFinished() const { rpl::producer<> moveFinished() const {
@ -46,10 +46,10 @@ 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());
} }
~ResizeArea() { ~ResizeArea() {

View File

@ -92,10 +92,11 @@ 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
callSetVisible(visible); ) | rpl::start_with_next([this](bool visible) {
}, lifetime()); callSetVisible(visible);
}, lifetime());
} }
rpl::lifetime &lifetime(); rpl::lifetime &lifetime();

View File

@ -53,44 +53,43 @@ 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();
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;
field->setGeometryToLeft( field->setGeometryToLeft(
st.padding.left() + st.fieldIconSkip, st.padding.left() + st.fieldIconSkip,
st.padding.top(), st.padding.top(),
availableWidth, availableWidth,
field->height()); field->height());
cancel->moveToRight(0, 0); cancel->moveToRight(0, 0);
shadow->setGeometry( shadow->setGeometry(
0, 0,
st.height - st::lineWidth, st.height - st::lineWidth,
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,
st.padding.left(), st.padding.left(),
st.padding.top(), st.padding.top(),
wrap->width()); wrap->width());
}, wrap->lifetime()); }, wrap->lifetime());
_view.release(); _view.release();
_view.reset(wrap); _view.reset(wrap);

View File

@ -74,10 +74,10 @@ 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());
} }
template <typename Callback> template <typename Callback>
@ -498,18 +498,19 @@ 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()
if (_waiting && _peer->userpicLoaded()) { ) | rpl::start_with_next([this] {
_waiting = false; if (_waiting && _peer->userpicLoaded()) {
startNewPhotoShowing(); _waiting = false;
} startNewPhotoShowing();
}, lifetime()); }
}, lifetime());
} }
void UserpicButton::paintEvent(QPaintEvent *e) { void UserpicButton::paintEvent(QPaintEvent *e) {

View File

@ -171,10 +171,11 @@ 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
setText(value); ) | rpl::start_with_next([this](const QString &value) {
}, lifetime()); setText(value);
}, lifetime());
} }
FlatLabel::FlatLabel( FlatLabel::FlatLabel(
@ -186,10 +187,11 @@ 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
setMarkedText(value); ) | rpl::start_with_next([this](const TextWithEntities &value) {
}, lifetime()); setMarkedText(value);
}, lifetime());
} }
void FlatLabel::init() { void FlatLabel::init() {

View File

@ -71,10 +71,11 @@ 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
toggle(shown, anim::type::normal); ) | rpl::start_with_next([this](bool shown) {
}, lifetime()); toggle(shown, anim::type::normal);
}, lifetime());
finishAnimating(); finishAnimating();
return this; return this;
} }

View File

@ -93,10 +93,11 @@ 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
toggle(shown, anim::type::normal); ) | rpl::start_with_next([this](bool shown) {
}, lifetime()); toggle(shown, anim::type::normal);
}, lifetime());
finishAnimating(); finishAnimating();
return this; return this;
} }

View File

@ -117,14 +117,14 @@ 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);
} }
}, [this, weak] { }, [this, weak] {
removeChild(weak); removeChild(weak);
}, lifetime()); }, lifetime());
return weak; return weak;
} }
return nullptr; return nullptr;

View File

@ -121,18 +121,18 @@ 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;
}, lifetime()); }, lifetime());
} }
} }

View File

@ -26,10 +26,10 @@ 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());
} }
void PlayerWrapWidget::updateShadowGeometry(const QSize &size) { void PlayerWrapWidget::updateShadowGeometry(const QSize &size) {

View File

@ -161,11 +161,11 @@ 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));
}); });
Ui::AttachAsChild(pinAction, std::move(lifetime)); Ui::AttachAsChild(pinAction, std::move(lifetime));
} }
@ -202,12 +202,13 @@ 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(
muteAction->setText(muteText(muted)); ) | rpl::start_with_next([=](bool muted) {
}); muteAction->setText(muteText(muted));
});
Ui::AttachAsChild(muteAction, std::move(lifetime)); Ui::AttachAsChild(muteAction, std::move(lifetime));
} }
@ -248,10 +249,10 @@ 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));
}); });
Ui::AttachAsChild(blockAction, std::move(lifetime)); Ui::AttachAsChild(blockAction, std::move(lifetime));