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:
@@ -106,9 +106,6 @@ public partial class ListItemViewModel(IListItem model, WeakReference<IPageConte
|
|||||||
public override int GetHashCode() => Model.GetHashCode();
|
public override int GetHashCode() => Model.GetHashCode();
|
||||||
|
|
||||||
private void UpdateTags(ITag[]? newTagsFromModel)
|
private void UpdateTags(ITag[]? newTagsFromModel)
|
||||||
{
|
|
||||||
DoOnUiThread(
|
|
||||||
() =>
|
|
||||||
{
|
{
|
||||||
var newTags = newTagsFromModel?.Select(t =>
|
var newTags = newTagsFromModel?.Select(t =>
|
||||||
{
|
{
|
||||||
@@ -118,6 +115,9 @@ public partial class ListItemViewModel(IListItem model, WeakReference<IPageConte
|
|||||||
})
|
})
|
||||||
.ToList() ?? [];
|
.ToList() ?? [];
|
||||||
|
|
||||||
|
DoOnUiThread(
|
||||||
|
() =>
|
||||||
|
{
|
||||||
// Tags being an ObservableCollection instead of a List lead to
|
// Tags being an ObservableCollection instead of a List lead to
|
||||||
// many COM exception issues.
|
// many COM exception issues.
|
||||||
Tags = new(newTags);
|
Tags = new(newTags);
|
||||||
|
|||||||
@@ -4,7 +4,6 @@
|
|||||||
|
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
using System.Runtime.Versioning;
|
using System.Runtime.Versioning;
|
||||||
using CommunityToolkit.Common;
|
|
||||||
using CommunityToolkit.Mvvm.ComponentModel;
|
using CommunityToolkit.Mvvm.ComponentModel;
|
||||||
using CommunityToolkit.Mvvm.Input;
|
using CommunityToolkit.Mvvm.Input;
|
||||||
using CommunityToolkit.Mvvm.Messaging;
|
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
|
// TODO GH #239 switch back when using the new MD text block
|
||||||
// _ = _queue.EnqueueAsync(() =>
|
// _ = _queue.EnqueueAsync(() =>
|
||||||
_ = Task.Factory.StartNew(
|
_ = Task.Factory.StartNew(
|
||||||
async () =>
|
() =>
|
||||||
{
|
{
|
||||||
// bool f = await viewModel.InitializeCommand.ExecutionTask.;
|
// bool f = await viewModel.InitializeCommand.ExecutionTask.;
|
||||||
// var result = viewModel.InitializeCommand.ExecutionTask.GetResultOrDefault()!;
|
// var result = viewModel.InitializeCommand.ExecutionTask.GetResultOrDefault()!;
|
||||||
// var result = viewModel.InitializeCommand.ExecutionTask.GetResultOrDefault<bool?>()!;
|
// var result = viewModel.InitializeCommand.ExecutionTask.GetResultOrDefault<bool?>()!;
|
||||||
var result = await viewModel.InitializeAsync();
|
|
||||||
|
|
||||||
CurrentPage = viewModel; // result ? viewModel : null;
|
CurrentPage = viewModel; // result ? viewModel : null;
|
||||||
////LoadedState = result ? ViewModelLoadedState.Loaded : ViewModelLoadedState.Error;
|
////LoadedState = result ? ViewModelLoadedState.Loaded : ViewModelLoadedState.Error;
|
||||||
},
|
},
|
||||||
|
|||||||
Reference in New Issue
Block a user