Use rpl::empty instead of rpl::empty_value().

This commit is contained in:
John Preston 2022-03-11 09:55:21 +04:00
parent 437fe4ba82
commit 32d09f189b
33 changed files with 57 additions and 119 deletions

View file

@ -309,7 +309,7 @@ void EditCaptionBox::setupShadows() {
void EditCaptionBox::setupControls() {
auto hintLabelToggleOn = _previewRebuilds.events_starting_with(
rpl::empty_value()
{}
) | rpl::map([=] {
return _controller->session().settings().photoEditorHintShown()
? _isPhoto
@ -334,9 +334,7 @@ void EditCaptionBox::setupControls() {
st::defaultBoxCheckbox),
st::editMediaCheckboxMargins)
)->toggleOn(
_previewRebuilds.events_starting_with(
rpl::empty_value()
) | rpl::map([=] {
_previewRebuilds.events_starting_with({}) | rpl::map([=] {
return _isPhoto
&& CanBeCompressed(_albumType)
&& !_preparedList.files.empty();

View file

@ -269,9 +269,7 @@ void EditPrivacyBox::setupContent() {
};
const auto addExceptionLink = [=](Exception exception) {
const auto update = Ui::CreateChild<rpl::event_stream<>>(content);
auto label = update->events_starting_with(
rpl::empty_value()
) | rpl::map([=] {
auto label = update->events_starting_with({}) | rpl::map([=] {
return Settings::ExceptionUsersCount(exceptions(exception));
}) | rpl::map([](int count) {
return count

View file

@ -237,7 +237,7 @@ object_ptr<Ui::RpWidget> CreateFingerprintAndSignalBars(
QImage::Format_ARGB32_Premultiplied);
background->setDevicePixelRatio(cRetinaFactor());
rpl::merge(
rpl::single(rpl::empty_value()),
rpl::single(rpl::empty),
Ui::Emoji::Updated(),
style::PaletteChanged()
) | rpl::start_with_next([=] {

View file

@ -165,9 +165,9 @@ void ScheduleGroupCallBox(
using namespace rpl::mappers;
*duration = rpl::combine(
rpl::single(
rpl::empty_value()
) | rpl::then(base::timer_each(kLabelRefreshInterval)),
rpl::single(rpl::empty) | rpl::then(
base::timer_each(kLabelRefreshInterval)
),
std::move(descriptor.values) | rpl::filter(_1 != 0),
_2
) | rpl::map([](TimeId date) {

View file

@ -728,7 +728,7 @@ void Panel::setupScheduledLabels(rpl::producer<TimeId> date) {
date
) | rpl::map([=](TimeId date) {
_countdownData = std::make_shared<Ui::GroupCallScheduledLeft>(date);
return rpl::empty_value();
return rpl::empty;
}) | rpl::start_spawning(lifetime());
_countdown = Ui::CreateGradientLabel(widget(), rpl::duplicate(
@ -1742,9 +1742,7 @@ void Panel::setupControlsBackgroundNarrow() {
const auto full = lifetime.make_state<QImage>(
QSize(1, height * factor),
QImage::Format_ARGB32_Premultiplied);
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
style::PaletteChanged()
) | rpl::start_with_next([=] {
full->fill(Qt::transparent);

View file

@ -364,9 +364,7 @@ void Row::setupContent(const Set &set) {
) | rpl::map([=](Loader *loader) {
return (loader && loader->id() == _id)
? loader->state()
: rpl::single(
rpl::empty_value()
) | rpl::then(
: rpl::single(rpl::empty) | rpl::then(
Updated()
) | rpl::map([=] {
return ComputeState(_id);

View file

@ -211,9 +211,7 @@ rpl::producer<SparseIdsMergedSlice> SharedScheduledMediaViewer(
const auto history = session->data().history(key.mergedKey.peerId);
return rpl::single(
rpl::empty_value()
) | rpl::then(
return rpl::single(rpl::empty) | rpl::then(
session->data().scheduledMessages().updates(history)
) | rpl::map([=] {
const auto list = session->data().scheduledMessages().list(history);

View file

@ -286,7 +286,7 @@ Widget::Widget(
if (!Core::UpdaterDisabled()) {
Core::UpdateChecker checker;
rpl::merge(
rpl::single(rpl::empty_value()),
rpl::single(rpl::empty),
checker.isLatest(),
checker.failed(),
checker.ready()
@ -303,9 +303,7 @@ Widget::Widget(
_cancelSearch->setClickedCallback([this] { onCancelSearch(); });
_jumpToDate->entity()->setClickedCallback([this] { showCalendar(); });
_chooseFromUser->entity()->setClickedCallback([this] { showSearchFrom(); });
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
session().domain().local().localPasscodeChanged()
) | rpl::start_with_next([=] {
updateLockUnlockVisibility();
@ -519,9 +517,7 @@ void Widget::setupSupportMode() {
void Widget::setupMainMenuToggle() {
_mainMenuToggle->setClickedCallback([=] { showMainMenu(); });
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
controller()->filtersMenuChanged()
) | rpl::start_with_next([=] {
const auto filtersHidden = !controller()->filtersWidth();

View file

@ -352,9 +352,9 @@ PhotoEditorControls::PhotoEditorControls(
}, _stickersButton->lifetime());
}
rpl::single(
rpl::empty_value()
) | rpl::skip(modifications.flipped ? 0 : 1) | rpl::then(
rpl::single(rpl::empty) | rpl::skip(
modifications.flipped ? 0 : 1
) | rpl::then(
_flipButton->clicks() | rpl::to_empty
) | rpl::start_with_next([=] {
_flipped = !_flipped;

View file

@ -1600,9 +1600,7 @@ void SetupManagerList(
not_null<Main::Session*> session,
rpl::producer<std::optional<base::flat_set<QString>>> filter) {
const auto reactions = &session->data().reactions();
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
reactions->updates()
) | rpl::start_with_next([=] {
manager->applyList(

View file

@ -1096,9 +1096,7 @@ rpl::producer<Data::MessagesSlice> ScheduledWidget::listSource(
int limitBefore,
int limitAfter) {
const auto data = &controller()->session().data();
return rpl::single(
rpl::empty_value()
) | rpl::then(
return rpl::single(rpl::empty) | rpl::then(
data->scheduledMessages().updates(_history)
) | rpl::map([=] {
return data->scheduledMessages().list(_history);

View file

@ -89,9 +89,7 @@ void Provider::refreshViewer() {
return;
}
auto &manager = Core::App().downloadManager();
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
manager.loadingListChanges() | rpl::to_empty
) | rpl::start_with_next([=, &manager] {
auto copy = _downloading;

View file

@ -405,9 +405,7 @@ rpl::producer<bool> CanAddMemberValue(not_null<PeerData*> peer) {
rpl::producer<int> FullReactionsCountValue(
not_null<Main::Session*> session) {
const auto reactions = &session->data().reactions();
return rpl::single(
rpl::empty_value()
) | rpl::then(
return rpl::single(rpl::empty) | rpl::then(
reactions->updates()
) | rpl::map([=] {
return int(reactions->list(Data::Reactions::Type::Active).size());

View file

@ -75,9 +75,7 @@ namespace {
) | rpl::map([](const QByteArray &code) {
return Qr::Encode(code, Qr::Redundancy::Quartile);
});
auto palettes = rpl::single(
rpl::empty_value()
) | rpl::then(
auto palettes = rpl::single(rpl::empty) | rpl::then(
style::PaletteChanged()
);
auto result = Ui::CreateChild<Ui::RpWidget>(parent.get());

View file

@ -149,7 +149,7 @@ Widget::Widget(
Core::UpdateChecker checker;
checker.start();
rpl::merge(
rpl::single(rpl::empty_value()),
rpl::single(rpl::empty),
checker.isLatest(),
checker.failed(),
checker.ready()

View file

@ -688,9 +688,7 @@ TimeId CalculateOnlineTill(not_null<PeerData*> peer) {
updateUserpics();
};
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
_session->data().pinnedDialogsOrderUpdated()
) | rpl::start_with_next(updatePinnedChats, _lifetime);

View file

@ -443,9 +443,7 @@ void FilterRowButton::paintEvent(QPaintEvent *e) {
AddSubsectionTitle(aboutRows, tr::lng_filters_recommended());
const auto suggested = lifetime.make_state<rpl::variable<int>>();
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
session->data().chatsFilters().suggestedUpdated()
) | rpl::map([=] {
return session->data().chatsFilters().suggestedFilters();

View file

@ -301,9 +301,7 @@ void SetupSections(
}
};
slided->toggleOn(
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
account->appConfig().refreshed()
) | rpl::map(
enabled

View file

@ -229,9 +229,7 @@ void SetupLocalPasscode(
AddSkip(container);
AddSubsectionTitle(container, tr::lng_settings_passcode_title());
auto has = rpl::single(
rpl::empty_value()
) | rpl::then(
auto has = rpl::single(rpl::empty) | rpl::then(
controller->session().domain().local().localPasscodeChanged()
) | rpl::map([=] {
return controller->session().domain().local().hasLocalPasscode();
@ -272,7 +270,7 @@ void SetupLocalPasscode(
? tr::lng_passcode_autolock_away
: tr::lng_passcode_autolock_inactive;
auto value = autoLockBoxClosing->events_starting_with(
rpl::empty_value()
{}
) | rpl::map([] {
const auto autolock = Core::App().settings().autoLock();
const auto hours = autolock / 3600;
@ -471,9 +469,7 @@ void SetupCloudPassword(
) | rpl::filter([](TimeId time) {
return time != 0;
}) | rpl::map([](TimeId time) {
return rpl::single(
rpl::empty_value()
) | rpl::then(base::timer_each(
return rpl::single(rpl::empty) | rpl::then(base::timer_each(
999
)) | rpl::map([=] {
const auto now = base::unixtime::now();

View file

@ -47,9 +47,7 @@ ItemSingleFilePreview::ItemSingleFilePreview(
_documentMedia = document->createMediaView();
_documentMedia->thumbnailWanted(item->fullId());
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
document->session().downloaderTaskFinished()
) | rpl::start_with_next([=] {
if (_documentMedia->thumbnail()) {

View file

@ -82,9 +82,7 @@ ItemSingleMediaPreview::ItemSingleMediaPreview(
}
};
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
session->downloaderTaskFinished()
) | rpl::start_with_next([=] {
const auto computed = computeThumbInfo();

View file

@ -181,7 +181,7 @@ void SetupSendAsButton(
const auto channel = peer->asMegagroup();
auto updates = rpl::single(
rpl::empty_value()
rpl::empty
) | rpl::then(channel->session().sendAsPeers().updated(
) | rpl::filter(
_1 == channel

View file

@ -231,9 +231,7 @@ void GroupCallBar::setupInner() {
static_cast<QMouseEvent*>(event.get())->pos());
});
}) | rpl::flatten_latest(
) | rpl::map([] {
return rpl::empty_value();
}) | rpl::start_to_stream(_barClicks, _inner->lifetime());
) | rpl::to_empty | rpl::start_to_stream(_barClicks, _inner->lifetime());
_wrap.geometryValue(
) | rpl::start_with_next([=](QRect rect) {

View file

@ -135,13 +135,15 @@ void PinnedBar::createControls() {
static_cast<QMouseEvent*>(event.get())->pos());
});
}) | rpl::flatten_latest(
) | rpl::map([] {
return rpl::empty_value();
}) | rpl::start_to_stream(_barClicks, _bar->widget()->lifetime());
) | rpl::to_empty | rpl::start_to_stream(
_barClicks,
_bar->widget()->lifetime());
_bar->widget()->move(0, 0);
_bar->widget()->show();
_wrap.entity()->resize(_wrap.entity()->width(), _bar->widget()->height());
_wrap.entity()->resize(
_wrap.entity()->width(),
_bar->widget()->height());
_wrap.geometryValue(
) | rpl::start_with_next([=](QRect rect) {

View file

@ -124,9 +124,7 @@ void RequestsBar::setupInner() {
static_cast<QMouseEvent*>(event.get())->pos());
});
}) | rpl::flatten_latest(
) | rpl::map([] {
return rpl::empty_value();
}) | rpl::start_to_stream(_barClicks, _inner->lifetime());
) | rpl::to_empty | rpl::start_to_stream(_barClicks, _inner->lifetime());
_wrap.geometryValue(
) | rpl::start_with_next([=](QRect rect) {

View file

@ -74,9 +74,7 @@ AbstractSectionWidget::AbstractSectionWidget(
peerForBackground
) | rpl::map([=](PeerData *peer) -> rpl::producer<> {
if (!peer) {
return rpl::single(
rpl::empty_value()
) | rpl::then(
return rpl::single(rpl::empty) | rpl::then(
controller->defaultChatTheme()->repaintBackgroundRequests()
);
}
@ -84,9 +82,7 @@ AbstractSectionWidget::AbstractSectionWidget(
controller,
peer
) | rpl::map([](const std::shared_ptr<Ui::ChatTheme> &theme) {
return rpl::single(
rpl::empty_value()
) | rpl::then(
return rpl::single(rpl::empty) | rpl::then(
theme->repaintBackgroundRequests()
);
}) | rpl::flatten_latest();

View file

@ -1371,9 +1371,7 @@ rpl::producer<bool> IsNightModeValue() {
return update.type == BackgroundUpdate::Type::ApplyingTheme;
}) | rpl::to_empty;
return rpl::single(
rpl::empty_value()
) | rpl::then(
return rpl::single(rpl::empty) | rpl::then(
std::move(changes)
) | rpl::map([=] {
return IsNightMode();
@ -1455,9 +1453,7 @@ bool LoadFromContent(
}
rpl::producer<bool> IsThemeDarkValue() {
return rpl::single(
rpl::empty_value()
) | rpl::then(
return rpl::single(rpl::empty) | rpl::then(
style::PaletteChanged()
) | rpl::map([] {
return (st::dialogsBg->c.valueF() < kDarkValueThreshold);

View file

@ -336,9 +336,7 @@ void CloudList::setup() {
object.cloud.id ? object.cloud.id : kFakeCloudThemeId));
});
auto cloudListChanges = rpl::single(
rpl::empty_value()
) | rpl::then(
auto cloudListChanges = rpl::single(rpl::empty) | rpl::then(
_window->session().data().cloudThemes().updated()
);

View file

@ -222,7 +222,7 @@ ConnectionState::ConnectionState(
if (!Core::UpdaterDisabled()) {
Core::UpdateChecker checker;
rpl::merge(
rpl::single(rpl::empty_value()),
rpl::single(rpl::empty),
checker.ready()
) | rpl::start_with_next([=] {
refreshState();

View file

@ -34,7 +34,7 @@ namespace {
[[nodiscard]] rpl::producer<Dialogs::UnreadState> MainListUnreadState(
not_null<Dialogs::MainList*> list) {
return rpl::single(rpl::empty_value()) | rpl::then(
return rpl::single(rpl::empty) | rpl::then(
list->unreadStateChanges() | rpl::to_empty
) | rpl::map([=] {
return list->unreadState();
@ -103,9 +103,7 @@ void FiltersMenu::setup() {
}, _outer.lifetime());
const auto filters = &_session->session().data().chatsFilters();
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
filters->changed()
) | rpl::start_with_next([=] {
refresh();

View file

@ -240,9 +240,7 @@ void AddUnreadBadge(
const auto state = raw->lifetime().make_state<State>(raw);
if (!active) {
AddUnreadBadge(raw, rpl::single(
rpl::empty_value()
) | rpl::then(
AddUnreadBadge(raw, rpl::single(rpl::empty) | rpl::then(
session->data().unreadBadgeChanges()
) | rpl::map([=] {
auto &owner = session->data();
@ -380,9 +378,7 @@ protected:
MainMenu::ToggleAccountsButton::ToggleAccountsButton(QWidget *parent)
: AbstractButton(parent) {
rpl::single(
rpl::empty_value()
) | rpl::then(
rpl::single(rpl::empty) | rpl::then(
Core::App().unreadBadgeChanges()
) | rpl::start_with_next([=] {
_unreadBadgeStale = true;
@ -743,9 +739,7 @@ void MainMenu::setupArchive() {
return folder && (folder->id() == Data::Folder::kId);
}) | rpl::take(1);
AddUnreadBadge(button, rpl::single(
rpl::empty_value()
) | rpl::then(std::move(
AddUnreadBadge(button, rpl::single(rpl::empty) | rpl::then(std::move(
folderValue
) | rpl::map([=](not_null<Data::Folder*> folder) {
return folder->owner().chatsList(folder)->unreadStateChanges();
@ -789,10 +783,9 @@ void MainMenu::setupAccounts() {
_addAccount = setupAddAccount(inner);
inner->add(object_ptr<Ui::FixedHeightWidget>(inner, st::mainMenuSkip));
rpl::single(
rpl::empty_value()
) | rpl::then(Core::App().domain().accountsChanges(
)) | rpl::start_with_next([=] {
rpl::single(rpl::empty) | rpl::then(
Core::App().domain().accountsChanges()
) | rpl::start_with_next([=] {
const auto &list = Core::App().domain().accounts();
const auto exists = [&](not_null<Main::Account*> account) {
for (const auto &[index, existing] : list) {
@ -1206,12 +1199,9 @@ OthersUnreadState OtherAccountsUnreadStateCurrent() {
}
rpl::producer<OthersUnreadState> OtherAccountsUnreadState() {
return rpl::single(
rpl::empty_value()
) | rpl::then(
return rpl::single(rpl::empty) | rpl::then(
Core::App().unreadBadgeChanges()
) | rpl::map(OtherAccountsUnreadStateCurrent);
}
} // namespace Window

@ -1 +1 @@
Subproject commit 3669e28e8767669dda7ff2d847eb2e30d18ea796
Subproject commit 03698385aa794fafd613a745371b5ade556ce5fa

@ -1 +1 @@
Subproject commit 94a42b775ab4e46e5edeb88d8ed6c06f9e869c61
Subproject commit 6ee3948b61cffdab672d75ea33266ea00731b3cf