diff --git a/Telegram/SourceFiles/auth_session.cpp b/Telegram/SourceFiles/auth_session.cpp index da9eeb957..ecb9c4156 100644 --- a/Telegram/SourceFiles/auth_session.cpp +++ b/Telegram/SourceFiles/auth_session.cpp @@ -243,13 +243,12 @@ auto AuthSessionData::megagroupParticipantRemoved() const -> rpl::producer> AuthSessionData::megagroupParticipantRemoved( not_null 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> AuthSessionData::megagroupParticipantAdded( not_null 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) { diff --git a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp index dc530290b..ee5a3624a 100644 --- a/Telegram/SourceFiles/boxes/edit_privacy_box.cpp +++ b/Telegram/SourceFiles/boxes/edit_privacy_box.cpp @@ -287,10 +287,10 @@ void EditPrivacyBox::createWidgets() { }; auto createExceptionLink = [this](Exception exception) { exceptionLink(exception).create(this, object_ptr(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); }); }; diff --git a/Telegram/SourceFiles/boxes/notifications_box.cpp b/Telegram/SourceFiles/boxes/notifications_box.cpp index f24f4d596..7cea97cf6 100644 --- a/Telegram/SourceFiles/boxes/notifications_box.cpp +++ b/Telegram/SourceFiles/boxes/notifications_box.cpp @@ -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); diff --git a/Telegram/SourceFiles/boxes/peer_list_box.cpp b/Telegram/SourceFiles/boxes/peer_list_box.cpp index 7fdf7aee4..03b746ca8 100644 --- a/Telegram/SourceFiles/boxes/peer_list_box.cpp +++ b/Telegram/SourceFiles/boxes/peer_list_box.cpp @@ -54,10 +54,10 @@ void PeerListBox::createMultiSelect() { auto entity = object_ptr(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); diff --git a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp index 2f903dbb2..386c4a50d 100644 --- a/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/edit_peer_info_box.cpp @@ -264,17 +264,17 @@ object_ptr 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 Controller::createUsernameEdit() { base::lambda(), 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 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 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(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( this, std::move(content))); diff --git a/Telegram/SourceFiles/boxes/peers/manage_peer_box.cpp b/Telegram/SourceFiles/boxes/peers/manage_peer_box.cpp index 198ed571a..5d3e6f825 100644 --- a/Telegram/SourceFiles/boxes/peers/manage_peer_box.cpp +++ b/Telegram/SourceFiles/boxes/peers/manage_peer_box.cpp @@ -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 channel) { @@ -228,12 +230,12 @@ void ManagePeerBox::prepare() { void ManagePeerBox::setupContent() { auto content = Ui::CreateChild(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()); } diff --git a/Telegram/SourceFiles/boxes/sticker_set_box.cpp b/Telegram/SourceFiles/boxes/sticker_set_box.cpp index 4e2990598..a14cd2e2a 100644 --- a/Telegram/SourceFiles/boxes/sticker_set_box.cpp +++ b/Telegram/SourceFiles/boxes/sticker_set_box.cpp @@ -50,21 +50,21 @@ void StickerSetBox::prepare() { setTitle(langFactory(lng_contacts_loading)); _inner = setInnerWidget(object_ptr(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() { diff --git a/Telegram/SourceFiles/boxes/stickers_box.cpp b/Telegram/SourceFiles/boxes/stickers_box.cpp index 1d0f9c42c..6f35173e8 100644 --- a/Telegram/SourceFiles/boxes/stickers_box.cpp +++ b/Telegram/SourceFiles/boxes/stickers_box.cpp @@ -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()) { diff --git a/Telegram/SourceFiles/calls/calls_box_controller.cpp b/Telegram/SourceFiles/calls/calls_box_controller.cpp index 6080a028a..b2ae0d996 100644 --- a/Telegram/SourceFiles/calls/calls_box_controller.cpp +++ b/Telegram/SourceFiles/calls/calls_box_controller.cpp @@ -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); diff --git a/Telegram/SourceFiles/calls/calls_panel.cpp b/Telegram/SourceFiles/calls/calls_panel.cpp index 290a29b6b..3e1d4abef 100644 --- a/Telegram/SourceFiles/calls/calls_panel.cpp +++ b/Telegram/SourceFiles/calls/calls_panel.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp index 8cfe0d751..6006fa89b 100644 --- a/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp +++ b/Telegram/SourceFiles/chat_helpers/gifs_list_widget.cpp @@ -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(); }); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp index 8b16036b6..ef729e65f 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_panel.cpp @@ -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()); diff --git a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp index e65a19b4e..d95371b17 100644 --- a/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp +++ b/Telegram/SourceFiles/chat_helpers/tabbed_selector.cpp @@ -339,13 +339,13 @@ TabbedSelector::TabbedSelector(QWidget *parent, not_null co } })); - Auth().api().stickerSetInstalled() - | rpl::start_with_next([this](uint64 setId) { - _tabsSlider->setActiveSection( - static_cast(SelectorTab::Stickers)); - stickers()->showStickerSet(setId); - _showRequests.fire({}); - }, lifetime()); + Auth().api().stickerSetInstalled( + ) | rpl::start_with_next([this](uint64 setId) { + _tabsSlider->setActiveSection( + static_cast(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(_currentTabType)); - _tabsSlider->sectionActivated() - | rpl::start_with_next( - [this] { switchTab(); }, - lifetime()); + _tabsSlider->sectionActivated( + ) | rpl::start_with_next( + [this] { switchTab(); }, + lifetime()); } bool TabbedSelector::hasSectionIcons() const { diff --git a/Telegram/SourceFiles/data/data_peer.cpp b/Telegram/SourceFiles/data/data_peer.cpp index b12a1ba97..5e7bc8840 100644 --- a/Telegram/SourceFiles/data/data_peer.cpp +++ b/Telegram/SourceFiles/data/data_peer.cpp @@ -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(); - } - } 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(); } - }, _lifetime); + } else if (mgInfo) { + mgInfo = nullptr; + } + }, _lifetime); } void ChannelData::setPhoto(const MTPChatPhoto &photo) { diff --git a/Telegram/SourceFiles/data/data_peer_values.h b/Telegram/SourceFiles/data/data_peer_values.h index 3b53fd953..a7f9d6dec 100644 --- a/Telegram/SourceFiles/data/data_peer_values.h +++ b/Telegram/SourceFiles/data/data_peer_values.h @@ -31,23 +31,25 @@ template inline auto FlagsValueWithMask( rpl::producer &&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 inline auto SingleFlagValue( rpl::producer &&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 < diff --git a/Telegram/SourceFiles/data/data_search_controller.cpp b/Telegram/SourceFiles/data/data_search_controller.cpp index 27f8f44ea..0bbe1f21a 100644 --- a/Telegram/SourceFiles/data/data_search_controller.cpp +++ b/Telegram/SourceFiles/data/data_search_controller.cpp @@ -260,50 +260,46 @@ rpl::producer 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 item) { - return (item->history()->peer->id == peerId); - }) - | rpl::filter([=](not_null item) { - return builder->removeOne(item->id); - }) - | rpl::start_with_next(pushNextSnapshot, lifetime); + Auth().data().itemRemoved( + ) | rpl::filter([=](not_null item) { + return (item->history()->peer->id == peerId); + }) | rpl::filter([=](not_null item) { + return builder->removeOne(item->id); + }) | rpl::start_with_next(pushNextSnapshot, lifetime); - Auth().data().historyCleared() - | rpl::filter([=](not_null history) { - return (history->peer->id == peerId); - }) - | rpl::filter([=] { return builder->removeAll(); }) - | rpl::start_with_next(pushNextSnapshot, lifetime); + Auth().data().historyCleared( + ) | rpl::filter([=](not_null 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; }; diff --git a/Telegram/SourceFiles/data/data_shared_media.cpp b/Telegram/SourceFiles/data/data_shared_media.cpp index f42dd97ad..fe944be8e 100644 --- a/Telegram/SourceFiles/data/data_shared_media.cpp +++ b/Telegram/SourceFiles/data/data_shared_media.cpp @@ -93,56 +93,50 @@ rpl::producer 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 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); + }); } diff --git a/Telegram/SourceFiles/data/data_sparse_ids.cpp b/Telegram/SourceFiles/data/data_sparse_ids.cpp index c7c1d289b..03ded2d84 100644 --- a/Telegram/SourceFiles/data/data_sparse_ids.cpp +++ b/Telegram/SourceFiles/data/data_sparse_ids.cpp @@ -415,13 +415,14 @@ rpl::producer 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, diff --git a/Telegram/SourceFiles/data/data_user_photos.cpp b/Telegram/SourceFiles/data/data_user_photos.cpp index 9e8478adf..81e6bca38 100644 --- a/Telegram/SourceFiles/data/data_user_photos.cpp +++ b/Telegram/SourceFiles/data/data_user_photos.cpp @@ -233,11 +233,11 @@ rpl::producer 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 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); + }); } \ No newline at end of file diff --git a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp index e0d2710ac..ca1edfd55 100644 --- a/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp +++ b/Telegram/SourceFiles/dialogs/dialogs_inner_widget.cpp @@ -96,16 +96,16 @@ DialogsInner::DialogsInner(QWidget *parent, not_null 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); diff --git a/Telegram/SourceFiles/history/history_admin_log_inner.cpp b/Telegram/SourceFiles/history/history_admin_log_inner.cpp index 9bd9b5974..00dc719d8 100644 --- a/Telegram/SourceFiles/history/history_admin_log_inner.cpp +++ b/Telegram/SourceFiles/history/history_admin_log_inner.cpp @@ -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()) { diff --git a/Telegram/SourceFiles/history/history_inner_widget.cpp b/Telegram/SourceFiles/history/history_inner_widget.cpp index fd41716ca..5e14a378c 100644 --- a/Telegram/SourceFiles/history/history_inner_widget.cpp +++ b/Telegram/SourceFiles/history/history_inner_widget.cpp @@ -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 history) { - return (_history == history); - }) - | rpl::start_with_next([this] { - mouseActionCancel(); - }, lifetime()); + Auth().data().historyCleared() + ) | rpl::filter([this](not_null history) { + return (_history == history); + }) | rpl::start_with_next([this] { + mouseActionCancel(); + }, lifetime()); } void HistoryInner::messagesReceived(PeerData *peer, const QVector &messages) { diff --git a/Telegram/SourceFiles/history/history_top_bar_widget.cpp b/Telegram/SourceFiles/history/history_top_bar_widget.cpp index 49c4bc8ca..6f94944f3 100644 --- a/Telegram/SourceFiles/history/history_top_bar_widget.cpp +++ b/Telegram/SourceFiles/history/history_top_bar_widget.cpp @@ -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 &previous, - const std::tuple ¤t) { - 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 &previous, + const std::tuple ¤t) { + 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(); diff --git a/Telegram/SourceFiles/history/history_widget.cpp b/Telegram/SourceFiles/history/history_widget.cpp index 263ff5887..07b6386b5 100644 --- a/Telegram/SourceFiles/history/history_widget.cpp +++ b/Telegram/SourceFiles/history/history_widget.cpp @@ -552,14 +552,14 @@ HistoryWidget::HistoryWidget(QWidget *parent, not_null 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 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 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) { diff --git a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp index 4c28d591f..f19565e91 100644 --- a/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp +++ b/Telegram/SourceFiles/info/common_groups/info_common_groups_inner_widget.cpp @@ -184,11 +184,11 @@ InnerWidget::InnerWidget( setContent(_list.data()); _listController->setDelegate(static_cast(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::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; } diff --git a/Telegram/SourceFiles/info/info_content_widget.cpp b/Telegram/SourceFiles/info/info_content_widget.cpp index b11be19f9..1817e528f 100644 --- a/Telegram/SourceFiles/info/info_content_widget.cpp +++ b/Telegram/SourceFiles/info/info_content_widget.cpp @@ -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 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 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); diff --git a/Telegram/SourceFiles/info/info_controller.cpp b/Telegram/SourceFiles/info/info_controller.cpp index 59974c923..f5e5bf10d 100644 --- a/Telegram/SourceFiles/info/info_controller.cpp +++ b/Telegram/SourceFiles/info/info_controller.cpp @@ -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( 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(); diff --git a/Telegram/SourceFiles/info/info_layer_widget.cpp b/Telegram/SourceFiles/info/info_layer_widget.cpp index 4e75a9716..7fcd3bf5f 100644 --- a/Telegram/SourceFiles/info/info_layer_widget.cpp +++ b/Telegram/SourceFiles/info/info_layer_widget.cpp @@ -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() { diff --git a/Telegram/SourceFiles/info/info_section_widget.cpp b/Telegram/SourceFiles/info/info_section_widget.cpp index 856392657..2a5d09b1c 100644 --- a/Telegram/SourceFiles/info/info_section_widget.cpp +++ b/Telegram/SourceFiles/info/info_section_widget.cpp @@ -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 { diff --git a/Telegram/SourceFiles/info/info_top_bar.cpp b/Telegram/SourceFiles/info/info_top_bar.cpp index f42a58b85..a5d41b294 100644 --- a/Telegram/SourceFiles/info/info_top_bar.cpp +++ b/Telegram/SourceFiles/info/info_top_bar.cpp @@ -158,10 +158,10 @@ Ui::FadeWrap *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 button) { @@ -440,10 +439,10 @@ void TopBar::createSelectionControls() { object_ptr(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>( this, object_ptr( diff --git a/Telegram/SourceFiles/info/info_wrap_widget.cpp b/Telegram/SourceFiles/info/info_wrap_widget.cpp index ffbfc172b..372ac601e 100644 --- a/Telegram/SourceFiles/info/info_wrap_widget.cpp +++ b/Telegram/SourceFiles/info/info_wrap_widget.cpp @@ -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 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 peer) { + injectActivePeerProfile(peer); + }, lifetime()); } @@ -190,11 +193,12 @@ not_null WrapWidget::peer() const { // _topTabs->setActiveSection(static_cast(_tab)); // _topTabs->finishAnimating(); // -// _topTabs->sectionActivated() -// | rpl::map([](int index) { return static_cast(index); }) -// | rpl::start_with_next( -// [this](Tab tab) { showTab(tab); }, -// lifetime()); +// _topTabs->sectionActivated( +// ) | rpl::map([](int index) { +// return static_cast(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( @@ -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() { diff --git a/Telegram/SourceFiles/info/media/info_media_buttons.h b/Telegram/SourceFiles/info/media/info_media_buttons.h index 38e906739..0dd3a66e8 100644 --- a/Telegram/SourceFiles/info/media/info_media_buttons.h +++ b/Telegram/SourceFiles/info/media/info_media_buttons.h @@ -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>( parent, object_ptr