2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-09-03 16:05:57 +00:00

Add rpl::take(count).

This commit is contained in:
John Preston
2017-10-01 12:39:07 +03:00
parent f0ad78d808
commit c4d33f9986
9 changed files with 135 additions and 18 deletions

View File

@@ -20,6 +20,9 @@ Copyright (c) 2014-2017 John Preston, https://desktop.telegram.org
*/
#include "boxes/change_phone_box.h"
#include <rpl/filter.h>
#include <rpl/mappers.h>
#include <rpl/take.h>
#include "lang/lang_keys.h"
#include "styles/style_boxes.h"
#include "ui/widgets/labels.h"
@@ -39,13 +42,19 @@ void createErrorLabel(
int y) {
if (label) {
label->hide(anim::type::normal);
auto context = label.data();
App::CallDelayed(
st::fadeWrapDuration,
context,
[old = std::move(label)]() mutable {
old.destroy();
});
auto saved = label.data();
auto destroy = [old = std::move(label)]() mutable {
old.destroyDelayed();
};
using namespace rpl::mappers;
saved->shownValue()
| rpl::filter($1 == false)
| rpl::take(1)
| rpl::start_with_done(
std::move(destroy),
saved->lifetime());
}
if (!text.isEmpty()) {
label.create(