1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-22 16:18:21 +01:00

order names in vault. getbyid can now return null if not found (use find instead of get)

This commit is contained in:
Kyle Spearrin 2016-07-07 00:00:12 -04:00
parent 31ad96ff31
commit b7869ed763
7 changed files with 64 additions and 7 deletions

View File

@ -32,7 +32,7 @@ namespace Bit.App.Models.Page
{
public Folder(IEnumerable<Models.Site> sites, string folderId = null)
{
var pageSites = sites.Select(s => new Site(s, folderId));
var pageSites = sites.Select(s => new Site(s, folderId)).OrderBy(s => s.Name);
AddRange(pageSites);
}

View File

@ -107,6 +107,12 @@ namespace Bit.App.Pages
private async void DeleteCell_Tapped(object sender, EventArgs e)
{
if(!_connectivity.IsConnected)
{
AlertNoConnection();
return;
}
// TODO: Validate the delete operation. ex. Cannot delete a folder that has sites in it?
if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No))

View File

@ -68,6 +68,13 @@ namespace Bit.App.Pages
};
changeMasterPasswordCell.Tapped += ChangeMasterPasswordCell_Tapped;
var changeEmailCell = new ExtendedTextCell
{
Text = "Change Email",
ShowDisclousure = true
};
changeEmailCell.Tapped += ChangeEmailCell_Tapped;
var foldersCell = new ExtendedTextCell
{
Text = "Folders",
@ -106,7 +113,8 @@ namespace Bit.App.Pages
LockOptionsCell,
FingerprintCell,
PinCell,
changeMasterPasswordCell
changeMasterPasswordCell,
changeEmailCell
},
new TableSection("Manage")
{
@ -205,6 +213,16 @@ namespace Bit.App.Pages
Device.OpenUri(new Uri("https://vault.bitwarden.com"));
}
private async void ChangeEmailCell_Tapped(object sender, EventArgs e)
{
if(!await _userDialogs.ConfirmAsync("You can change your email address on the bitwarden.com web vault. Do you want to visit the website now?", null, AppResources.Yes, AppResources.Cancel))
{
return;
}
Device.OpenUri(new Uri("https://vault.bitwarden.com"));
}
private void FingerprintCell_Changed(object sender, EventArgs e)
{
var cell = sender as ExtendedSwitchCell;

View File

@ -78,6 +78,9 @@ namespace Bit.App.Pages
On = site.Favorite
};
var deleteCell = new ExtendedTextCell { Text = AppResources.Delete, TextColor = Color.Red };
deleteCell.Tapped += DeleteCell_Tapped;
var table = new ExtendedTableView
{
Intent = TableIntent.Settings,
@ -100,6 +103,10 @@ namespace Bit.App.Pages
new TableSection(AppResources.Notes)
{
notesCell
},
new TableSection
{
deleteCell
}
}
};
@ -169,6 +176,31 @@ namespace Bit.App.Pages
}
}
private async void DeleteCell_Tapped(object sender, EventArgs e)
{
if(!_connectivity.IsConnected)
{
AlertNoConnection();
return;
}
if(!await _userDialogs.ConfirmAsync(AppResources.DoYouReallyWantToDelete, null, AppResources.Yes, AppResources.No))
{
return;
}
var deleteTask = _siteService.DeleteAsync(_siteId);
_userDialogs.ShowLoading("Deleting...", MaskType.Black);
await deleteTask;
_userDialogs.HideLoading();
if((await deleteTask).Succeeded)
{
await Navigation.PopModalAsync();
_userDialogs.SuccessToast("Site deleted.");
}
}
private void AlertNoConnection()
{
DisplayAlert(AppResources.InternetConnectionRequiredTitle, AppResources.InternetConnectionRequiredMessage, AppResources.Ok);

View File

@ -106,7 +106,8 @@ namespace Bit.App.Pages
var folders = await _folderService.GetAllAsync();
var sites = _favorites ? await _siteService.GetAllAsync(true) : await _siteService.GetAllAsync();
var pageFolders = folders.Select(f => new VaultListPageModel.Folder(f, sites.Where(s => s.FolderId == f.Id))).ToList();
var pageFolders = folders.Select(f => new VaultListPageModel.Folder(f,
sites.Where(s => s.FolderId == f.Id))).OrderBy(f => f.Name).ToList();
var noneFolder = new VaultListPageModel.Folder(sites.Where(s => s.FolderId == null));
pageFolders.Add(noneFolder);

View File

@ -109,12 +109,12 @@ namespace Bit.App.Pages
BindingContext = Model;
}
protected override void OnAppearing()
protected async override void OnAppearing()
{
var site = _siteService.GetByIdAsync(_siteId).GetAwaiter().GetResult();
var site = await _siteService.GetByIdAsync(_siteId);
if(site == null)
{
// TODO: handle error. navigate back? should never happen...
await Navigation.PopModalAsync();
return;
}

View File

@ -20,7 +20,7 @@ namespace Bit.App.Repositories
public virtual Task<T> GetByIdAsync(TId id)
{
return Task.FromResult(Connection.Get<T>(id));
return Task.FromResult(Connection.Find<T>(id));
}
public virtual Task<IEnumerable<T>> GetAllAsync()