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(
not_null<ChannelData*> channel) const {
return megagroupParticipantRemoved()
| rpl::filter([channel](auto updateChannel, auto user) {
return (updateChannel == channel);
})
| rpl::map([](auto updateChannel, auto user) {
return user;
});
return megagroupParticipantRemoved(
) | rpl::filter([channel](auto updateChannel, auto user) {
return (updateChannel == channel);
}) | rpl::map([](auto updateChannel, auto user) {
return user;
});
}
void AuthSessionData::addNewMegagroupParticipant(
@ -264,13 +263,12 @@ auto AuthSessionData::megagroupParticipantAdded() const -> rpl::producer<Megagro
rpl::producer<not_null<UserData*>> AuthSessionData::megagroupParticipantAdded(
not_null<ChannelData*> channel) const {
return megagroupParticipantAdded()
| rpl::filter([channel](auto updateChannel, auto user) {
return (updateChannel == channel);
})
| rpl::map([](auto updateChannel, auto user) {
return user;
});
return megagroupParticipantAdded(
) | rpl::filter([channel](auto updateChannel, auto user) {
return (updateChannel == channel);
}) | rpl::map([](auto updateChannel, auto user) {
return user;
});
}
void AuthSessionData::setTabbedSelectorSectionEnabled(bool enabled) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -214,19 +214,19 @@ void BoxController::Row::stopLastActionRipple() {
}
void BoxController::prepare() {
Auth().data().itemRemoved()
| rpl::start_with_next([this](auto item) {
if (auto row = rowForItem(item)) {
row->itemRemoved(item);
if (!row->hasItems()) {
delegate()->peerListRemoveRow(row);
if (!delegate()->peerListFullRowsCount()) {
refreshAbout();
}
Auth().data().itemRemoved(
) | rpl::start_with_next([this](auto item) {
if (auto row = rowForItem(item)) {
row->itemRemoved(item);
if (!row->hasItems()) {
delegate()->peerListRemoveRow(row);
if (!delegate()->peerListFullRowsCount()) {
refreshAbout();
}
delegate()->peerListRefreshRows();
}
}, lifetime());
delegate()->peerListRefreshRows();
}
}, lifetime());
subscribe(Current().newServiceMessage(), [this](const FullMsgId &msgId) {
if (auto item = App::histItemById(msgId)) {
insertRow(item, InsertWay::Prepend);

View file

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

View file

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

View file

@ -63,10 +63,10 @@ TabbedPanel::TabbedPanel(
_controller->disableGifPauseReason(Window::GifPauseReason::SavedGifs);
}
});
_selector->showRequests()
| rpl::start_with_next([this] {
this->showFromSelector();
}, lifetime());
_selector->showRequests(
) | rpl::start_with_next([this] {
this->showFromSelector();
}, lifetime());
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()
| rpl::start_with_next([this](uint64 setId) {
_tabsSlider->setActiveSection(
static_cast<int>(SelectorTab::Stickers));
stickers()->showStickerSet(setId);
_showRequests.fire({});
}, lifetime());
Auth().api().stickerSetInstalled(
) | rpl::start_with_next([this](uint64 setId) {
_tabsSlider->setActiveSection(
static_cast<int>(SelectorTab::Stickers));
stickers()->showStickerSet(setId);
_showRequests.fire({});
}, lifetime());
// setAttribute(Qt::WA_AcceptTouchEvents);
setAttribute(Qt::WA_OpaquePaintEvent, false);
@ -638,10 +638,10 @@ void TabbedSelector::createTabsSlider() {
_tabsSlider->setSections(sections);
_tabsSlider->setActiveSectionFast(static_cast<int>(_currentTabType));
_tabsSlider->sectionActivated()
| rpl::start_with_next(
[this] { switchTab(); },
lifetime());
_tabsSlider->sectionActivated(
) | rpl::start_with_next(
[this] { switchTab(); },
lifetime());
}
bool TabbedSelector::hasSectionIcons() const {

View file

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

View file

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

View file

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

View file

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

View file

@ -415,13 +415,14 @@ rpl::producer<SparseIdsMergedSlice> SparseIdsMergedSlice::CreateViewer(
limitAfter
);
if (!key.migratedPeerId) {
return std::move(partViewer)
| rpl::start_with_next([=](SparseIdsSlice &&part) {
consumer.put_next(SparseIdsMergedSlice(
key,
std::move(part),
base::none));
});
return std::move(
partViewer
) | rpl::start_with_next([=](SparseIdsSlice &&part) {
consumer.put_next(SparseIdsMergedSlice(
key,
std::move(part),
base::none));
});
}
auto migratedViewer = simpleViewer(
key.migratedPeerId,

View file

@ -233,11 +233,11 @@ rpl::producer<UserPhotosSlice> UserPhotosViewer(
Auth().storage().query(Storage::UserPhotosQuery(
key,
limitBefore,
limitAfter))
| rpl::start_with_next_done(
applyUpdate,
[=] { builder->checkInsufficientPhotos(); },
lifetime);
limitAfter
)) | rpl::start_with_next_done(
applyUpdate,
[=] { builder->checkInsufficientPhotos(); },
lifetime);
return lifetime;
};
@ -248,9 +248,12 @@ rpl::producer<UserPhotosSlice> UserPhotosReversedViewer(
UserPhotosSlice::Key key,
int limitBefore,
int limitAfter) {
return UserPhotosViewer(key, limitBefore, limitAfter)
| rpl::map([](UserPhotosSlice &&slice) {
slice.reverse();
return std::move(slice);
});
return UserPhotosViewer(
key,
limitBefore,
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();
subscribe(Auth().downloaderTaskFinished(), [this] { update(); });
Auth().data().itemRemoved()
| rpl::start_with_next(
[this](auto item) { itemRemoved(item); },
lifetime());
Auth().data().itemRepaintRequest()
| rpl::start_with_next([this](auto item) {
if (item->history()->lastMsg == item) {
item->history()->updateChatListEntry();
}
}, lifetime());
Auth().data().itemRemoved(
) | rpl::start_with_next(
[this](auto item) { itemRemoved(item); },
lifetime());
Auth().data().itemRepaintRequest(
) | rpl::start_with_next([this](auto item) {
if (item->history()->lastMsg == item) {
item->history()->updateChatListEntry();
}
}, lifetime());
subscribe(App::histories().sendActionAnimationUpdated(), [this](const Histories::SendActionAnimationUpdate &update) {
auto updateRect = Dialogs::Layout::RowPainter::sendActionAnimationRect(update.width, update.height, getFullWidth(), update.textUpdated);
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()) {
setMouseTracking(true);
_scrollDateHideTimer.setCallback([this] { scrollDateHideByTimer(); });
Auth().data().itemRepaintRequest()
| rpl::start_with_next([this](auto item) {
if (item->isLogEntry() && _history == item->history()) {
repaintItem(item);
}
}, lifetime());
Auth().data().itemRepaintRequest(
) | rpl::start_with_next([this](auto item) {
if (item->isLogEntry() && _history == item->history()) {
repaintItem(item);
}
}, lifetime());
subscribe(Auth().data().pendingHistoryResize(), [this] { handlePendingHistoryResize(); });
subscribe(Auth().data().queryItemVisibility(), [this](const AuthSessionData::ItemVisibilityQuery &query) {
if (_history != query.item->history() || !query.item->isLogEntry() || !isVisible()) {

View file

@ -159,19 +159,18 @@ HistoryInner::HistoryInner(
subscribe(_controller->window()->dragFinished(), [this] {
mouseActionUpdate(QCursor::pos());
});
Auth().data().itemRemoved()
| rpl::start_with_next(
[this](auto item) { itemRemoved(item); },
lifetime());
Auth().data().itemRemoved(
) | rpl::start_with_next(
[this](auto item) { itemRemoved(item); },
lifetime());
rpl::merge(
Auth().data().historyUnloaded(),
Auth().data().historyCleared())
| rpl::filter([this](not_null<const History*> history) {
return (_history == history);
})
| rpl::start_with_next([this] {
mouseActionCancel();
}, lifetime());
Auth().data().historyCleared()
) | rpl::filter([this](not_null<const History*> history) {
return (_history == history);
}) | rpl::start_with_next([this] {
mouseActionCancel();
}, lifetime());
}
void HistoryInner::messagesReceived(PeerData *peer, const QVector<MTPMessage> &messages) {

View file

@ -77,26 +77,26 @@ HistoryTopBarWidget::HistoryTopBarWidget(
rpl::combine(
_controller->historyPeer.value(),
_controller->searchInPeer.value())
| rpl::combine_previous(std::make_tuple(nullptr, nullptr))
| rpl::map([](
const std::tuple<PeerData*, PeerData*> &previous,
const std::tuple<PeerData*, PeerData*> &current) {
auto peer = std::get<0>(current);
auto searchPeer = std::get<1>(current);
auto peerChanged = (peer != std::get<0>(previous));
auto searchInPeer
= (peer != nullptr) && (peer == searchPeer);
return std::make_tuple(searchInPeer, peerChanged);
})
| rpl::start_with_next([this](
bool searchInHistoryPeer,
bool peerChanged) {
auto animated = peerChanged
? anim::type::instant
: anim::type::normal;
_search->setForceRippled(searchInHistoryPeer, animated);
}, lifetime());
_controller->searchInPeer.value()
) | rpl::combine_previous(
std::make_tuple(nullptr, nullptr)
) | rpl::map([](
const std::tuple<PeerData*, PeerData*> &previous,
const std::tuple<PeerData*, PeerData*> &current) {
auto peer = std::get<0>(current);
auto searchPeer = std::get<1>(current);
auto peerChanged = (peer != std::get<0>(previous));
auto searchInPeer
= (peer != nullptr) && (peer == searchPeer);
return std::make_tuple(searchInPeer, peerChanged);
}) | rpl::start_with_next([this](
bool searchInHistoryPeer,
bool peerChanged) {
auto animated = peerChanged
? anim::type::instant
: anim::type::normal;
_search->setForceRippled(searchInHistoryPeer, animated);
}, lifetime());
subscribe(Adaptive::Changed(), [this] { updateAdaptiveLayout(); });
if (Adaptive::OneColumn()) {
@ -126,10 +126,10 @@ HistoryTopBarWidget::HistoryTopBarWidget(
rpl::combine(
Auth().data().thirdSectionInfoEnabledValue(),
Auth().data().tabbedReplacedWithInfoValue())
| rpl::start_with_next(
[this] { updateInfoToggleActive(); },
lifetime());
Auth().data().tabbedReplacedWithInfoValue()
) | rpl::start_with_next(
[this] { updateInfoToggleActive(); },
lifetime());
setCursor(style::cur_pointer);
updateControlsVisibility();

View file

@ -552,14 +552,14 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
connect(&_updateEditTimeLeftDisplay, SIGNAL(timeout()), this, SLOT(updateField()));
subscribe(Adaptive::Changed(), [this] { update(); });
Auth().data().itemRemoved()
| rpl::start_with_next(
[this](auto item) { itemRemoved(item); },
lifetime());
Auth().data().itemRepaintRequest()
| rpl::start_with_next(
[this](auto item) { repaintHistoryItem(item); },
lifetime());
Auth().data().itemRemoved(
) | rpl::start_with_next(
[this](auto item) { itemRemoved(item); },
lifetime());
Auth().data().itemRepaintRequest(
) | rpl::start_with_next(
[this](auto item) { repaintHistoryItem(item); },
lifetime());
subscribe(Auth().data().contactsLoaded(), [this](bool) {
if (_peer) {
updateReportSpamStatus();
@ -639,20 +639,20 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null<Window::Controller*> cont
}
}
});
Auth().data().itemLayoutChanged()
| rpl::start_with_next([this](auto item) {
if (_peer && _list) {
if ((item == App::mousedItem())
|| (item == App::hoveredItem())
|| (item == App::hoveredLinkItem())) {
_list->onUpdateSelected();
}
Auth().data().itemLayoutChanged(
) | rpl::start_with_next([this](auto item) {
if (_peer && _list) {
if ((item == App::mousedItem())
|| (item == App::hoveredItem())
|| (item == App::hoveredLinkItem())) {
_list->onUpdateSelected();
}
}, lifetime());
_topBar->membersShowAreaActive()
| rpl::start_with_next([this](bool active) {
setMembersShowAreaActive(active);
}, _topBar->lifetime());
}
}, lifetime());
_topBar->membersShowAreaActive(
) | rpl::start_with_next([this](bool active) {
setMembersShowAreaActive(active);
}, _topBar->lifetime());
Auth().api().sendActions(
) | rpl::start_with_next([this](const ApiWrap::SendOptions &options) {
@ -883,11 +883,11 @@ int HistoryWidget::itemTopForHighlight(not_null<HistoryItem*> item) const {
}
void HistoryWidget::start() {
Auth().data().stickersUpdated()
| rpl::start_with_next([this] {
_tabbedSelector->refreshStickers();
updateStickersByEmoji();
}, lifetime());
Auth().data().stickersUpdated(
) | rpl::start_with_next([this] {
_tabbedSelector->refreshStickers();
updateStickersByEmoji();
}, lifetime());
updateRecentStickers();
Auth().data().markSavedGifsUpdated();
subscribe(Auth().api().fullPeerUpdated(), [this](PeerData *peer) {

View file

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

View file

@ -51,29 +51,29 @@ ContentWidget::ContentWidget(
using namespace rpl::mappers;
setAttribute(Qt::WA_OpaquePaintEvent);
_controller->wrapValue()
| rpl::start_with_next([this](Wrap value) {
if (value != Wrap::Layer) {
applyAdditionalScroll(0);
}
_bg = (value == Wrap::Layer)
? st::boxBg
: st::profileBg;
update();
}, lifetime());
_controller->wrapValue(
) | rpl::start_with_next([this](Wrap value) {
if (value != Wrap::Layer) {
applyAdditionalScroll(0);
}
_bg = (value == Wrap::Layer)
? st::boxBg
: st::profileBg;
update();
}, lifetime());
if (_controller->section().type() != Section::Type::Profile) {
rpl::combine(
_controller->wrapValue(),
_controller->searchEnabledByContent(),
(_1 == Wrap::Layer) && _2)
| rpl::start_with_next([this](bool shown) {
refreshSearchField(shown);
}, lifetime());
}
_scrollTopSkip.changes()
| rpl::start_with_next([this] {
updateControlsGeometry();
(_1 == Wrap::Layer) && _2
) | rpl::start_with_next([this](bool shown) {
refreshSearchField(shown);
}, lifetime());
}
_scrollTopSkip.changes(
) | rpl::start_with_next([this] {
updateControlsGeometry();
}, lifetime());
}
void ContentWidget::resizeEvent(QResizeEvent *e) {
@ -144,15 +144,15 @@ Ui::RpWidget *ContentWidget::doSetInnerWidget(
_scroll->scrollTopValue(),
_scroll->heightValue(),
_innerWrap->entity()->desiredHeightValue(),
tuple(_1, _1 + _2, _3))
| rpl::start_with_next([this](
int top,
int bottom,
int desired) {
_innerDesiredHeight = desired;
_innerWrap->setVisibleTopBottom(top, bottom);
_scrollTillBottomChanges.fire_copy(std::max(desired - bottom, 0));
}, _innerWrap->lifetime());
tuple(_1, _1 + _2, _3)
) | rpl::start_with_next([this](
int top,
int bottom,
int desired) {
_innerDesiredHeight = desired;
_innerWrap->setVisibleTopBottom(top, bottom);
_scrollTillBottomChanges.fire_copy(std::max(desired - bottom, 0));
}, _innerWrap->lifetime());
return _innerWrap->entity();
}
@ -190,16 +190,16 @@ rpl::producer<int> ContentWidget::desiredHeightValue() const {
using namespace rpl::mappers;
return rpl::combine(
_innerWrap->entity()->desiredHeightValue(),
_scrollTopSkip.value())
| rpl::map(_1 + _2);
_scrollTopSkip.value()
) | rpl::map(_1 + _2);
}
rpl::producer<bool> ContentWidget::desiredShadowVisibility() const {
using namespace rpl::mappers;
return rpl::combine(
_scroll->scrollTopValue(),
_scrollTopSkip.value())
| rpl::map((_1 > 0) || (_2 > 0));
_scrollTopSkip.value()
) | rpl::map((_1 > 0) || (_2 > 0));
}
bool ContentWidget::hasTopBarShadow() const {
@ -248,11 +248,11 @@ void ContentWidget::refreshSearchField(bool shown) {
_searchField = rowView.field;
const auto view = _searchWrap.get();
widthValue()
| rpl::start_with_next([=](int newWidth) {
view->resizeToWidth(newWidth);
view->moveToLeft(0, 0);
}, view->lifetime());
widthValue(
) | rpl::start_with_next([=](int newWidth) {
view->resizeToWidth(newWidth);
view->moveToLeft(0, 0);
}, view->lifetime());
view->show();
_searchField->setFocus();
setScrollTopSkip(view->heightNoMargins() - st::lineWidth);

View file

@ -93,22 +93,24 @@ void Controller::setupMigrationViewer() {
if (!_peer->isChat() && (!_peer->isChannel() || _migrated != nullptr)) {
return;
}
Notify::PeerUpdateValue(_peer, Notify::PeerUpdate::Flag::MigrationChanged)
| rpl::start_with_next([this] {
if (_peer->migrateTo() || (_peer->migrateFrom() != _migrated)) {
auto window = parentController();
auto peerId = _peer->id;
auto section = _section;
InvokeQueued(_widget, [=] {
window->showSection(
Memento(peerId, section),
Window::SectionShow(
Window::SectionShow::Way::Backward,
anim::type::instant,
anim::activation::background));
});
}
}, lifetime());
Notify::PeerUpdateValue(
_peer,
Notify::PeerUpdate::Flag::MigrationChanged
) | rpl::start_with_next([this] {
if (_peer->migrateTo() || (_peer->migrateFrom() != _migrated)) {
auto window = parentController();
auto peerId = _peer->id;
auto section = _section;
InvokeQueued(_widget, [=] {
window->showSection(
Memento(peerId, section),
Window::SectionShow(
Window::SectionShow::Way::Backward,
anim::type::instant,
anim::activation::background));
});
}
}, lifetime());
}
Wrap Controller::wrap() const {
@ -160,11 +162,11 @@ void Controller::updateSearchControllers(
= std::make_unique<Ui::SearchFieldController>(
searchQuery);
if (_searchController) {
_searchFieldController->queryValue()
| rpl::start_with_next([=](QString &&query) {
_searchController->setQuery(
produceSearchQuery(std::move(query)));
}, _searchFieldController->lifetime());
_searchFieldController->queryValue(
) | rpl::start_with_next([=](QString &&query) {
_searchController->setQuery(
produceSearchQuery(std::move(query)));
}, _searchFieldController->lifetime());
}
_seachEnabledByContent = memento->searchEnabledByContent();
_searchStartsFocused = memento->searchStartsFocused();

View file

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

View file

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

View file

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

View file

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

View file

@ -68,12 +68,13 @@ inline auto AddCountedButton(
using Button = Profile::Button;
auto forked = std::move(count)
| start_spawning(parent->lifetime());
auto text = rpl::duplicate(forked)
| rpl::map([textFromCount](int count) {
return (count > 0)
? textFromCount(count)
: QString();
});
auto text = rpl::duplicate(
forked
) | rpl::map([textFromCount](int count) {
return (count > 0)
? textFromCount(count)
: QString();
});
auto button = parent->add(object_ptr<Ui::SlideWrap<Button>>(
parent,
object_ptr<Button>(

View file

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

View file

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

View file

@ -560,30 +560,32 @@ ListWidget::ListWidget(
void ListWidget::start() {
_controller->setSearchEnabledByContent(false);
ObservableViewer(*Window::Theme::Background())
| rpl::start_with_next([this](const auto &update) {
if (update.paletteChanged()) {
invalidatePaletteCache();
}
}, lifetime());
ObservableViewer(Auth().downloader().taskFinished())
| rpl::start_with_next([this] { update(); }, lifetime());
Auth().data().itemLayoutChanged()
| rpl::start_with_next([this](auto item) {
itemLayoutChanged(item);
}, lifetime());
Auth().data().itemRemoved()
| rpl::start_with_next([this](auto item) {
itemRemoved(item);
}, lifetime());
Auth().data().itemRepaintRequest()
| rpl::start_with_next([this](auto item) {
repaintItem(item);
}, lifetime());
_controller->mediaSourceQueryValue()
| rpl::start_with_next([this]{
restart();
}, lifetime());
ObservableViewer(
*Window::Theme::Background()
) | rpl::start_with_next([this](const auto &update) {
if (update.paletteChanged()) {
invalidatePaletteCache();
}
}, lifetime());
ObservableViewer(
Auth().downloader().taskFinished()
) | rpl::start_with_next([this] { update(); }, lifetime());
Auth().data().itemLayoutChanged(
) | rpl::start_with_next([this](auto item) {
itemLayoutChanged(item);
}, lifetime());
Auth().data().itemRemoved(
) | rpl::start_with_next([this](auto item) {
itemRemoved(item);
}, lifetime());
Auth().data().itemRepaintRequest(
) | rpl::start_with_next([this](auto item) {
repaintItem(item);
}, lifetime());
_controller->mediaSourceQueryValue(
) | rpl::start_with_next([this]{
restart();
}, lifetime());
}
rpl::producer<int> ListWidget::scrollToRequests() const {
@ -800,19 +802,19 @@ void ListWidget::refreshViewer() {
_controller->mediaSource(
idForViewer,
_idsLimit,
_idsLimit)
| rpl::start_with_next([=](
SparseIdsMergedSlice &&slice) {
if (!slice.fullCount()) {
// Don't display anything while full count is unknown.
return;
}
_slice = std::move(slice);
if (auto nearest = _slice.nearest(idForViewer)) {
_universalAroundId = GetUniversalId(*nearest);
}
refreshRows();
}, _viewerLifetime);
_idsLimit
) | rpl::start_with_next([=](
SparseIdsMergedSlice &&slice) {
if (!slice.fullCount()) {
// Don't display anything while full count is unknown.
return;
}
_slice = std::move(slice);
if (auto nearest = _slice.nearest(idForViewer)) {
_universalAroundId = GetUniversalId(*nearest);
}
refreshRows();
}, _viewerLifetime);
}
BaseLayout *ListWidget::getLayout(UniversalMsgId universalId) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -66,13 +66,13 @@ InnerWidget::InnerWidget(
, _peer(_controller->peer())
, _migrated(_controller->migrated())
, _content(setupContent(this)) {
_content->heightValue()
| rpl::start_with_next([this](int height) {
if (!_inResize) {
resizeToWidth(width());
updateDesiredHeight();
}
}, lifetime());
_content->heightValue(
) | rpl::start_with_next([this](int height) {
if (!_inResize) {
resizeToWidth(width());
updateDesiredHeight();
}
}, lifetime());
}
bool InnerWidget::canHideDetailsEver() const {
@ -122,18 +122,18 @@ object_ptr<Ui::RpWidget> InnerWidget::setupContent(
_controller,
_peer)
);
_members->scrollToRequests()
| rpl::start_with_next([this](Ui::ScrollToRequest request) {
auto min = (request.ymin < 0)
? request.ymin
: mapFromGlobal(_members->mapToGlobal({ 0, request.ymin })).y();
auto max = (request.ymin < 0)
? mapFromGlobal(_members->mapToGlobal({ 0, 0 })).y()
: (request.ymax < 0)
? request.ymax
: mapFromGlobal(_members->mapToGlobal({ 0, request.ymax })).y();
_scrollToRequests.fire({ min, max });
}, _members->lifetime());
_members->scrollToRequests(
) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
auto min = (request.ymin < 0)
? request.ymin
: mapFromGlobal(_members->mapToGlobal({ 0, request.ymin })).y();
auto max = (request.ymin < 0)
? mapFromGlobal(_members->mapToGlobal({ 0, 0 })).y()
: (request.ymax < 0)
? request.ymax
: mapFromGlobal(_members->mapToGlobal({ 0, request.ymax })).y();
_scrollToRequests.fire({ min, max });
}, _members->lifetime());
_cover->setOnlineCount(_members->onlineCountValue());
}
return std::move(result);
@ -198,24 +198,25 @@ object_ptr<Ui::RpWidget> InnerWidget::setupSharedMedia(
//rpl::combine(
// tracker.atLeastOneShownValue(),
// _controller->wrapValue(),
// _isStackBottom.value())
// | rpl::combine_previous(ToggledData())
// | rpl::start_with_next([wrap = result.data()](
// const ToggledData &was,
// const ToggledData &now) {
// bool wasOneShown, wasStackBottom, nowOneShown, nowStackBottom;
// Wrap wasWrap, nowWrap;
// std::tie(wasOneShown, wasWrap, wasStackBottom) = was;
// std::tie(nowOneShown, nowWrap, nowStackBottom) = now;
// // MSVC Internal Compiler Error
// //auto [wasOneShown, wasWrap, wasStackBottom] = was;
// //auto [nowOneShown, nowWrap, nowStackBottom] = now;
// wrap->toggle(
// nowOneShown && (nowWrap != Wrap::Side || !nowStackBottom),
// (wasStackBottom == nowStackBottom && wasWrap == nowWrap)
// ? anim::type::normal
// : anim::type::instant);
// }, result->lifetime());
// _isStackBottom.value()
//) | rpl::combine_previous(
// ToggledData()
//) | rpl::start_with_next([wrap = result.data()](
// const ToggledData &was,
// const ToggledData &now) {
// bool wasOneShown, wasStackBottom, nowOneShown, nowStackBottom;
// Wrap wasWrap, nowWrap;
// std::tie(wasOneShown, wasWrap, wasStackBottom) = was;
// std::tie(nowOneShown, nowWrap, nowStackBottom) = now;
// // MSVC Internal Compiler Error
// //auto [wasOneShown, wasWrap, wasStackBottom] = was;
// //auto [nowOneShown, nowWrap, nowStackBottom] = now;
// wrap->toggle(
// nowOneShown && (nowWrap != Wrap::Side || !nowStackBottom),
// (wasStackBottom == nowStackBottom && wasWrap == nowWrap)
// ? anim::type::normal
// : anim::type::instant);
//}, result->lifetime());
//
// Using that instead
result->setDuration(

View file

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

View file

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

View file

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

View file

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

View file

@ -69,15 +69,15 @@ Widget::Widget(
this,
controller));
_inner->move(0, 0);
_inner->scrollToRequests()
| rpl::start_with_next([this](Ui::ScrollToRequest request) {
if (request.ymin < 0) {
scrollTopRestore(
qMin(scrollTopSave(), request.ymax));
} else {
scrollTo(request);
}
}, lifetime());
_inner->scrollToRequests(
) | rpl::start_with_next([this](Ui::ScrollToRequest request) {
if (request.ymin < 0) {
scrollTopRestore(
qMin(scrollTopSave(), request.ymax));
} else {
scrollTo(request);
}
}, lifetime());
}
void Widget::setIsStackBottom(bool isStackBottom) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -80,30 +80,32 @@ void ParticipantsBoxController::setupListChangeViewers() {
if (!_channel->isMegagroup()) {
return;
}
Auth().data().megagroupParticipantAdded(_channel)
| rpl::start_with_next([this](not_null<UserData*> user) {
if (delegate()->peerListFullRowsCount() > 0) {
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);
Auth().data().megagroupParticipantAdded(
_channel
) | rpl::start_with_next([this](not_null<UserData*> user) {
if (delegate()->peerListFullRowsCount() > 0) {
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();
}, 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() {
@ -270,32 +272,34 @@ std::unique_ptr<PeerListState> ParticipantsBoxController::saveState() const {
if (_channel->isMegagroup()) {
auto weak = result.get();
Auth().data().megagroupParticipantAdded(_channel)
| rpl::start_with_next([weak](not_null<UserData*> user) {
if (!weak->list.empty()) {
if (weak->list[0] == user) {
return;
}
Auth().data().megagroupParticipantAdded(
_channel
) | rpl::start_with_next([weak](not_null<UserData*> user) {
if (!weak->list.empty()) {
if (weak->list[0] == user) {
return;
}
auto pos = ranges::find(weak->list, user);
if (pos == weak->list.cend()) {
weak->list.push_back(user);
}
ranges::stable_partition(
weak->list,
[user](auto peer) { return (peer == user); });
}, my->lifetime);
Auth().data().megagroupParticipantRemoved(_channel)
| rpl::start_with_next([weak](not_null<UserData*> user) {
weak->list.erase(std::remove(
weak->list.begin(),
weak->list.end(),
user), weak->list.end());
weak->filterResults.erase(std::remove(
weak->filterResults.begin(),
weak->filterResults.end(),
user), weak->filterResults.end());
}, my->lifetime);
}
auto pos = ranges::find(weak->list, user);
if (pos == weak->list.cend()) {
weak->list.push_back(user);
}
ranges::stable_partition(
weak->list,
[user](auto peer) { return (peer == user); });
}, my->lifetime);
Auth().data().megagroupParticipantRemoved(
_channel
) | rpl::start_with_next([weak](not_null<UserData*> user) {
weak->list.erase(std::remove(
weak->list.begin(),
weak->list.end(),
user), weak->list.end());
weak->filterResults.erase(std::remove(
weak->filterResults.begin(),
weak->filterResults.end(),
user), weak->filterResults.end());
}, my->lifetime);
}
result->controllerState = std::move(my);
return result;

View file

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

View file

@ -31,14 +31,14 @@ BlockWidget::BlockWidget(QWidget *parent, UserData *self, const QString &title)
, _content(this)
, _self(self)
, _title(title) {
_content->heightValue()
| rpl::start_with_next([this](int contentHeight) {
resize(
width(),
contentTop()
+ contentHeight
+ st::settingsBlockMarginBottom);
}, lifetime());
_content->heightValue(
) | rpl::start_with_next([this](int contentHeight) {
resize(
width(),
contentTop()
+ contentHeight
+ st::settingsBlockMarginBottom);
}, lifetime());
}
void BlockWidget::setContentLeft(int contentLeft) {

View file

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

View file

@ -79,10 +79,10 @@ void InnerWidget::refreshBlocks() {
_cover->show();
}
_blocks->show();
_blocks->heightValue()
| rpl::start_with_next([this](int blocksHeight) {
resize(width(), _blocks->y() + blocksHeight);
}, lifetime());
_blocks->heightValue(
) | rpl::start_with_next([this](int blocksHeight) {
resize(width(), _blocks->y() + blocksHeight);
}, lifetime());
}
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) {
_inner = _scroll->setOwnedWidget(std::move(widget));
_inner->heightValue()
| rpl::start_with_next([this](int innerHeight) {
resizeUsingInnerHeight(width(), innerHeight);
}, lifetime());
_inner->heightValue(
) | rpl::start_with_next([this](int innerHeight) {
resizeUsingInnerHeight(width(), innerHeight);
}, lifetime());
}
void Layer::paintEvent(QPaintEvent *e) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -53,44 +53,43 @@ auto SearchFieldController::createRowView(
cancel->addClickHandler([=] {
field->setText(QString());
});
queryValue()
| rpl::map([](const QString &value) {
return !value.isEmpty();
})
| rpl::start_with_next([cancel](bool shown) {
cancel->toggle(shown, anim::type::normal);
}, cancel->lifetime());
queryValue(
) | rpl::map([](const QString &value) {
return !value.isEmpty();
}) | rpl::start_with_next([cancel](bool shown) {
cancel->toggle(shown, anim::type::normal);
}, cancel->lifetime());
cancel->finishAnimating();
auto shadow = CreateChild<Ui::PlainShadow>(wrap);
shadow->show();
wrap->widthValue()
| rpl::start_with_next([=, &st](int newWidth) {
auto availableWidth = newWidth
- st.fieldIconSkip
- st.fieldCancelSkip;
field->setGeometryToLeft(
st.padding.left() + st.fieldIconSkip,
st.padding.top(),
availableWidth,
field->height());
cancel->moveToRight(0, 0);
shadow->setGeometry(
0,
st.height - st::lineWidth,
newWidth,
st::lineWidth);
}, wrap->lifetime());
wrap->paintRequest()
| rpl::start_with_next([=, &st] {
Painter p(wrap);
st.fieldIcon.paint(
p,
st.padding.left(),
st.padding.top(),
wrap->width());
}, wrap->lifetime());
wrap->widthValue(
) | rpl::start_with_next([=, &st](int newWidth) {
auto availableWidth = newWidth
- st.fieldIconSkip
- st.fieldCancelSkip;
field->setGeometryToLeft(
st.padding.left() + st.fieldIconSkip,
st.padding.top(),
availableWidth,
field->height());
cancel->moveToRight(0, 0);
shadow->setGeometry(
0,
st.height - st::lineWidth,
newWidth,
st::lineWidth);
}, wrap->lifetime());
wrap->paintRequest(
) | rpl::start_with_next([=, &st] {
Painter p(wrap);
st.fieldIcon.paint(
p,
st.padding.left(),
st.padding.top(),
wrap->width());
}, wrap->lifetime());
_view.release();
_view.reset(wrap);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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