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

Commit 43ba6e3

Browse files
committed
Clear IsLoading when exception occurs.
1 parent f33ab0a commit 43ba6e3

File tree

2 files changed

+21
-5
lines changed

2 files changed

+21
-5
lines changed

src/GitHub.App/Collections/SequentialListSource.cs

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -182,13 +182,18 @@ async Task Load()
182182
{
183183
OnBeginLoading();
184184

185-
while (nextPage <= loadTo && !disposed)
185+
try
186186
{
187-
await LoadNextPage().ConfigureAwait(false);
188-
PageLoaded?.Invoke(this, EventArgs.Empty);
187+
while (nextPage <= loadTo && !disposed)
188+
{
189+
await LoadNextPage().ConfigureAwait(false);
190+
PageLoaded?.Invoke(this, EventArgs.Empty);
191+
}
192+
}
193+
finally
194+
{
195+
OnEndLoading();
189196
}
190-
191-
OnEndLoading();
192197
}
193198

194199
async Task LoadNextPage()

test/GitHub.App.UnitTests/Collections/SequentialListSourceTests.cs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,17 @@ public void GetPage_Should_Stop_Loading_Pages_When_LoadPage_Throws()
4646
Assert.That(target.PagesLoaded, Is.EqualTo(new[] { 0, 1 }));
4747
}
4848

49+
[Test]
50+
public void IsLoading_Should_Be_Set_To_False_When_LoadPage_Throws()
51+
{
52+
var target = new TestSource(2);
53+
54+
Assert.That(target.PagesLoaded, Is.Empty);
55+
56+
Assert.ThrowsAsync<AggregateException>(() => target.GetPage(3));
57+
Assert.That(target.IsLoading, Is.False);
58+
}
59+
4960
class TestSource : SequentialListSource<string, string>
5061
{
5162
const int PageCount = 10;

0 commit comments

Comments
 (0)