2
0
mirror of https://github.com/telegramdesktop/tdesktop synced 2025-08-31 06:26:18 +00:00

Simplified updating of autolock time in Settings::PrivacySecurity.

This commit is contained in:
23rd
2021-05-25 21:31:01 +03:00
parent 77c8bf8176
commit 7852c82eab
2 changed files with 15 additions and 6 deletions

View File

@@ -291,15 +291,24 @@ void SetupLocalPasscode(
Ui::show(Box<PasscodeBox>(&controller->session(), true));
});
const auto autoLockBoxClosing =
container->lifetime().make_state<rpl::event_stream<>>();
const auto label = base::Platform::LastUserInputTimeSupported()
? tr::lng_passcode_autolock_away
: tr::lng_passcode_autolock_inactive;
auto value = PasscodeChanges(
auto value = autoLockBoxClosing->events_starting_with(
rpl::empty_value()
) | rpl::map([] {
const auto autolock = Core::App().settings().autoLock();
return (autolock % 3600)
? tr::lng_passcode_autolock_minutes(tr::now, lt_count, autolock / 60)
: tr::lng_passcode_autolock_hours(tr::now, lt_count, autolock / 3600);
? tr::lng_passcode_autolock_minutes(
tr::now,
lt_count,
autolock / 60)
: tr::lng_passcode_autolock_hours(
tr::now,
lt_count,
autolock / 3600);
});
AddButtonWithLabel(
@@ -308,7 +317,9 @@ void SetupLocalPasscode(
std::move(value),
st::settingsButton
)->addClickHandler([=] {
Ui::show(Box<AutoLockBox>(&controller->session()));
const auto box = Ui::show(Box<AutoLockBox>(&controller->session()));
box->boxClosing(
) | rpl::start_to_stream(*autoLockBoxClosing, box->lifetime());
});
wrap->toggleOn(base::duplicate(has));