1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-09-29 04:07:37 +02:00

handle some loading race conditions

This commit is contained in:
Kyle Spearrin 2019-06-13 14:08:21 -04:00
parent 28166f79a1
commit 8df4c27203
2 changed files with 15 additions and 3 deletions

View File

@ -6,7 +6,6 @@ using Bit.Core.Abstractions;
using Bit.Core.Enums; using Bit.Core.Enums;
using Bit.Core.Utilities; using Bit.Core.Utilities;
using System; using System;
using System.Linq;
using System.Threading.Tasks; using System.Threading.Tasks;
using Xamarin.Forms; using Xamarin.Forms;
@ -78,6 +77,10 @@ namespace Bit.App.Pages
} }
else if(message.Command == "syncCompleted") else if(message.Command == "syncCompleted")
{ {
if(!_vm.LoadedOnce)
{
return;
}
await Task.Delay(500); await Task.Delay(500);
Device.BeginInvokeOnMainThread(() => Device.BeginInvokeOnMainThread(() =>
{ {
@ -92,8 +95,15 @@ namespace Bit.App.Pages
{ {
if(!_syncService.SyncInProgress) if(!_syncService.SyncInProgress)
{ {
await Task.Delay(500); try
await _vm.LoadAsync(); {
await _vm.LoadAsync();
}
catch(Exception e) when(e.Message.Contains("No key."))
{
await Task.Delay(5000);
await _vm.LoadAsync();
}
} }
else else
{ {

View File

@ -126,6 +126,7 @@ namespace Bit.App.Pages
public ExtendedObservableCollection<GroupingsPageListGroup> GroupedItems { get; set; } public ExtendedObservableCollection<GroupingsPageListGroup> GroupedItems { get; set; }
public Command RefreshCommand { get; set; } public Command RefreshCommand { get; set; }
public Command<CipherView> CipherOptionsCommand { get; set; } public Command<CipherView> CipherOptionsCommand { get; set; }
public bool LoadedOnce { get; set; }
public async Task LoadAsync() public async Task LoadAsync()
{ {
@ -134,6 +135,7 @@ namespace Bit.App.Pages
return; return;
} }
_doingLoad = true; _doingLoad = true;
LoadedOnce = true;
ShowNoData = false; ShowNoData = false;
Loading = true; Loading = true;
ShowList = false; ShowList = false;