-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Conversation
|
This fix is not correct. Selecting [None] should remove it from the list and reset the filter to nothing, so everything shows up. [None] should only be visible when there is a selection in the list. The |
|
Ok, I'd misunderstood the intention then. Will try and work out the correct fix. |
|
Initially, |
If the source tracking collection already contains items at the time `CreateListenerCollection` is called, make sure the listener collection is populated with these items.
Added a method that creates an observable collection that tracks an ITrackingCollection and adds a sticky item to the top of the collection when a related selection is null.
Instead of using a behavior to add/remove the [None] item in the pull request list view, use the new listener collection to add/remove it.
This should now be implemented at the viewmodel level using CreateListenerCollection.
5fdff92 to
2edd3e4
Compare
|
👍 |
|
I added two tests that clarify the behaviour this should have when initially created and when the
|
|
Seeing as the |
Setting the Author/Assignee filter to [None] should not trigger a filter in the view model: doing this will remove the [None] entry from Authors, which will cause the selection in the view to be set to null which will reset the filter.
| { | ||
| foreach (var item in stickieItemsOnTop) | ||
| if (addedStickieItem) | ||
| { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about we just do a result.FirstOrDefault() == stickieItemOnTop instead of tracking with a flag? We know it's always going to be either the first or not there at all, and that way we don't have to keep state (and the first element look up is fast and doesn't consume the whole collection). That would work equally well to replace the hasSelection flag, too (or maybe not entirely for that flag, I'm trying to follow all the edge cases in my head here but brain is tired)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yep, I was wondering about that, but assumed you had a scenario in mind when writing it like that.
| if (col.Contains(item)) | ||
| offset++; | ||
| result.Remove(stickieItemOnTop); | ||
| hasStickieItem = false; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This doesn't need to be set.
|
✨ |
The empty list item was getting added twice: once by the XAML and once in PullRequestListViewModel. This adds a new overload of
TrackingCollection.CreateListenerCollectionso that the logical can be carried out at the VM layer instead of being mixed between VM and view.Fixes #390.