1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-06-26 10:36:21 +02:00

pop pages if cipher doesnt exist

This commit is contained in:
Kyle Spearrin 2019-05-30 08:40:10 -04:00
parent 46a8ffa5ae
commit e34ca49b9b
4 changed files with 28 additions and 4 deletions

View File

@ -54,7 +54,14 @@ namespace Bit.App.Pages
protected override async void OnAppearing()
{
base.OnAppearing();
await LoadOnAppearedAsync(_scrollView, true, () => _vm.LoadAsync(_appOptions));
await LoadOnAppearedAsync(_scrollView, true, async () =>
{
var success = await _vm.LoadAsync();
if(!success)
{
await Navigation.PopModalAsync();
}
});
if(_vm.EditMode && Device.RuntimePlatform == Device.Android)
{
if(_vm.Cipher.OrganizationId == null)

View File

@ -267,7 +267,7 @@ namespace Bit.App.Pages
PageTitle = EditMode ? AppResources.EditItem : AppResources.AddItem;
}
public async Task LoadAsync(AppOptions appOptions = null)
public async Task<bool> LoadAsync(AppOptions appOptions = null)
{
var myEmail = await _userService.GetEmailAsync();
OwnershipOptions.Add(new KeyValuePair<string, string>(myEmail, null));
@ -296,6 +296,10 @@ namespace Bit.App.Pages
if(EditMode)
{
var cipher = await _cipherService.GetAsync(CipherId);
if(cipher == null)
{
return false;
}
Cipher = await cipher.DecryptAsync();
}
else
@ -358,6 +362,7 @@ namespace Bit.App.Pages
Fields.ResetWithRange(Cipher.Fields?.Select(f => new AddEditPageFieldViewModel(f)));
}
}
return true;
}
public async Task<bool> SubmitAsync()

View File

@ -49,7 +49,14 @@ namespace Bit.App.Pages
}
}
});
await LoadOnAppearedAsync(_scrollView, true, () => _vm.LoadAsync(), _mainContent);
await LoadOnAppearedAsync(_scrollView, true, async () =>
{
var success = await _vm.LoadAsync();
if(!success)
{
await Navigation.PopModalAsync();
}
}, _mainContent);
if(Device.RuntimePlatform == Device.Android)
{
if(_vm.Cipher.OrganizationId == null)

View File

@ -206,10 +206,14 @@ namespace Bit.App.Pages
}
}
public async Task LoadAsync()
public async Task<bool> LoadAsync()
{
CleanUp();
var cipher = await _cipherService.GetAsync(CipherId);
if(cipher == null)
{
return false;
}
Cipher = await cipher.DecryptAsync();
CanAccessPremium = await _userService.CanAccessPremiumAsync();
Fields = Cipher.Fields?.Select(f => new ViewPageFieldViewModel(f)).ToList();
@ -231,6 +235,7 @@ namespace Bit.App.Pages
return true;
});
}
return true;
}
public void CleanUp()