1
0
mirror of https://github.com/bitwarden/mobile synced 2025-12-16 00:03:22 +00:00

PS-1404 Improved exception handling when saving an attachment (#2078)

* PS-1404 Improved exception handling when saving an attachment

* PS-1404 Reverted unnecessary catch change

* PS-1404 Added missing whitespace

* PS-1404 Improved code formatting

* PS-1404 removed unnecessary whitespace

* PS-1404 Using SubmitAsyncCommand on xaml and removed the click method from the cs file
This commit is contained in:
aj-rosado
2022-09-16 18:28:20 +01:00
committed by GitHub
parent 305c770c58
commit b4737457a8
3 changed files with 16 additions and 10 deletions

View File

@@ -1,6 +1,8 @@
using System.Collections.Generic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using System.Windows.Input;
using Bit.App.Abstractions;
using Bit.App.Resources;
using Bit.Core.Abstractions;
@@ -8,6 +10,7 @@ using Bit.Core.Exceptions;
using Bit.Core.Models.Domain;
using Bit.Core.Models.View;
using Bit.Core.Utilities;
using Xamarin.CommunityToolkit.ObjectModel;
using Xamarin.Forms;
namespace Bit.App.Pages
@@ -20,6 +23,7 @@ namespace Bit.App.Pages
private readonly IStateService _stateService;
private readonly IVaultTimeoutService _vaultTimeoutService;
private readonly IPlatformUtilsService _platformUtilsService;
private readonly ILogger _logger;
private CipherView _cipher;
private Cipher _cipherDomain;
private bool _hasAttachments;
@@ -35,8 +39,10 @@ namespace Bit.App.Pages
_platformUtilsService = ServiceContainer.Resolve<IPlatformUtilsService>("platformUtilsService");
_stateService = ServiceContainer.Resolve<IStateService>("stateService");
_vaultTimeoutService = ServiceContainer.Resolve<IVaultTimeoutService>("vaultTimeoutService");
_logger = ServiceContainer.Resolve<ILogger>();
Attachments = new ExtendedObservableCollection<AttachmentView>();
DeleteAttachmentCommand = new Command<AttachmentView>(DeleteAsync);
SubmitAsyncCommand = new AsyncCommand(SubmitAsync, allowsMultipleExecutions: false);
PageTitle = AppResources.Attachments;
}
@@ -59,6 +65,7 @@ namespace Bit.App.Pages
}
public byte[] FileData { get; set; }
public Command DeleteAttachmentCommand { get; set; }
public ICommand SubmitAsyncCommand { get; }
public async Task InitAsync()
{
@@ -125,6 +132,7 @@ namespace Bit.App.Pages
}
catch (ApiException e)
{
_logger.Exception(e);
await _deviceActionService.HideLoadingAsync();
if (e?.Error != null)
{
@@ -132,6 +140,12 @@ namespace Bit.App.Pages
AppResources.AnErrorHasOccurred);
}
}
catch (Exception e)
{
_logger.Exception(e);
await _deviceActionService.HideLoadingAsync();
await _platformUtilsService.ShowDialogAsync(AppResources.GenericErrorMessage, AppResources.AnErrorHasOccurred);
}
return false;
}