Skip to content

Commit

Permalink
Update NewsViewModel.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
iNoles authored Nov 20, 2024
1 parent e80e5bf commit f0d80fd
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions NewsViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,20 +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();
await foreach (var story in GetTopStoriesAsync())
{
InsertIntoSortedCollection(TopStoryCollection, (a, b) => b.Score.CompareTo(a.Score), story);
}
}
catch (Exception ex)
{
var sortedStories = (await GetTopStoriesAsync().ToListAsync())

Check failure on line 24 in NewsViewModel.cs

View workflow job for this annotation

GitHub Actions / Build_Windows

'IAsyncEnumerable<StoryModel>' does not contain a definition for 'ToListAsync' and no accessible extension method 'ToListAsync' accepting a first argument of type 'IAsyncEnumerable<StoryModel>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in NewsViewModel.cs

View workflow job for this annotation

GitHub Actions / Build_Windows

'IAsyncEnumerable<StoryModel>' does not contain a definition for 'ToListAsync' and no accessible extension method 'ToListAsync' accepting a first argument of type 'IAsyncEnumerable<StoryModel>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in NewsViewModel.cs

View workflow job for this annotation

GitHub Actions / Build_Android

'IAsyncEnumerable<StoryModel>' does not contain a definition for 'ToListAsync' and no accessible extension method 'ToListAsync' accepting a first argument of type 'IAsyncEnumerable<StoryModel>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in NewsViewModel.cs

View workflow job for this annotation

GitHub Actions / Build_Android

'IAsyncEnumerable<StoryModel>' does not contain a definition for 'ToListAsync' and no accessible extension method 'ToListAsync' accepting a first argument of type 'IAsyncEnumerable<StoryModel>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in NewsViewModel.cs

View workflow job for this annotation

GitHub Actions / Build_MacCatalyst

'IAsyncEnumerable<StoryModel>' does not contain a definition for 'ToListAsync' and no accessible extension method 'ToListAsync' accepting a first argument of type 'IAsyncEnumerable<StoryModel>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in NewsViewModel.cs

View workflow job for this annotation

GitHub Actions / Build_MacCatalyst

'IAsyncEnumerable<StoryModel>' does not contain a definition for 'ToListAsync' and no accessible extension method 'ToListAsync' accepting a first argument of type 'IAsyncEnumerable<StoryModel>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in NewsViewModel.cs

View workflow job for this annotation

GitHub Actions / Build_iOS

'IAsyncEnumerable<StoryModel>' does not contain a definition for 'ToListAsync' and no accessible extension method 'ToListAsync' accepting a first argument of type 'IAsyncEnumerable<StoryModel>' could be found (are you missing a using directive or an assembly reference?)

Check failure on line 24 in NewsViewModel.cs

View workflow job for this annotation

GitHub Actions / Build_iOS

'IAsyncEnumerable<StoryModel>' does not contain a definition for 'ToListAsync' and no accessible extension method 'ToListAsync' accepting a first argument of type 'IAsyncEnumerable<StoryModel>' could be found (are you missing a using directive or an assembly reference?)
.OrderByDescending(story => story.Score)
.ToList();
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<T>(ObservableCollection<T> collection, Comparison<T> comparison, T modelToInsert)
Expand Down

0 comments on commit f0d80fd

Please sign in to comment.