catch thrown sync errors from ui

This commit is contained in:
Kyle Spearrin 2019-10-15 11:05:56 -04:00
parent a0aca3e837
commit 37a536b138
4 changed files with 6700 additions and 6632 deletions

File diff suppressed because it is too large Load Diff

View File

@ -305,10 +305,18 @@ namespace Bit.App.Pages
return;
}
await _deviceActionService.ShowLoadingAsync(AppResources.Syncing);
await _syncService.FullSyncAsync(false);
try
{
await _syncService.FullSyncAsync(false, true);
await _deviceActionService.HideLoadingAsync();
_platformUtilsService.ShowToast("success", null, AppResources.SyncingComplete);
}
catch
{
await _deviceActionService.HideLoadingAsync();
_platformUtilsService.ShowToast("error", null, AppResources.SyncingFailed);
}
}
private async Task LoadDataAsync()
{

View File

@ -8,7 +8,7 @@ namespace Bit.Core.Abstractions
{
bool SyncInProgress { get; set; }
Task<bool> FullSyncAsync(bool forceSync);
Task<bool> FullSyncAsync(bool forceSync, bool allowThrowOnError = false);
Task<DateTime?> GetLastSyncAsync();
Task SetLastSyncAsync(DateTime date);
Task<bool> SyncDeleteCipherAsync(SyncCipherNotification notification);

View File

@ -71,7 +71,7 @@ namespace Bit.Core.Services
await _storageService.SaveAsync(string.Format(Keys_LastSyncFormat, userId), date);
}
public async Task<bool> FullSyncAsync(bool forceSync)
public async Task<bool> FullSyncAsync(bool forceSync, bool allowThrowOnError = false)
{
SyncStarted();
var isAuthenticated = await _userService.IsAuthenticatedAsync();
@ -105,10 +105,17 @@ namespace Bit.Core.Services
return SyncCompleted(true);
}
catch
{
if(allowThrowOnError)
{
throw;
}
else
{
return SyncCompleted(false);
}
}
}
public async Task<bool> SyncUpsertFolderAsync(SyncFolderNotification notification, bool isEdit)
{