mirror of
https://github.com/microsoft/PowerToys.git
synced 2025-12-16 11:48:06 +01:00
CmdPal: Ensuring alias changes are propagated to related TopLevelViewModels (#40970)
Closes #39709 - Only updating aliases when the alias has changed - When an alias is used that is already in use, remove the alias from the previous TopLevelViewModel - Don't crash if the previous TopLevelViewModel doesn't exist (e.g. it was uninstalled)
This commit is contained in:
@@ -110,6 +110,8 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
get => Alias?.Alias ?? string.Empty;
|
||||
set
|
||||
{
|
||||
var previousAlias = Alias?.Alias ?? string.Empty;
|
||||
|
||||
if (string.IsNullOrEmpty(value))
|
||||
{
|
||||
Alias = null;
|
||||
@@ -126,9 +128,13 @@ public sealed partial class TopLevelViewModel : ObservableObject, IListItem
|
||||
}
|
||||
}
|
||||
|
||||
HandleChangeAlias();
|
||||
OnPropertyChanged(nameof(AliasText));
|
||||
OnPropertyChanged(nameof(IsDirectAlias));
|
||||
// Only call HandleChangeAlias if there was an actual change.
|
||||
if (previousAlias != Alias?.Alias)
|
||||
{
|
||||
HandleChangeAlias();
|
||||
OnPropertyChanged(nameof(AliasText));
|
||||
OnPropertyChanged(nameof(IsDirectAlias));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user