mirror of
https://github.com/bitwarden/android.git
synced 2024-10-31 23:25:45 +03:00
more do once checks
This commit is contained in:
parent
5ef4c96ee7
commit
2816e72aa9
4 changed files with 26 additions and 14 deletions
|
@ -11,6 +11,18 @@ namespace Bit.App.Pages
|
|||
|
||||
public DateTime? LastPageAction { get; set; }
|
||||
|
||||
public 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;
|
||||
}
|
||||
|
||||
protected void SetActivityIndicator()
|
||||
{
|
||||
Content = new ActivityIndicator
|
||||
|
@ -56,17 +68,5 @@ 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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -106,6 +106,10 @@ namespace Bit.App.Pages
|
|||
|
||||
private async void CipherOptionsAsync(CipherView cipher)
|
||||
{
|
||||
if(!(Page as BaseContentPage).DoOnce())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var option = await Page.DisplayActionSheet(cipher.Name, AppResources.Cancel, null, "1", "2");
|
||||
if(option == AppResources.Cancel)
|
||||
{
|
||||
|
|
|
@ -104,8 +104,12 @@ namespace Bit.App.Pages
|
|||
|
||||
private async void Search_Clicked(object sender, System.EventArgs e)
|
||||
{
|
||||
await Navigation.PushModalAsync(new NavigationPage(
|
||||
new CiphersPage(_vm.Filter,_vm.FolderId != null, _vm.CollectionId != null, _vm.Type != null)), false);
|
||||
if(DoOnce())
|
||||
{
|
||||
var page = new CiphersPage(_vm.Filter, _vm.FolderId != null, _vm.CollectionId != null,
|
||||
_vm.Type != null);
|
||||
await Navigation.PushModalAsync(new NavigationPage(page), false);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -369,6 +369,10 @@ namespace Bit.App.Pages
|
|||
|
||||
private async void CipherOptionsAsync(CipherView cipher)
|
||||
{
|
||||
if(!(Page as BaseContentPage).DoOnce())
|
||||
{
|
||||
return;
|
||||
}
|
||||
var option = await Page.DisplayActionSheet(cipher.Name, AppResources.Cancel, null, "1", "2");
|
||||
if(option == AppResources.Cancel)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue