"Back" now works for search results (#3)
- Made the application only retrieve the list of continents once per visit - Update the verbiage for phase 3 completion
This commit is contained in:
@@ -1,5 +1,8 @@
|
||||
using JobsJobsJobs.Shared;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Net.Http;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace JobsJobsJobs.Client
|
||||
{
|
||||
@@ -45,6 +48,33 @@ namespace JobsJobsJobs.Client
|
||||
}
|
||||
}
|
||||
|
||||
private IEnumerable<Continent>? _continents = null;
|
||||
|
||||
/// <summary>
|
||||
/// Get a list of continents (only retrieves once per application load)
|
||||
/// </summary>
|
||||
/// <param name="http">The HTTP client to use to obtain continents the first time</param>
|
||||
/// <returns>The list of continents</returns>
|
||||
/// <exception cref="ApplicationException">If the continents cannot be loaded</exception>
|
||||
public async Task<IEnumerable<Continent>> GetContinents(HttpClient http)
|
||||
{
|
||||
if (_continents == null)
|
||||
{
|
||||
ServerApi.SetJwt(http, this);
|
||||
var continentResult = await ServerApi.RetrieveMany<Continent>(http, "continent/all");
|
||||
|
||||
if (continentResult.IsOk)
|
||||
{
|
||||
_continents = continentResult.Ok;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ApplicationException($"Could not load continents - {continentResult.Error}");
|
||||
}
|
||||
}
|
||||
return _continents;
|
||||
}
|
||||
|
||||
public AppState() { }
|
||||
|
||||
private void NotifyChanged() => OnChange.Invoke();
|
||||
|
||||
Reference in New Issue
Block a user