mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-01-12 15:26:28 +01:00
Ensure the equality checks for our ViewModels use the underlying Model object so even if we create a new wrapper we'll compare it against what it actually contains.
This commit is contained in:
@@ -107,4 +107,8 @@ public partial class ListItemViewModel(IListItem model, TaskScheduler scheduler)
|
||||
public bool MatchesFilter(string filter) => StringMatcher.FuzzySearch(filter, Title).Success || StringMatcher.FuzzySearch(filter, Subtitle).Success;
|
||||
|
||||
public override string ToString() => $"{Name} ListItemViewModel";
|
||||
|
||||
public override bool Equals(object? obj) => obj is ListItemViewModel vm && vm._listItemModel.Equals(this._listItemModel);
|
||||
|
||||
public override int GetHashCode() => _listItemModel.GetHashCode();
|
||||
}
|
||||
|
||||
@@ -7,4 +7,8 @@ namespace Microsoft.CmdPal.UI.ViewModels.Models;
|
||||
public class ExtensionObject<T>(T? value) // where T : IInspectable
|
||||
{
|
||||
public T? Unsafe { get; } = value;
|
||||
|
||||
public override bool Equals(object? obj) => obj is ExtensionObject<T> ext && ext.Unsafe?.Equals(this.Unsafe) == true;
|
||||
|
||||
public override int GetHashCode() => Unsafe?.GetHashCode() ?? base.GetHashCode();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user