mirror of
https://github.com/telegramdesktop/tdesktop
synced 2025-08-31 06:26:18 +00:00
Allow editing sessions auto-termination period.
This commit is contained in:
@@ -119,6 +119,7 @@ void Authorizations::reload() {
|
||||
_requestId = 0;
|
||||
_lastReceived = crl::now();
|
||||
result.match([&](const MTPDaccount_authorizations &auths) {
|
||||
_ttlDays = auths.vauthorization_ttl_days().v;
|
||||
_list = (
|
||||
auths.vauthorizations().v
|
||||
) | ranges::views::transform([](const MTPAuthorization &d) {
|
||||
@@ -184,6 +185,22 @@ rpl::producer<int> Authorizations::totalChanges() const {
|
||||
_listChanges.events() | rpl::map([=] { return total(); }));
|
||||
}
|
||||
|
||||
void Authorizations::updateTTL(int days) {
|
||||
_api.request(_ttlRequestId).cancel();
|
||||
_ttlRequestId = _api.request(MTPaccount_SetAuthorizationTTL(
|
||||
MTP_int(days)
|
||||
)).done([=](const MTPBool &result) {
|
||||
_ttlRequestId = 0;
|
||||
}).fail([=](const MTP::Error &result) {
|
||||
_ttlRequestId = 0;
|
||||
}).send();
|
||||
_ttlDays = days;
|
||||
}
|
||||
|
||||
rpl::producer<int> Authorizations::ttlDays() const {
|
||||
return _ttlDays.value() | rpl::filter(rpl::mappers::_1 != 0);
|
||||
}
|
||||
|
||||
int Authorizations::total() const {
|
||||
return ranges::count_if(
|
||||
_list,
|
||||
|
@@ -40,6 +40,9 @@ public:
|
||||
[[nodiscard]] int total() const;
|
||||
[[nodiscard]] rpl::producer<int> totalChanges() const;
|
||||
|
||||
void updateTTL(int days);
|
||||
[[nodiscard]] rpl::producer<int> ttlDays() const;
|
||||
|
||||
private:
|
||||
MTP::Sender _api;
|
||||
mtpRequestId _requestId = 0;
|
||||
@@ -47,6 +50,9 @@ private:
|
||||
List _list;
|
||||
rpl::event_stream<> _listChanges;
|
||||
|
||||
mtpRequestId _ttlRequestId = 0;
|
||||
rpl::variable<int> _ttlDays = 0;
|
||||
|
||||
crl::time _lastReceived = 0;
|
||||
rpl::lifetime _lifetime;
|
||||
|
||||
|
Reference in New Issue
Block a user