1
0
mirror of https://github.com/bitwarden/mobile synced 2026-01-06 10:34:07 +00:00

add timeout on timers

This commit is contained in:
Kyle Spearrin
2018-02-01 21:20:35 -05:00
parent dfd39ebc95
commit dd334858ff
4 changed files with 20 additions and 16 deletions

View File

@@ -21,7 +21,8 @@ namespace Bit.App.Pages
private readonly ICipherService _cipherService;
private readonly IDeviceActionService _deviceActionService;
private readonly ITokenService _tokenService;
private bool _pageDisappeared = true;
private DateTime? _timerStarted = null;
private TimeSpan _timerMaxLength = TimeSpan.FromMinutes(5);
public VaultViewCipherPage(CipherType type, string cipherId)
{
@@ -273,7 +274,6 @@ namespace Bit.App.Pages
protected async override void OnAppearing()
{
_pageDisappeared = false;
NotesCell.Tapped += NotesCell_Tapped;
EditItem?.InitEvents();
@@ -291,7 +291,7 @@ namespace Bit.App.Pages
protected override void OnDisappearing()
{
_pageDisappeared = true;
_timerStarted = null;
NotesCell.Tapped -= NotesCell_Tapped;
EditItem?.Dispose();
CleanupAttachmentCells();
@@ -382,9 +382,10 @@ namespace Bit.App.Pages
if(!string.IsNullOrWhiteSpace(Model.LoginTotpCode))
{
TotpTick(totpKey);
_timerStarted = DateTime.Now;
Device.StartTimer(new TimeSpan(0, 0, 1), () =>
{
if(_pageDisappeared)
if(_timerStarted == null || (DateTime.Now - _timerStarted) > _timerMaxLength)
{
return false;
}