Replaced variable of loading in SessionsBox with rpl::variable.

This commit is contained in:
23rd 2020-09-05 12:54:23 +03:00 committed by John Preston
parent cc9eb7f893
commit 8d2cacac80
2 changed files with 10 additions and 13 deletions

View file

@ -106,15 +106,13 @@ void SessionsBox::prepare() {
shortPollSessions(); shortPollSessions();
}, lifetime()); }, lifetime());
setLoading(true); _loading.changes(
shortPollSessions(); ) | rpl::start_with_next([=](bool value) {
} setInnerVisible(!value);
}, lifetime());
void SessionsBox::setLoading(bool loading) { _loading = true;
if (_loading != loading) { shortPollSessions();
_loading = loading;
setInnerVisible(!_loading);
}
} }
void SessionsBox::resizeEvent(QResizeEvent *e) { void SessionsBox::resizeEvent(QResizeEvent *e) {
@ -128,7 +126,7 @@ void SessionsBox::paintEvent(QPaintEvent *e) {
Painter p(this); Painter p(this);
if (_loading) { if (_loading.current()) {
p.setFont(st::noContactsFont); p.setFont(st::noContactsFont);
p.setPen(st::noContactsColor); p.setPen(st::noContactsColor);
p.drawText( p.drawText(
@ -140,7 +138,7 @@ void SessionsBox::paintEvent(QPaintEvent *e) {
void SessionsBox::got(const MTPaccount_Authorizations &result) { void SessionsBox::got(const MTPaccount_Authorizations &result) {
_shortPollRequest = 0; _shortPollRequest = 0;
setLoading(false); _loading = false;
_data = Full(); _data = Full();
result.match([&](const MTPDaccount_authorizations &data) { result.match([&](const MTPDaccount_authorizations &data) {
@ -339,7 +337,7 @@ void SessionsBox::terminateAll() {
_api.request(base::take(_shortPollRequest)).cancel(); _api.request(base::take(_shortPollRequest)).cancel();
shortPollSessions(); shortPollSessions();
}).send(); }).send();
setLoading(true); _loading = true;
}); });
_terminateBox = Ui::show( _terminateBox = Ui::show(
Box<ConfirmBox>( Box<ConfirmBox>(

View file

@ -51,7 +51,6 @@ private:
static Entry ParseEntry(const MTPDauthorization &data); static Entry ParseEntry(const MTPDauthorization &data);
static void ResizeEntry(Entry &entry); static void ResizeEntry(Entry &entry);
void setLoading(bool loading);
void shortPollSessions(); void shortPollSessions();
void got(const MTPaccount_Authorizations &result); void got(const MTPaccount_Authorizations &result);
@ -62,7 +61,7 @@ private:
const not_null<Main::Session*> _session; const not_null<Main::Session*> _session;
MTP::Sender _api; MTP::Sender _api;
bool _loading = false; rpl::variable<bool> _loading = false;
Full _data; Full _data;
QPointer<Inner> _inner; QPointer<Inner> _inner;