Skip to content

Commit

Permalink
Sorting various lists of extensions and accounts alphabetically (micr…
Browse files Browse the repository at this point in the history
  • Loading branch information
EricJohnson327 authored Nov 3, 2023
1 parent 95a44bf commit 3d5b6ca
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 3 deletions.
5 changes: 3 additions & 2 deletions settings/DevHome.Settings/ViewModels/AccountsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,9 @@ public class AccountsViewModel : ObservableObject

public AccountsViewModel()
{
var devIdProviders = Task.Run(async () => await Application.Current.GetService<IAccountsService>().GetDevIdProviders()).Result;
devIdProviders.ToList().ForEach((devIdProvider) =>
var devIdProviders = Task.Run(async () => await Application.Current.GetService<IAccountsService>().GetDevIdProviders()).Result.ToList();
devIdProviders.Sort((a, b) => string.Compare(a.DisplayName, b.DisplayName, System.StringComparison.OrdinalIgnoreCase));
devIdProviders.ForEach((devIdProvider) =>
{
AccountsProviders.Add(new AccountsProviderViewModel(devIdProvider));
});
Expand Down
3 changes: 3 additions & 0 deletions settings/DevHome.Settings/ViewModels/ExtensionsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@

using System;
using System.Collections.ObjectModel;
using System.Linq;
using System.Threading.Tasks;
using CommunityToolkit.Mvvm.ComponentModel;
using CommunityToolkit.Mvvm.Input;
Expand Down Expand Up @@ -78,6 +79,8 @@ private void DisplaySettings()
return await extensionService.GetInstalledExtensionsAsync(true);
}).Result;

extensionWrappers = extensionWrappers.OrderBy(extensionWrapper => extensionWrapper.Name);

SettingsList.Clear();

foreach (var extensionWrapper in extensionWrappers)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,8 @@ private async Task GetInstalledExtensionsAsync()

InstalledPackagesList.Clear();

extensionWrappers = extensionWrappers.OrderBy(extensionWrapper => extensionWrapper.Name);

foreach (var extensionWrapper in extensionWrappers)
{
// Don't show self as an extension.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -332,7 +332,7 @@ public void GetExtensions()

var extensions = extensionWrappers.Where(
extension => extension.HasProviderType(ProviderType.Repository) &&
extension.HasProviderType(ProviderType.DeveloperId));
extension.HasProviderType(ProviderType.DeveloperId)).OrderBy(extensionWrapper => extensionWrapper.Name);

_providers = new RepositoryProviders(extensions);

Expand Down

0 comments on commit 3d5b6ca

Please sign in to comment.