Skip to content

Commit

Permalink
fix fix
Browse files Browse the repository at this point in the history
  • Loading branch information
neuecc committed Oct 3, 2024
1 parent ee3281a commit 1489313
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
7 changes: 5 additions & 2 deletions sandbox/ConsoleApp/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,14 @@


var dict = new ObservableDictionary<int, string>();
var view = dict.CreateView(x => x).ToNotifyCollectionChanged();
var view = dict.CreateView(x => x);
view.AttachFilter(x => x.Key == 1);

var view2 = view.ToNotifyCollectionChanged();
dict.Add(key: 1, value: "foo");
dict.Add(key: 2, value: "bar");

foreach (var item in view)
foreach (var item in view2)
{
Console.WriteLine(item);
}
Expand Down
5 changes: 4 additions & 1 deletion src/ObservableCollections/SynchronizedViewList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,8 @@ private void Parent_ViewChanged(in SynchronizedViewChangedEventArgs<T, TView> e)

private void Parent_RejectedViewChanged(RejectedViewChangedAction arg1, int index, int oldIndex)
{
if (index == -1) return;

lock (gate)
{
switch (arg1)
Expand All @@ -208,6 +210,7 @@ private void Parent_RejectedViewChanged(RejectedViewChangedAction arg1, int inde
listView.UpdateAlternateIndex(index, -1);
break;
case RejectedViewChangedAction.Move:
if (oldIndex == -1) return;
listView.TryReplaceAlternateIndex(oldIndex, index);
break;
default:
Expand Down Expand Up @@ -270,7 +273,7 @@ internal class NonFilteredSynchronizedViewList<T, TView> : ISynchronizedViewList
readonly ISynchronizedView<T, TView> parent;
protected readonly List<TView> listView; // no filter can be faster
protected readonly object gate = new object();

protected virtual bool IsSupportRangeFeature => true;

public NonFilteredSynchronizedViewList(ISynchronizedView<T, TView> parent)
Expand Down

0 comments on commit 1489313

Please sign in to comment.