Skip to content

Commit

Permalink
Batch the VisibleRepositoryList Updates to avoid overworking the UI T…
Browse files Browse the repository at this point in the history
…hread
  • Loading branch information
brminnick committed Mar 23, 2020
1 parent b253c32 commit e17edea
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 10 deletions.
2 changes: 1 addition & 1 deletion GitTrends.UITests/Tests/RepositoriesTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ public async Task VerifySortingOptions(SortingOption sortingOption)
//Act
RepositoryPage.SetSortingOption(sortingOption);

//Wait for RepositoryList to refresh
//Allow RepositoryList to update
await Task.Delay(1000).ConfigureAwait(false);

//Assert
Expand Down
10 changes: 4 additions & 6 deletions GitTrends/Pages/SettingsPage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,16 +51,14 @@ RelativeLayout CreateLayout(bool isPortraitOrientation)
var trendsSettingsView = new TrendsChartSettingsView(_trendsChartSettingsService);
var registerforNotificationsView = new RegisterForNotificationsView();

var versionNumberText =
#if AppStore
$"Version: {VersionTracking.CurrentVersion}";
var versionNumberText = $"Version {VersionTracking.CurrentVersion}";
#elif RELEASE
$"Version: {VersionTracking.CurrentVersion} (Release)";
var versionNumberText = $"Version {VersionTracking.CurrentVersion} (Release)";
#elif DEBUG
$"Version: {VersionTracking.CurrentVersion} (Debug)";
#else
throw new NotSupportedException();
var versionNumberText = $"Version {VersionTracking.CurrentVersion} (Debug)";
#endif

var createdByLabel = new Label
{
AutomationId = SettingsPageAutomationIds.CreatedByLabel,
Expand Down
6 changes: 3 additions & 3 deletions GitTrends/ViewModels/RepositoryViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,7 @@ public IReadOnlyList<Repository> VisibleRepositoryList
public bool IsRefreshing
{
get => _isRefreshing;
set => SetProperty(ref _isRefreshing, value, () => MainThread.InvokeOnMainThreadAsync(() => OnPropertyChanged(nameof(IsNotRefreshing))));
set => SetProperty(ref _isRefreshing, value, () => OnPropertyChanged(nameof(IsNotRefreshing)));
}

async Task ExecutePullToRefreshCommand(string repositoryOwner)
Expand All @@ -95,9 +95,9 @@ async Task ExecutePullToRefreshCommand(string repositoryOwner)
_repositoryDatabase.SaveRepository(retrievedRepositoriesWithViewsAndClonesData).SafeFireAndForget();
completedRepoitories.Add(retrievedRepositoriesWithViewsAndClonesData);

//Limit the VisibleRepositoryList Updates to avoid overworking the UI Thread
//Batch the VisibleRepositoryList Updates to avoid overworking the UI Thread
if (!GitHubAuthenticationService.IsDemoUser
&& completedRepoitories.Count > repositoriesPerFetch / 20)
&& completedRepoitories.Count > repositoriesPerFetch / 5)
{
AddRepositoriesToCollection(completedRepoitories, _searchBarText);
completedRepoitories.Clear();
Expand Down

0 comments on commit e17edea

Please sign in to comment.