Skip to content
This repository was archived by the owner on Jun 21, 2023. It is now read-only.

Commit d19859d

Browse files
committed
Populate listener collection with existing items
If the source tracking collection already contains items at the time `CreateListenerCollection` is called, make sure the listener collection is populated with these items.
1 parent def4421 commit d19859d

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/GitHub.Exports.Reactive/Collections/TrackingCollection.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,12 @@ public static ObservableCollection<T> CreateListenerCollection<T>(this ITracking
4747
IList<T> stickieItemsOnTop = null)
4848
where T : class, ICopyable<T>
4949
{
50-
var col = new ObservableCollection<T>(stickieItemsOnTop ?? Enumerable.Empty<T>());
50+
if (stickieItemsOnTop == null)
51+
{
52+
stickieItemsOnTop = new T[0];
53+
}
54+
55+
var col = new ObservableCollection<T>(stickieItemsOnTop.Concat(tcol));
5156
tcol.CollectionChanged += (s, e) =>
5257
{
5358
var offset = 0;

0 commit comments

Comments
 (0)