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:
Michael Jolley
2025-08-21 06:09:00 -05:00
committed by GitHub
parent da572c6c40
commit 56aa9acfb4
2 changed files with 23 additions and 4 deletions

View File

@@ -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));
}
}
}