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 var stackLayout = new StackLayout
{ {
Spacing = 0, Spacing = 0,
Padding = new Thickness(16, 8), Padding = new Thickness(16, 10),
Children = { Icon, Label, CountLabel }, Children = { Icon, Label, CountLabel },
Orientation = StackOrientation.Horizontal Orientation = StackOrientation.Horizontal
}; };

View file

@ -187,11 +187,12 @@ namespace Bit.App.Pages
{ {
var sections = new List<Section<GroupingOrCipher>>(); var sections = new List<Section<GroupingOrCipher>>();
var favoriteCipherGroupings = new List<GroupingOrCipher>(); var favoriteCipherGroupings = new List<GroupingOrCipher>();
var noFolderCipherGroupings = new List<GroupingOrCipher>();
var ciphers = await _cipherService.GetAllAsync(); var ciphers = await _cipherService.GetAllAsync();
var collectionsDict = (await _collectionService.GetAllCipherAssociationsAsync()) var collectionsDict = (await _collectionService.GetAllCipherAssociationsAsync())
.GroupBy(c => c.Item2).ToDictionary(g => g.Key, v => v.ToList()); .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) foreach(var cipher in ciphers)
{ {
if(cipher.Favorite) if(cipher.Favorite)
@ -209,7 +210,7 @@ namespace Bit.App.Pages
} }
else 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 folders = await _folderService.GetAllAsync();
var collections = await _collectionService.GetAllAsync();
var folderGroupings = folders? var folderGroupings = folders?
.Select(f => new GroupingOrCipher(new Grouping(f, folderCounts.ContainsKey(f.Id) ? folderCounts[f.Id] : 0))) .Select(f => new GroupingOrCipher(new Grouping(f, folderCounts.ContainsKey(f.Id) ? folderCounts[f.Id] : 0)))
.OrderBy(g => g.Grouping.Name).ToList(); .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? var collectionGroupings = collections?
.Select(c => new GroupingOrCipher(new Grouping(c, .Select(c => new GroupingOrCipher(new Grouping(c,
collectionsDict.ContainsKey(c.Id) ? collectionsDict[c.Id].Count() : 0))) 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)); 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(() => Device.BeginInvokeOnMainThread(() =>
{ {