parallelize some events and database mutating actions
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
parent
fdb27b6f2c
commit
be38c91746
@ -0,0 +1,4 @@
|
||||
[*.cs]
|
||||
|
||||
# CS1998: Async method lacks 'await' operators and will run synchronously
|
||||
dotnet_diagnostic.CS1998.severity = none
|
@ -1,47 +1,47 @@
|
||||
|
||||
namespace ShoopNCook.Pages;
|
||||
using Models;
|
||||
using ShoopNCook.Views;
|
||||
using Endpoint;
|
||||
using LocalEndpoint;
|
||||
|
||||
public partial class HomePage : ContentPage
|
||||
{
|
||||
public HomePage(Account account, IUserNotifier notifier, IEndpoint endpoint)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
IRecipesService service = endpoint.RecipesService;
|
||||
IAccountRecipesPreferences preferences = service.GetPreferencesOf(account);
|
||||
|
||||
|
||||
//TODO this code can be factorised
|
||||
void PushRecipe(Layout layout, RecipeInfo info)
|
||||
{
|
||||
layout.Children.Add(new RecipeView(info, () =>
|
||||
{
|
||||
Recipe? recipe = service.GetRecipe(info);
|
||||
if (recipe != null)
|
||||
Shell.Current.Navigation.PushAsync(new RecipePage(recipe, notifier, preferences, 1));
|
||||
|
||||
namespace ShoopNCook.Pages;
|
||||
using Models;
|
||||
using ShoopNCook.Views;
|
||||
using Endpoint;
|
||||
using LocalEndpoint;
|
||||
|
||||
public partial class HomePage : ContentPage
|
||||
{
|
||||
public HomePage(Account account, IUserNotifier notifier, IEndpoint endpoint)
|
||||
{
|
||||
InitializeComponent();
|
||||
|
||||
IRecipesService service = endpoint.RecipesService;
|
||||
IAccountRecipesPreferences preferences = service.GetPreferencesOf(account);
|
||||
|
||||
|
||||
//TODO this code can be factorised
|
||||
void PushRecipe(Layout layout, RecipeInfo info)
|
||||
{
|
||||
layout.Children.Add(new RecipeView(info, () =>
|
||||
{
|
||||
Recipe? recipe = service.GetRecipe(info);
|
||||
if (recipe != null)
|
||||
Shell.Current.Navigation.PushAsync(new RecipePage(recipe, notifier, preferences, 1));
|
||||
else
|
||||
{
|
||||
notifier.Error("Could not find recipe");
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
service.PopularRecipes().ForEach(recipe => PushRecipe(PopularsList, recipe));
|
||||
preferences.GetRecommendedRecipes().ForEach(recipe => PushRecipe(RecommendedList, recipe));
|
||||
|
||||
ProfilePictureImage.Source = ImageSource.FromUri(account.User.ProfilePicture);
|
||||
ProfilePictureName.Text = account.User.Name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private void OnSyncButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
Shell.Current.Navigation.PushAsync(new SearchPage());
|
||||
}
|
||||
}
|
||||
}));
|
||||
}
|
||||
|
||||
service.PopularRecipes().ForEach(recipe => PushRecipe(PopularsList, recipe));
|
||||
preferences.GetRecommendedRecipes().ForEach(recipe => PushRecipe(RecommendedList, recipe));
|
||||
|
||||
ProfilePictureImage.Source = ImageSource.FromUri(account.User.ProfilePicture);
|
||||
ProfilePictureName.Text = account.User.Name;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
private async void OnSyncButtonClicked(object sender, EventArgs e)
|
||||
{
|
||||
await Shell.Current.Navigation.PushAsync(new SearchPage());
|
||||
}
|
||||
}
|
Loading…
Reference in new issue