From 54161aaf39e03ee3b38b8a7b7fece5ec99c7ca73 Mon Sep 17 00:00:00 2001 From: Kyle Spearrin Date: Wed, 20 Dec 2017 13:55:59 -0500 Subject: [PATCH] list no folder items on my vault when no collects. --- src/App/Controls/VaultGroupingViewCell.cs | 2 +- src/App/Pages/Vault/VaultListGroupingsPage.cs | 27 +++++++++++++++---- 2 files changed, 23 insertions(+), 6 deletions(-) diff --git a/src/App/Controls/VaultGroupingViewCell.cs b/src/App/Controls/VaultGroupingViewCell.cs index 82b4aad1c..626e9141d 100644 --- a/src/App/Controls/VaultGroupingViewCell.cs +++ b/src/App/Controls/VaultGroupingViewCell.cs @@ -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 }; diff --git a/src/App/Pages/Vault/VaultListGroupingsPage.cs b/src/App/Pages/Vault/VaultListGroupingsPage.cs index f5987086a..8f068bca4 100644 --- a/src/App/Pages/Vault/VaultListGroupingsPage.cs +++ b/src/App/Pages/Vault/VaultListGroupingsPage.cs @@ -187,11 +187,12 @@ namespace Bit.App.Pages { var sections = new List>(); var favoriteCipherGroupings = new List(); + var noFolderCipherGroupings = new List(); 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 { ["none"] = 0 }; + var folderCounts = new Dictionary(); 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(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(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(collectionGroupings, AppResources.Collections)); } + else if(noFolderCipherGroupings?.Any() ?? false) + { + sections.Add(new Section( + noFolderCipherGroupings.OrderBy(g => g.Cipher.Name).ThenBy(g => g.Cipher.Subtitle).ToList(), + AppResources.FolderNone)); + } Device.BeginInvokeOnMainThread(() => {