diff --git a/frontend/capacitor.config.ts b/frontend/capacitor.config.ts index 830c10c..1064af4 100644 --- a/frontend/capacitor.config.ts +++ b/frontend/capacitor.config.ts @@ -7,6 +7,16 @@ const config: CapacitorConfig = { server: { androidScheme: 'http', cleartext: true + }, + plugins: { + SplashScreen: { + launchShowDuration: 2000, + launchAutoHide: true, + backgroundColor: "#101820", + androidSplashResourceName: "splash", + androidScaleType: "CENTER_CROP", + showSpinner: false, + } } }; diff --git a/frontend/src/stores/busStop.ts b/frontend/src/stores/busStop.ts index 4e72b22..5a07137 100644 --- a/frontend/src/stores/busStop.ts +++ b/frontend/src/stores/busStop.ts @@ -9,9 +9,13 @@ export const useBusStopStore = defineStore('busStop', () => { const busStops = ref([]) const isLoading = ref(false) const error = ref(null) + const lastFetched = ref(0) async function loadBusStops(force = false) { - if (!force && busStops.value.length > 0) { + const CACHE_TIME = 1000 * 60 * 30; // 30 minutos + const now = Date.now(); + + if (!force && busStops.value.length > 0 && (now - lastFetched.value < CACHE_TIME)) { return } @@ -19,6 +23,7 @@ export const useBusStopStore = defineStore('busStop', () => { error.value = null try { busStops.value = await busStopsService.getAllBusStops() + lastFetched.value = now; } catch (e) { error.value = e instanceof Error ? e.message : 'Failed to load bus stops' console.error('Error loading bus stops:', e) diff --git a/frontend/src/stores/route.ts b/frontend/src/stores/route.ts index 4e7fb0a..16dd7f8 100644 --- a/frontend/src/stores/route.ts +++ b/frontend/src/stores/route.ts @@ -12,11 +12,16 @@ export const useRouteStore = defineStore('route', () => { const isLoadingRoutes = ref(false) const isLoadingStops = ref(false) const error = ref(null) + const lastFetched = ref(0) // ⚡ CACHÉ ESTÁTICO const hasSelectedRoute = computed(() => selectedRouteId.value !== null && selectedRouteName.value !== null) async function loadRoutes(filters?: { originCity?: string, destinationCity?: string }, force = false) { - if (!force && !filters && allRoutes.value.length > 0) { + const CACHE_TIME = 1000 * 60 * 15; // 15 minutos + const now = Date.now(); + + // Si no forzamos, no hay filtros raros, ya tenemos rutas y aún no expira el caché, omitir llamada + if (!force && !filters && allRoutes.value.length > 0 && (now - lastFetched.value < CACHE_TIME)) { return } @@ -24,6 +29,7 @@ export const useRouteStore = defineStore('route', () => { error.value = null try { allRoutes.value = await routesService.getAllRoutes(filters) + if (!filters) lastFetched.value = now; // Solo actualizar timer si es un request general limio } catch (e) { error.value = e instanceof Error ? e.message : 'Failed to load routes' console.error('Error loading routes:', e) diff --git a/frontend/src/views/DiscoverView.vue b/frontend/src/views/DiscoverView.vue index 5d93ad8..8e1be2a 100644 --- a/frontend/src/views/DiscoverView.vue +++ b/frontend/src/views/DiscoverView.vue @@ -200,6 +200,7 @@ function resetFilters() {
@@ -207,6 +208,8 @@ function resetFilters() { @@ -271,12 +274,15 @@ function resetFilters() {