diff --git a/HackerNews.csproj b/HackerNews.csproj index 978b2a8..e567e04 100644 --- a/HackerNews.csproj +++ b/HackerNews.csproj @@ -7,7 +7,7 @@ Library HackerNews true - 9.0.0 + 9.0.10 true enable @@ -44,6 +44,7 @@ + diff --git a/NewsViewModel.cs b/NewsViewModel.cs index 4bb45ac..b0f4c6d 100644 --- a/NewsViewModel.cs +++ b/NewsViewModel.cs @@ -17,24 +17,24 @@ public async Task RefreshAsync() // Ensure this method is called on the UI thread await MainThread.InvokeOnMainThreadAsync(async () => { - try - { - TopStoryCollection.Clear(); + try + { + TopStoryCollection.Clear(); - var sortedStories = (await GetTopStoriesAsync().ToListAsync()) - .OrderByDescending(story => story.Score) - .ToList(); + var sortedStories = (await GetTopStoriesAsync().ToListAsync()) + .OrderByDescending(story => story.Score) + .ToList(); - foreach (var story in sortedStories) - { - TopStoryCollection.Add(story); // Add sorted stories to the collection - } - } - catch (Exception ex) - { + foreach (var story in sortedStories) + { + TopStoryCollection.Add(story); // Add sorted stories to the collection + } + } + catch (Exception ex) + { _logger.LogError(ex, "Error while refreshing top stories."); - } - }); + } + }); } static void InsertIntoSortedCollection(ObservableCollection collection, Comparison comparison, T modelToInsert) @@ -74,7 +74,7 @@ private async IAsyncEnumerable GetTopStoriesAsync() _logger.LogError(ex, "Error while fetching top stories."); yield break; // Stop if there’s an issue fetching the top story IDs } - + foreach (var id in topStoryIds) { StoryModel story;