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

Speed up PR list and other improvements #1737

Merged
merged 41 commits into from
Jul 4, 2018
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
41 commits
Select commit Hold shift + click to select a range
599efea
Basic reimplementation of PR list.
grokys Jun 14, 2018
b9ce76b
Double clicking a PR opens it.
grokys Jun 14, 2018
71f57c6
Implement PR state filter.
grokys Jun 14, 2018
c084813
Display more accurate comment count.
grokys Jun 15, 2018
77c48cc
Implement Refresh.
grokys Jun 15, 2018
421ad8d
Cancel previous load on refresh.
grokys Jun 15, 2018
3c9cebb
Implement filtering.
grokys Jun 15, 2018
4246b53
Display messages when no PRs found.
grokys Jun 15, 2018
aec7a5a
Started implementing an author filter.
grokys Jun 15, 2018
0921da9
Make author filter work.
grokys Jun 15, 2018
f1c3255
Close author filter on selection.
grokys Jun 15, 2018
e19d3c1
Merge branch 'refactor/pr-models' into refactor/pr-list
grokys Jun 17, 2018
373226f
Style PR list a bit.
grokys Jun 17, 2018
9b722a4
Wire up create pull request.
grokys Jun 17, 2018
f30cab3
Use IIssueListItemViewModelBase not IViewModel.
grokys Jun 17, 2018
f4a8b8e
Display the current PR in the list.
grokys Jun 17, 2018
58a49b5
Fix dark theme.
grokys Jun 17, 2018
55b1611
Switch between fork/parent repository.
grokys Jun 19, 2018
6157a24
Merge branch 'master' into refactor/pr-list
jcansdale Jun 19, 2018
2cccd71
Fix non-compiling tests.
grokys Jun 20, 2018
19f56c0
Merge branch 'refactor/pr-list' of https://github.com/github/VisualSt…
grokys Jun 20, 2018
5b6ac81
Merge branch 'master' into refactor/pr-list
StanleyGoldman Jun 20, 2018
dbe8d3b
Make virtualizing list unit testable.
grokys Jun 20, 2018
1991f03
Added failing test.
grokys Jun 20, 2018
1636c1d
Fix failing test.
grokys Jun 20, 2018
4876f10
Merge branch 'refactor/pr-list' of https://github.com/github/VisualSt…
grokys Jun 20, 2018
a94466b
Merge branch 'master' into refactor/pr-list
grokys Jun 21, 2018
307b45a
Merge branch 'master' into refactor/pr-list
grokys Jun 28, 2018
7718388
Consolidate Octokit.GraphQL package version.
grokys Jun 28, 2018
aa85e58
Added XML docs and logging.
grokys Jun 28, 2018
dd6d3f8
Added/updated view model XML docs.
grokys Jun 28, 2018
ebc0127
Don't show NoOpenItems when there's search criteria.
grokys Jun 29, 2018
a5871c6
Hide author filter when no items.
grokys Jun 29, 2018
a6200b3
Implement opening PR list in browser.
grokys Jun 29, 2018
7598d20
Added context menu to PR list.
grokys Jul 3, 2018
809ebca
Hide PR count when list is loading.
grokys Jul 3, 2018
f59a513
Clear user filter when item selected.
grokys Jul 3, 2018
022271e
Navigate to PR with enter key from PR list.
grokys Jul 3, 2018
db00183
Fix typo.
grokys Jul 4, 2018
d52302a
ReadParentOwnerLogin -> FindParent.
grokys Jul 4, 2018
7ce21a3
Fix non-compiling tests.
grokys Jul 4, 2018
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Cancel previous load on refresh.
  • Loading branch information
grokys committed Jun 15, 2018
commit 421ad8d3d3a58dae9dbcc496829e347927b614b0
17 changes: 14 additions & 3 deletions src/GitHub.App/Collections/SequentialListSource.cs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Threading;
Expand All @@ -14,6 +15,7 @@ public abstract class SequentialListSource<TModel, TViewModel> : IVirtualizingLi
{
static readonly ILogger log = LogManager.ForContext<SequentialListSource<TModel, TViewModel>>();

readonly CancellationToken cancel;
readonly Dispatcher dispatcher;
readonly object loadLock = new object();
Dictionary<int, Page<TModel>> pages = new Dictionary<int, Page<TModel>>();
Expand All @@ -23,8 +25,9 @@ public abstract class SequentialListSource<TModel, TViewModel> : IVirtualizingLi
int loadTo;
string after;

public SequentialListSource()
public SequentialListSource(CancellationToken cancel)
{
this.cancel = cancel;
dispatcher = Application.Current.Dispatcher;
}

Expand All @@ -48,6 +51,12 @@ public async Task<IReadOnlyList<TViewModel>> GetPage(int pageNumber)
dispatcher.VerifyAccess();

var page = await EnsureLoaded(pageNumber);

if (page == null)
{
return null;
}

var result = page.Items
.Select(CreateViewModel)
.ToList();
Expand Down Expand Up @@ -76,7 +85,7 @@ async Task<Page<TModel>> EnsureLoaded(int pageNumber)
var pageLoaded = WaitPageLoaded(pageNumber);
loadTo = Math.Max(loadTo, pageNumber);

while (true)
while (!cancel.IsCancellationRequested)
{
lock (loadLock)
{
Expand All @@ -93,6 +102,8 @@ async Task<Page<TModel>> EnsureLoaded(int pageNumber)
return pages[pageNumber];
}
}

return null;
}

Task WaitPageLoaded(int page)
Expand All @@ -115,7 +126,7 @@ async Task Load()
{
OnBeginLoading();

while (nextPage <= loadTo)
while (nextPage <= loadTo && !cancel.IsCancellationRequested)
{
await LoadNextPage().ConfigureAwait(false);
PageLoaded?.Invoke(this, EventArgs.Empty);
Expand Down
8 changes: 6 additions & 2 deletions src/GitHub.App/Collections/VirtualizingList.cs
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,12 @@ async void LoadPage(int number)
{
pages.Add(number, placeholderPage);
var page = await source.GetPage(number);
pages[number] = page;
SendReset();

if (page != null)
{
pages[number] = page;
SendReset();
}
}
catch (Exception)
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ namespace GitHub.ViewModels.GitHubPane
{
public abstract class IssueListViewModelBase : PanePageViewModelBase, IIssueListViewModelBase
{
CancellationTokenSource cancel;
IReadOnlyList<IViewModel> items;
ICollectionView itemsView;
string searchQuery;
Expand Down Expand Up @@ -65,13 +66,17 @@ public async Task InitializeAsync(ILocalRepositoryModel repository, IConnection

public override Task Refresh()
{
var items = new VirtualizingList<IViewModel>(CreateItemSource(), null);
cancel?.Cancel();
cancel?.Dispose();
cancel = new CancellationTokenSource();

var items = new VirtualizingList<IViewModel>(CreateItemSource(cancel.Token), null);
Items = items;
ItemsView = new VirtualizingListCollectionView<IViewModel>(items);
return Task.CompletedTask;
}

protected abstract IVirtualizingListSource<IViewModel> CreateItemSource();
protected abstract IVirtualizingListSource<IViewModel> CreateItemSource(CancellationToken cancel);
protected abstract Task DoOpenItem(IViewModel item);

async Task OpenItemImpl(object i)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.ComponentModel.Composition;
using System.Diagnostics;
using System.Threading;
using System.Threading.Tasks;
using GitHub.Collections;
using GitHub.Models;
Expand All @@ -26,9 +27,9 @@ public PullRequestListViewModel(IPullRequestService service)

public override IReadOnlyList<string> States => states;

protected override IVirtualizingListSource<IViewModel> CreateItemSource()
protected override IVirtualizingListSource<IViewModel> CreateItemSource(CancellationToken cancel)
{
return new ItemSource(this);
return new ItemSource(this, cancel);
}

protected override Task DoOpenItem(IViewModel item)
Expand All @@ -42,7 +43,8 @@ class ItemSource : SequentialListSource<PullRequestListItemModel, IViewModel>
{
readonly PullRequestListViewModel owner;

public ItemSource(PullRequestListViewModel owner)
public ItemSource(PullRequestListViewModel owner, CancellationToken cancel)
: base(cancel)
{
this.owner = owner;
}
Expand Down