From 2816e72aa93e7a2e29e55fcd67965799993c7c79 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Mon, 6 May 2019 23:07:47 -0400 Subject: [PATCH] more do once checks --- src/App/Pages/BaseContentPage.cs | 24 +++++++++---------- src/App/Pages/Vault/CiphersPageViewModel.cs | 4 ++++ .../Vault/GroupingsPage/GroupingsPage.xaml.cs | 8 +++++-- .../GroupingsPage/GroupingsPageViewModel.cs | 4 ++++ 4 files changed, 26 insertions(+), 14 deletions(-) diff --git a/src/App/Pages/BaseContentPage.cs b/src/App/Pages/BaseContentPage.cs index 0d886e5d1..2f89e49e5 100644 --- a/src/App/Pages/BaseContentPage.cs +++ b/src/App/Pages/BaseContentPage.cs @@ -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; - } } } diff --git a/src/App/Pages/Vault/CiphersPageViewModel.cs b/src/App/Pages/Vault/CiphersPageViewModel.cs index d167be973..724d62ca0 100644 --- a/src/App/Pages/Vault/CiphersPageViewModel.cs +++ b/src/App/Pages/Vault/CiphersPageViewModel.cs @@ -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) { diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs index ac4eb3420..8b91e9cae 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs @@ -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); + } } } } diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs index 1d8f2f743..72774d208 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPageViewModel.cs @@ -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) {