diff --git a/src/App/App.xaml.cs b/src/App/App.xaml.cs index 18e01535c..8f2e9841c 100644 --- a/src/App/App.xaml.cs +++ b/src/App/App.xaml.cs @@ -71,21 +71,24 @@ namespace Bit.App var confirmed = true; var confirmText = string.IsNullOrWhiteSpace(details.ConfirmText) ? AppResources.Ok : details.ConfirmText; - if(!string.IsNullOrWhiteSpace(details.CancelText)) + Device.BeginInvokeOnMainThread(async () => { - confirmed = await MainPage.DisplayAlert(details.Title, details.Text, confirmText, - details.CancelText); - } - else - { - await MainPage.DisplayAlert(details.Title, details.Text, confirmText); - } - _messagingService.Send("showDialogResolve", new Tuple(details.DialogId, confirmed)); + if(!string.IsNullOrWhiteSpace(details.CancelText)) + { + confirmed = await MainPage.DisplayAlert(details.Title, details.Text, confirmText, + details.CancelText); + } + else + { + await MainPage.DisplayAlert(details.Title, details.Text, confirmText); + } + _messagingService.Send("showDialogResolve", new Tuple(details.DialogId, confirmed)); + }); } else if(message.Command == "locked") { await _stateService.PurgeAsync(); - MainPage = new NavigationPage(new LockPage()); + Device.BeginInvokeOnMainThread(() => MainPage = new NavigationPage(new LockPage())); } else if(message.Command == "lockVault") { diff --git a/src/App/Pages/Accounts/TwoFactorPage.xaml.cs b/src/App/Pages/Accounts/TwoFactorPage.xaml.cs index 23913b9eb..214db64a7 100644 --- a/src/App/Pages/Accounts/TwoFactorPage.xaml.cs +++ b/src/App/Pages/Accounts/TwoFactorPage.xaml.cs @@ -46,14 +46,17 @@ namespace Bit.App.Pages protected async override void OnAppearing() { base.OnAppearing(); - _broadcasterService.Subscribe(nameof(TwoFactorPage), async (message) => + _broadcasterService.Subscribe(nameof(TwoFactorPage), (message) => { if(message.Command == "gotYubiKeyOTP") { if(_vm.YubikeyMethod) { - _vm.Token = (string)message.Data; - await _vm.SubmitAsync(); + Device.BeginInvokeOnMainThread(async () => + { + _vm.Token = (string)message.Data; + await _vm.SubmitAsync(); + }); } } else if(message.Command == "resumeYubiKey") diff --git a/src/App/Pages/Vault/AttachmentsPage.xaml.cs b/src/App/Pages/Vault/AttachmentsPage.xaml.cs index aa692bb14..06620a10f 100644 --- a/src/App/Pages/Vault/AttachmentsPage.xaml.cs +++ b/src/App/Pages/Vault/AttachmentsPage.xaml.cs @@ -27,9 +27,12 @@ namespace Bit.App.Pages { if(message.Command == "selectFileResult") { - var data = message.Data as Tuple; - _vm.FileData = data.Item1; - _vm.FileName = data.Item2; + Device.BeginInvokeOnMainThread(() => + { + var data = message.Data as Tuple; + _vm.FileData = data.Item1; + _vm.FileName = data.Item2; + }); } }); await LoadOnAppearedAsync(_scrollView, true, () => _vm.InitAsync()); diff --git a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs index e50d948e1..579ef0d27 100644 --- a/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs +++ b/src/App/Pages/Vault/GroupingsPage/GroupingsPage.xaml.cs @@ -63,7 +63,10 @@ namespace Bit.App.Pages if(message.Command == "syncCompleted") { await Task.Delay(500); - await _vm.LoadAsync(); + Device.BeginInvokeOnMainThread(() => + { + var task = _vm.LoadAsync(); + }); } }); diff --git a/src/App/Pages/Vault/ViewPage.xaml.cs b/src/App/Pages/Vault/ViewPage.xaml.cs index 3eecc53d4..d1d098024 100644 --- a/src/App/Pages/Vault/ViewPage.xaml.cs +++ b/src/App/Pages/Vault/ViewPage.xaml.cs @@ -38,15 +38,18 @@ namespace Bit.App.Pages { if(message.Command == "syncCompleted") { - var data = message.Data as Dictionary; - if(data.ContainsKey("successfully")) + Device.BeginInvokeOnMainThread(() => { - var success = data["successfully"] as bool?; - if(success.HasValue && success.Value) + var data = message.Data as Dictionary; + if(data.ContainsKey("successfully")) { - await _vm.LoadAsync(); + var success = data["successfully"] as bool?; + if(success.HasValue && success.Value) + { + var task = _vm.LoadAsync(); + } } - } + }); } }); await LoadOnAppearedAsync(_scrollView, true, async () => diff --git a/src/Core/Services/BroadcasterService.cs b/src/Core/Services/BroadcasterService.cs index 4ac47ce91..a19bfaa79 100644 --- a/src/Core/Services/BroadcasterService.cs +++ b/src/Core/Services/BroadcasterService.cs @@ -2,6 +2,7 @@ using Bit.Core.Models.Domain; using System; using System.Collections.Generic; +using System.Threading.Tasks; namespace Bit.App.Services { @@ -15,13 +16,13 @@ namespace Bit.App.Services { if(_subscribers.ContainsKey(id)) { - _subscribers[id].Invoke(message); + Task.Run(() => _subscribers[id].Invoke(message)); } return; } foreach(var sub in _subscribers) { - sub.Value.Invoke(message); + Task.Run(() => sub.Value.Invoke(message)); } }