From f1db052266f254dec65435a54702ca6e2a74a8cd Mon Sep 17 00:00:00 2001 From: Ariel Costas Guerrero <94913521+arielcostas@users.noreply.github.com> Date: Fri, 30 Aug 2024 16:26:19 +0200 Subject: Fix client-side stop list cache --- Backend/ListStops.cs | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'Backend') diff --git a/Backend/ListStops.cs b/Backend/ListStops.cs index 93b6a48..b6f9ab4 100644 --- a/Backend/ListStops.cs +++ b/Backend/ListStops.cs @@ -2,6 +2,7 @@ using Microsoft.Azure.Functions.Worker; using Microsoft.AspNetCore.Http; using Microsoft.AspNetCore.Mvc; using Costasdev.VigoTransitApi; +using Costasdev.VigoTransitApi.Types; namespace Costasdev.UrbanoVigoWeb; @@ -9,6 +10,8 @@ public class ListStops { private readonly VigoTransitApiClient _api; + public List? Stops { get; set; } = null; + public ListStops(HttpClient http) { _api = new VigoTransitApiClient(http); @@ -17,6 +20,12 @@ public class ListStops [Function("ListStops")] public async Task Run([HttpTrigger(AuthorizationLevel.Anonymous, "get")] HttpRequest req) { + // Get stops from cache + if (Stops != null) + { + return new OkObjectResult(Stops); + } + try { var stops = await _api.GetStops(); -- cgit v1.3