Public Access
Desktop: swap the host lists in whole instead of announcing every row to listeners that redo all their work per row
This commit is contained in:
1 parent
a2362d1e3e
commit
7b072bcded
4 files changed
+120
-48
No files matched your search
@@ -1663,7 +1663,7 @@ internal sealed partial class VaultViewModel(
|
||||
/// host key list checks itself against, so a filter applied here would change what the application can
|
||||
/// do rather than what it shows. <see cref="VisibleHosts"/> is the filtered view.
|
||||
/// </remarks>
|
||||
internal ObservableCollection<HostRowViewModel> Hosts { get; } = [];
|
||||
internal ReplaceableCollection<HostRowViewModel> Hosts { get; } = [];
|
||||
|
||||
/// <summary>The hosts the grid is showing: one level of the group tree, narrowed by the box.</summary>
|
||||
/// <remarks>
|
||||
@@ -1677,7 +1677,7 @@ internal sealed partial class VaultViewModel(
|
||||
/// alone: the phone draws <see cref="SidebarRows"/>, which is the same hosts flattened under headings.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
internal ObservableCollection<HostRowViewModel> VisibleHosts { get; } = [];
|
||||
internal ReplaceableCollection<HostRowViewModel> VisibleHosts { get; } = [];
|
||||
|
||||
/// <summary>Whether the grid has anything to draw.</summary>
|
||||
/// <remarks>
|
||||
@@ -1891,7 +1891,7 @@ internal sealed partial class VaultViewModel(
|
||||
/// groupless keychain is one flat grid and nothing above it.
|
||||
/// </para>
|
||||
/// </remarks>
|
||||
internal ObservableCollection<HostSectionViewModel> HostSections { get; } = [];
|
||||
internal ReplaceableCollection<HostSectionViewModel> HostSections { get; } = [];
|
||||
|
||||
/// <summary>Every host on the board, in the order its cards are drawn — every section, one after another.</summary>
|
||||
/// <remarks>
|
||||
@@ -2003,7 +2003,7 @@ internal sealed partial class VaultViewModel(
|
||||
internal ObservableCollection<CredentialRowViewModel> Credentials { get; } = [];
|
||||
|
||||
/// <summary>The buckets to show, unpushed local state included.</summary>
|
||||
internal ObservableCollection<ObjectStoreRowViewModel> ObjectStores { get; } = [];
|
||||
internal ReplaceableCollection<ObjectStoreRowViewModel> ObjectStores { get; } = [];
|
||||
|
||||
/// <summary>The tags to show, with the number of hosts wearing each.</summary>
|
||||
/// <remarks>
|
||||
@@ -4714,18 +4714,14 @@ internal sealed partial class VaultViewModel(
|
||||
|
||||
var (rows, unreadable) = await FetchHostRowsAsync(cancellationToken).ConfigureAwait(true);
|
||||
|
||||
Hosts.Clear();
|
||||
|
||||
// Grouped by vault, with the one new items go into first, then by name inside each. Two vaults can
|
||||
// hold a host with the same label and both are shown: which vault it is in is what tells them
|
||||
// apart, which is why the row carries the name rather than the list deduplicating.
|
||||
foreach (var host in rows
|
||||
// apart, which is why the row carries the name rather than the list deduplicating. Swapped in whole,
|
||||
// and announced once: see ReplaceableCollection for what a row at a time cost.
|
||||
Hosts.ReplaceAll(rows
|
||||
.OrderByDescending(row => row.VaultId == session.ActiveVaultId)
|
||||
.ThenBy(row => row.VaultName, StringComparer.CurrentCulture)
|
||||
.ThenBy(row => row.Label, StringComparer.CurrentCulture))
|
||||
{
|
||||
Hosts.Add(host);
|
||||
}
|
||||
.ThenBy(row => row.Label, StringComparer.CurrentCulture));
|
||||
|
||||
SelectedHost = SelectionAfterReload(selectedId);
|
||||
ApplyTheChosenHosts();
|
||||
@@ -4816,13 +4812,9 @@ internal sealed partial class VaultViewModel(
|
||||
|
||||
var selectedId = SelectedObjectStore?.EntityId;
|
||||
|
||||
ObjectStores.Clear();
|
||||
|
||||
foreach (var store in listing.Items
|
||||
.OrderBy(store => store.Secret.Label, StringComparer.CurrentCulture))
|
||||
{
|
||||
ObjectStores.Add(new ObjectStoreRowViewModel(store));
|
||||
}
|
||||
ObjectStores.ReplaceAll(listing.Items
|
||||
.OrderBy(store => store.Secret.Label, StringComparer.CurrentCulture)
|
||||
.Select(store => new ObjectStoreRowViewModel(store)));
|
||||
|
||||
SelectedObjectStore = ObjectStores.FirstOrDefault(row => row.EntityId == selectedId);
|
||||
|
||||
@@ -5388,12 +5380,7 @@ internal sealed partial class VaultViewModel(
|
||||
// a walk up the group tree, and this is the map that walk is made against.
|
||||
var parents = EffectiveParents();
|
||||
|
||||
VisibleHosts.Clear();
|
||||
|
||||
foreach (var host in Hosts.Where(host => Matches(host, parents)))
|
||||
{
|
||||
VisibleHosts.Add(host);
|
||||
}
|
||||
VisibleHosts.ReplaceAll(Hosts.Where(host => Matches(host, parents)));
|
||||
|
||||
RebuildSidebarRows();
|
||||
|
||||
@@ -5403,7 +5390,7 @@ internal sealed partial class VaultViewModel(
|
||||
// property directly, and a host that is not on screen is not one any of them should act on.
|
||||
SelectedHost = selected is not null && VisibleHosts.Contains(selected) ? selected : null;
|
||||
|
||||
// After the host selection, not before: this mirrors it, and the ListBox's own answer to the Clear()
|
||||
// After the host selection, not before: this mirrors it, and the ListBox's own answer to the reset
|
||||
// above is a null that has to be overwritten rather than read.
|
||||
SelectedSidebarRow = SelectedHost;
|
||||
|
||||
@@ -5473,12 +5460,7 @@ internal sealed partial class VaultViewModel(
|
||||
/// </remarks>
|
||||
private void RebuildHostSections()
|
||||
{
|
||||
HostSections.Clear();
|
||||
|
||||
foreach (var built in BuildHostSections())
|
||||
{
|
||||
HostSections.Add(built);
|
||||
}
|
||||
HostSections.ReplaceAll(BuildHostSections());
|
||||
|
||||
// Computed rather than stored, and none of the four has a change notification of its own — the same
|
||||
// arrangement RebuildVisibleHosts holds for HasVisibleHosts and NoVisibleHostsMessage, and for the
|
||||
|
||||
Reference in new issue
Block a user