mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
CmdPal: fix a perf regression loading pages (#39415)
This was especially noticable with the icons extension. Turns out in #39051, when I was experimenting with getting AoT clean, i accidentally called this twice. Then we actually commited that straight up. This PR reverts that. It also moves a similar case where we were initializing all the tags on the UI thread. That's wrong too - we need to fetch properties off the UI thread, then update the list on the UI thread. Closes nothing, I didn't file this yet.
This commit is contained in:
@@ -107,17 +107,17 @@ public partial class ListItemViewModel(IListItem model, WeakReference<IPageConte
|
||||
|
||||
private void UpdateTags(ITag[]? newTagsFromModel)
|
||||
{
|
||||
var newTags = newTagsFromModel?.Select(t =>
|
||||
{
|
||||
var vm = new TagViewModel(t, PageContext);
|
||||
vm.InitializeProperties();
|
||||
return vm;
|
||||
})
|
||||
.ToList() ?? [];
|
||||
|
||||
DoOnUiThread(
|
||||
() =>
|
||||
{
|
||||
var newTags = newTagsFromModel?.Select(t =>
|
||||
{
|
||||
var vm = new TagViewModel(t, PageContext);
|
||||
vm.InitializeProperties();
|
||||
return vm;
|
||||
})
|
||||
.ToList() ?? [];
|
||||
|
||||
// Tags being an ObservableCollection instead of a List lead to
|
||||
// many COM exception issues.
|
||||
Tags = new(newTags);
|
||||
|
||||
@@ -4,7 +4,6 @@
|
||||
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Runtime.Versioning;
|
||||
using CommunityToolkit.Common;
|
||||
using CommunityToolkit.Mvvm.ComponentModel;
|
||||
using CommunityToolkit.Mvvm.Input;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
@@ -109,13 +108,11 @@ public partial class ShellViewModel(IServiceProvider _serviceProvider, TaskSched
|
||||
// TODO GH #239 switch back when using the new MD text block
|
||||
// _ = _queue.EnqueueAsync(() =>
|
||||
_ = Task.Factory.StartNew(
|
||||
async () =>
|
||||
() =>
|
||||
{
|
||||
// bool f = await viewModel.InitializeCommand.ExecutionTask.;
|
||||
// var result = viewModel.InitializeCommand.ExecutionTask.GetResultOrDefault()!;
|
||||
// var result = viewModel.InitializeCommand.ExecutionTask.GetResultOrDefault<bool?>()!;
|
||||
var result = await viewModel.InitializeAsync();
|
||||
|
||||
CurrentPage = viewModel; // result ? viewModel : null;
|
||||
////LoadedState = result ? ViewModelLoadedState.Loaded : ViewModelLoadedState.Error;
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user