1
0
mirror of https://github.com/bitwarden/mobile.git synced 2024-12-29 17:28:33 +01:00

list no folder items on my vault when no collects.

This commit is contained in:
Kyle Spearrin 2017-12-20 13:55:59 -05:00
parent 4054519f38
commit 54161aaf39
2 changed files with 23 additions and 6 deletions

View File

@ -44,7 +44,7 @@ namespace Bit.App.Controls
var stackLayout = new StackLayout
{
Spacing = 0,
Padding = new Thickness(16, 8),
Padding = new Thickness(16, 10),
Children = { Icon, Label, CountLabel },
Orientation = StackOrientation.Horizontal
};

View File

@ -187,11 +187,12 @@ namespace Bit.App.Pages
{
var sections = new List<Section<GroupingOrCipher>>();
var favoriteCipherGroupings = new List<GroupingOrCipher>();
var noFolderCipherGroupings = new List<GroupingOrCipher>();
var ciphers = await _cipherService.GetAllAsync();
var collectionsDict = (await _collectionService.GetAllCipherAssociationsAsync())
.GroupBy(c => c.Item2).ToDictionary(g => g.Key, v => v.ToList());
var folderCounts = new Dictionary<string, int> { ["none"] = 0 };
var folderCounts = new Dictionary<string, int>();
foreach(var cipher in ciphers)
{
if(cipher.Favorite)
@ -209,7 +210,7 @@ namespace Bit.App.Pages
}
else
{
folderCounts["none"]++;
noFolderCipherGroupings.Add(new GroupingOrCipher(new Cipher(cipher, _appSettingsService)));
}
}
@ -221,13 +222,23 @@ namespace Bit.App.Pages
}
var folders = await _folderService.GetAllAsync();
var collections = await _collectionService.GetAllAsync();
var folderGroupings = folders?
.Select(f => new GroupingOrCipher(new Grouping(f, folderCounts.ContainsKey(f.Id) ? folderCounts[f.Id] : 0)))
.OrderBy(g => g.Grouping.Name).ToList();
folderGroupings.Add(new GroupingOrCipher(new Grouping(AppResources.FolderNone, folderCounts["none"])));
sections.Add(new Section<GroupingOrCipher>(folderGroupings, AppResources.Folders));
var collections = await _collectionService.GetAllAsync();
if(collections.Any())
{
folderGroupings.Add(new GroupingOrCipher(new Grouping(AppResources.FolderNone,
noFolderCipherGroupings.Count)));
}
if(folderGroupings.Any())
{
sections.Add(new Section<GroupingOrCipher>(folderGroupings, AppResources.Folders));
}
var collectionGroupings = collections?
.Select(c => new GroupingOrCipher(new Grouping(c,
collectionsDict.ContainsKey(c.Id) ? collectionsDict[c.Id].Count() : 0)))
@ -236,6 +247,12 @@ namespace Bit.App.Pages
{
sections.Add(new Section<GroupingOrCipher>(collectionGroupings, AppResources.Collections));
}
else if(noFolderCipherGroupings?.Any() ?? false)
{
sections.Add(new Section<GroupingOrCipher>(
noFolderCipherGroupings.OrderBy(g => g.Cipher.Name).ThenBy(g => g.Cipher.Subtitle).ToList(),
AppResources.FolderNone));
}
Device.BeginInvokeOnMainThread(() =>
{