mirror of
https://github.com/bitwarden/mobile
synced 2025-12-15 15:53:44 +00:00
DoOnce helper
This commit is contained in:
@@ -9,6 +9,8 @@ namespace Bit.App.Pages
|
||||
protected int AndroidShowModalAnimationDelay = 400;
|
||||
protected int AndroidShowPageAnimationDelay = 100;
|
||||
|
||||
public DateTime? LastPageAction { get; set; }
|
||||
|
||||
protected void SetActivityIndicator()
|
||||
{
|
||||
Content = new ActivityIndicator
|
||||
@@ -54,5 +56,17 @@ namespace Bit.App.Pages
|
||||
Device.BeginInvokeOnMainThread(() => input.Focus());
|
||||
});
|
||||
}
|
||||
|
||||
protected bool DoOnce(Action action = null, int milliseconds = 1000)
|
||||
{
|
||||
if(LastPageAction.HasValue && (DateTime.UtcNow - LastPageAction.Value).TotalMilliseconds < milliseconds)
|
||||
{
|
||||
// Last action occurred recently.
|
||||
return false;
|
||||
}
|
||||
LastPageAction = DateTime.UtcNow;
|
||||
action?.Invoke();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user