Skip to content

Commit a883b2a

Browse files
authored
Merge pull request #51 from YassinLokhat/50-hide-first-empty-password-in-account-view
Hide first empty password in account view
2 parents a2eb269 + de0ac29 commit a883b2a

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

GUI/WPF/ViewModels/Controls/AccountViewModel.cs

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,23 @@ public string Password
5353
}
5454
}
5555

56-
public PasswordViewModel[] Passwords => [.. Account.Passwords
57-
.OrderByDescending(x => x.Key)
58-
.Select(x => new PasswordViewModel(x.Key.ToShortDateString(), x.Value))];
56+
public PasswordViewModel[] Passwords
57+
{
58+
get
59+
{
60+
PasswordViewModel[] passwords = [.. Account.Passwords
61+
.OrderByDescending(x => x.Key)
62+
.Select(x => new PasswordViewModel(x.Key.ToShortDateString(), x.Value))];
63+
64+
if (passwords.Length != 0
65+
&& string.IsNullOrEmpty(passwords.Last().Password))
66+
{
67+
passwords = passwords[..(passwords.Length - 1)];
68+
}
69+
70+
return passwords;
71+
}
72+
}
5973

6074
public Brush NotesBackground => Account.HasChanged(nameof(Notes)) ? DarkMode.ChangedBrush : DarkMode.UnchangedBrush2;
6175
public string Notes
@@ -147,7 +161,7 @@ public bool PasswordLeaked
147161
&& MainViewModel.Database.Warnings.Any(x => x.WarningType == WarningType.PasswordLeakedWarning
148162
&& x.Accounts.Contains(Account));
149163

150-
public string[] IdentifierAutoCompleteList => MainViewModel.User?.Services
164+
public static string[] IdentifierAutoCompleteList => MainViewModel.User?.Services
151165
.SelectMany(x => x.Accounts)
152166
.SelectMany(x => x.Identifiers)
153167
.Distinct()

GUI/WPF/Views/Controls/AccountView.xaml.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -280,7 +280,7 @@ private void _identifier_TextBox_KeyUp(object sender, KeyEventArgs e)
280280
if (e.Key is Key.Enter
281281
or Key.Insert)
282282
{
283-
string? identifier = InsertIdentifierView.InsertIdentifierDialog(_viewModel?.IdentifierAutoCompleteList ?? [], identifier_TB.Text);
283+
string? identifier = InsertIdentifierView.InsertIdentifierDialog(AccountViewModel.IdentifierAutoCompleteList ?? [], identifier_TB.Text);
284284

285285
if (string.IsNullOrEmpty(identifier)) return;
286286

0 commit comments

Comments
 (0)