OrderBookRowCollection - when filter changes, call clear/addall instead of sync_with

This commit is contained in:
John Colvin committed 2018-10-24 22:33:43 -05:00
1 parent ae100f66c7
commit 079a7ad439
1 file changed
+12 -7
@@ -28,19 +28,14 @@ namespace mbts.spark {
set {
_filter = value;
_refresh_branches(_tree.RootNodes);
refresh();
_reset();
}
}
public IComparer<OrderBookRowVM> comparer {
get => _comparer;
set {
_tree = _tree.Resort(_comparer = value);
if (_is_refresh_deferred) {
_is_refresh_pending = true;
} else {
Clear();
this.AddRange(_visible_rows);
}
_reset();
}
}
public IEnumerable<OrderBookRowVM> all_rows => _tree;
@@ -159,6 +154,16 @@ namespace mbts.spark {
static SortedTree<OrderBookRowVM, uint> _mk_tree(IComparer<OrderBookRowVM> comp, IEnumerable<OrderBookRowVM> init = null) =>
new SortedTree<OrderBookRowVM, uint>(comp, r => r.order_key, r => r.parent_order_key, init);
void _reset() {
if (_is_refresh_deferred) {
_is_refresh_pending = true;
} else {
Clear();
this.AddRange(_visible_rows);
_is_refresh_pending = false;
}
}
void _refresh_branches(IEnumerable<INode<OrderBookRowVM>> roots) {
if (filter == null) {
foreach (var n in roots)