mirror of
https://github.com/bitwarden/android.git
synced 2024-12-24 18:08:26 +03:00
fix for bug stopping vault timeout to never (#1618)
- use nullable int on settings page and in vault service
This commit is contained in:
parent
0f992d27b3
commit
318a3e4de9
3 changed files with 9 additions and 9 deletions
|
@ -58,7 +58,7 @@ namespace Bit.App.Pages
|
|||
};
|
||||
|
||||
private Policy _vaultTimeoutPolicy;
|
||||
private int _vaultTimeout;
|
||||
private int? _vaultTimeout;
|
||||
|
||||
public SettingsPageViewModel()
|
||||
{
|
||||
|
@ -223,7 +223,7 @@ namespace Bit.App.Pages
|
|||
await _vaultTimeoutService.LockAsync(true, true);
|
||||
}
|
||||
|
||||
public async Task VaultTimeoutAsync(bool promptOptions = true, int newTimeout = 0)
|
||||
public async Task VaultTimeoutAsync(bool promptOptions = true, int? newTimeout = 0)
|
||||
{
|
||||
var oldTimeout = _vaultTimeout;
|
||||
|
||||
|
@ -240,7 +240,7 @@ namespace Bit.App.Pages
|
|||
var cleanSelection = selection.Replace("✓ ", string.Empty);
|
||||
var selectionOption = _vaultTimeouts.FirstOrDefault(o => o.Key == cleanSelection);
|
||||
_vaultTimeoutDisplayValue = selectionOption.Key;
|
||||
newTimeout = selectionOption.Value.GetValueOrDefault();
|
||||
newTimeout = selectionOption.Value;
|
||||
}
|
||||
|
||||
if (_vaultTimeoutPolicy != null)
|
||||
|
@ -441,7 +441,7 @@ namespace Bit.App.Pages
|
|||
securityItems.Insert(1, new SettingsPageListItem
|
||||
{
|
||||
Name = AppResources.Custom,
|
||||
Time = TimeSpan.FromMinutes(Math.Abs((double)_vaultTimeout)),
|
||||
Time = TimeSpan.FromMinutes(Math.Abs((double)_vaultTimeout.GetValueOrDefault())),
|
||||
});
|
||||
}
|
||||
if (_vaultTimeoutPolicy != null)
|
||||
|
|
|
@ -17,6 +17,6 @@ namespace Bit.Core.Abstractions
|
|||
Task LockAsync(bool allowSoftLock = false, bool userInitiated = false);
|
||||
Task LogOutAsync();
|
||||
Task SetVaultTimeoutOptionsAsync(int? timeout, string action);
|
||||
Task<int> GetVaultTimeout();
|
||||
Task<int?> GetVaultTimeout();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -86,7 +86,7 @@ namespace Bit.Core.Services
|
|||
return;
|
||||
}
|
||||
var vaultTimeoutMinutes = await GetVaultTimeout();
|
||||
if (vaultTimeoutMinutes < 0)
|
||||
if (vaultTimeoutMinutes < 0 || vaultTimeoutMinutes == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -178,8 +178,8 @@ namespace Bit.Core.Services
|
|||
await _storageService.RemoveAsync(Constants.ProtectedPin);
|
||||
}
|
||||
|
||||
public async Task<int> GetVaultTimeout() {
|
||||
var vaultTimeout = (await _storageService.GetAsync<int?>(Constants.VaultTimeoutKey)).GetValueOrDefault(-1);
|
||||
public async Task<int?> GetVaultTimeout() {
|
||||
var vaultTimeout = await _storageService.GetAsync<int?>(Constants.VaultTimeoutKey);
|
||||
|
||||
if (await _policyService.PolicyAppliesToUser(PolicyType.MaximumVaultTimeout)) {
|
||||
var policy = (await _policyService.GetAll(PolicyType.MaximumVaultTimeout)).First();
|
||||
|
@ -190,7 +190,7 @@ namespace Bit.Core.Services
|
|||
return vaultTimeout;
|
||||
}
|
||||
|
||||
var timeout = Math.Min(vaultTimeout, policyTimeout.Value);
|
||||
var timeout = vaultTimeout.HasValue ? Math.Min(vaultTimeout.Value, policyTimeout.Value) : policyTimeout.Value;
|
||||
|
||||
if (timeout < 0) {
|
||||
timeout = policyTimeout.Value;
|
||||
|
|
Loading…
Reference in a new issue