From 8a059e0fbb826d1f8fbdb314f486e49831ac6a9c Mon Sep 17 00:00:00 2001 From: Matt Portune <59324545+mportune-bw@users.noreply.github.com> Date: Mon, 9 Mar 2020 18:43:28 -0400 Subject: [PATCH] Fixed issue where multiple threads were attempting to modify search result list (#761) * Fixed issue where multiple threads were attempting to modify search result list * Fixed race condition --- src/App/Pages/Vault/CiphersPage.xaml.cs | 2 +- src/App/Pages/Vault/CiphersPageViewModel.cs | 13 ++++++++----- 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/src/App/Pages/Vault/CiphersPage.xaml.cs b/src/App/Pages/Vault/CiphersPage.xaml.cs index 92a4af6c0..efe0c9605 100644 --- a/src/App/Pages/Vault/CiphersPage.xaml.cs +++ b/src/App/Pages/Vault/CiphersPage.xaml.cs @@ -75,7 +75,7 @@ namespace Bit.App.Pages { return; } - _vm.Search(e.NewTextValue, 500); + _vm.Search(e.NewTextValue, 200); } private void SearchBar_SearchButtonPressed(object sender, EventArgs e) diff --git a/src/App/Pages/Vault/CiphersPageViewModel.cs b/src/App/Pages/Vault/CiphersPageViewModel.cs index fe71ab649..aa6584c59 100644 --- a/src/App/Pages/Vault/CiphersPageViewModel.cs +++ b/src/App/Pages/Vault/CiphersPageViewModel.cs @@ -77,7 +77,7 @@ namespace Bit.App.Pages .GetValueOrDefault(); if(!string.IsNullOrWhiteSpace((Page as CiphersPage).SearchBar.Text)) { - Search((Page as CiphersPage).SearchBar.Text, 500); + Search((Page as CiphersPage).SearchBar.Text, 200); } } @@ -110,16 +110,19 @@ namespace Bit.App.Pages } catch(OperationCanceledException) { - ciphers = new List(); + return; } } if(ciphers == null) { ciphers = new List(); } - Ciphers.ResetWithRange(ciphers); - ShowNoData = searchable && Ciphers.Count == 0; - ShowList = searchable && !ShowNoData; + Device.BeginInvokeOnMainThread(() => + { + Ciphers.ResetWithRange(ciphers); + ShowNoData = searchable && Ciphers.Count == 0; + ShowList = searchable && !ShowNoData; + }); }, cts.Token); _searchCancellationTokenSource = cts; }