mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-07-08 19:40:01 +02:00
fix fallbacks
This commit is contained in:
@@ -168,16 +168,6 @@ public sealed class CommandProviderWrapper
|
||||
Logger.LogError($"Extension was {Extension!.PackageFamilyName}");
|
||||
Logger.LogError(e.ToString());
|
||||
}
|
||||
|
||||
// if (commands != null)
|
||||
// {
|
||||
// TopLevelItems = (TopLevelViewModel[])commands;
|
||||
// }
|
||||
|
||||
// if (fallbacks != null)
|
||||
// {
|
||||
// FallbackItems = fallbacks;
|
||||
// }
|
||||
}
|
||||
|
||||
private void InitializeCommands(ICommandItem[] commands, IFallbackCommandItem[] fallbacks, IServiceProvider serviceProvider, WeakReference<IPageContext> pageContext)
|
||||
@@ -203,7 +193,7 @@ public sealed class CommandProviderWrapper
|
||||
if (fallbacks != null)
|
||||
{
|
||||
FallbackItems = fallbacks
|
||||
.Select(c => makeAndAdd(c, false))
|
||||
.Select(c => makeAndAdd(c, true))
|
||||
.ToArray();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -161,7 +161,7 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
private void UpdateAlias()
|
||||
{
|
||||
// Add tags for the alias, if we have one.
|
||||
AliasManager? aliases = _serviceProvider.GetService<AliasManager>();
|
||||
var aliases = _serviceProvider.GetService<AliasManager>();
|
||||
if (aliases != null)
|
||||
{
|
||||
Alias = aliases.AliasFromId(Id);
|
||||
@@ -170,7 +170,7 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
|
||||
private void UpdateHotkey()
|
||||
{
|
||||
TopLevelHotkey? hotkey = _settings.CommandHotkeys.Where(hk => hk.CommandId == Id).FirstOrDefault();
|
||||
var hotkey = _settings.CommandHotkeys.Where(hk => hk.CommandId == Id).FirstOrDefault();
|
||||
if (hotkey != null)
|
||||
{
|
||||
_hotkey = hotkey.Hotkey;
|
||||
@@ -200,7 +200,7 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
|
||||
private void DoOnUiThread(Action action)
|
||||
{
|
||||
if (_commandItemViewModel.PageContext.TryGetTarget(out IPageContext? pageContext))
|
||||
if (_commandItemViewModel.PageContext.TryGetTarget(out var pageContext))
|
||||
{
|
||||
Task.Factory.StartNew(
|
||||
action,
|
||||
@@ -221,12 +221,12 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
{
|
||||
try
|
||||
{
|
||||
ICommandItem? model = _commandItemViewModel.Model.Unsafe;
|
||||
var model = _commandItemViewModel.Model.Unsafe;
|
||||
if (model is IFallbackCommandItem fallback)
|
||||
{
|
||||
bool wasEmpty = string.IsNullOrEmpty(Title);
|
||||
var wasEmpty = string.IsNullOrEmpty(Title);
|
||||
fallback.FallbackHandler.UpdateQuery(newQuery);
|
||||
bool isEmpty = string.IsNullOrEmpty(Title);
|
||||
var isEmpty = string.IsNullOrEmpty(Title);
|
||||
if (wasEmpty != isEmpty)
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<UpdateFallbackItemsMessage>();
|
||||
|
||||
@@ -4,8 +4,8 @@
|
||||
|
||||
using System.Collections.ObjectModel;
|
||||
using CommunityToolkit.Mvvm.Messaging;
|
||||
using Microsoft.CmdPal.UI.Pages;
|
||||
using Microsoft.CmdPal.UI.ViewModels;
|
||||
using Microsoft.CmdPal.UI.ViewModels.Messages;
|
||||
using Microsoft.UI.Windowing;
|
||||
using Microsoft.UI.Xaml;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
@@ -15,7 +15,8 @@ using RS_ = Microsoft.CmdPal.UI.Helpers.ResourceLoaderInstance;
|
||||
namespace Microsoft.CmdPal.UI.Settings;
|
||||
|
||||
public sealed partial class SettingsWindow : Window,
|
||||
IRecipient<NavigateToExtensionSettingsMessage>
|
||||
IRecipient<NavigateToExtensionSettingsMessage>,
|
||||
IRecipient<QuitMessage>
|
||||
{
|
||||
public ObservableCollection<Crumb> BreadCrumbs { get; } = [];
|
||||
|
||||
@@ -27,7 +28,9 @@ public sealed partial class SettingsWindow : Window,
|
||||
this.AppWindow.Title = RS_.GetString("SettingsWindowTitle");
|
||||
this.AppWindow.TitleBar.PreferredHeightOption = TitleBarHeightOption.Tall;
|
||||
PositionCentered();
|
||||
|
||||
WeakReferenceMessenger.Default.Register<NavigateToExtensionSettingsMessage>(this);
|
||||
WeakReferenceMessenger.Default.Register<QuitMessage>(this);
|
||||
}
|
||||
|
||||
private void NavView_Loaded(object sender, RoutedEventArgs e)
|
||||
@@ -101,6 +104,12 @@ public sealed partial class SettingsWindow : Window,
|
||||
{
|
||||
WeakReferenceMessenger.Default.Send<WindowActivatedEventArgs>(args);
|
||||
}
|
||||
|
||||
public void Receive(QuitMessage message)
|
||||
{
|
||||
// This might come in on a background thread
|
||||
DispatcherQueue.TryEnqueue(() => Close());
|
||||
}
|
||||
}
|
||||
|
||||
public readonly struct Crumb
|
||||
|
||||
Reference in New Issue
Block a user