Decouple route selection: Map uses persistent store state, Schedules uses local state. Map selection only persists on Map banner.

This commit is contained in:
2026-03-01 12:38:04 -05:00
parent b8577a512b
commit 59de2c7c23
3 changed files with 36 additions and 21 deletions

View File

@ -47,7 +47,6 @@ const unitFetchInterval = ref<any>(null);
const userCoords = ref<{ lat: number; lng: number } | null>(null);
const optimalStopPulse = ref<any>(null);
const showRouteDropdown = ref(false);
const wasSelectedFromMap = ref(false);
const isInternalSelection = ref(false);
const alturaNavbar = ref(64);
@ -238,7 +237,7 @@ async function initializeMap() {
}
// If we have a selected route AND it was from map, show its stops
if (routeStore.selectedRouteId && routeStore.selectedRouteStops.length > 0 && wasSelectedFromMap.value) {
if (routeStore.selectedRouteId && routeStore.selectedRouteStops.length > 0 && routeStore.wasSelectedFromMap) {
updateMapMarkers();
} else {
// If no route or not from map, ensure it's clean (promos stay though)
@ -265,7 +264,7 @@ watch(
// Si la selección no viene de dentro de MapView (selectRouteAndClose),
// reseteamos el flag de origen Mapa para que el buscador no se "fije"
if (!isInternalSelection.value) {
wasSelectedFromMap.value = false;
routeStore.wasSelectedFromMap = false;
}
// ALWAYS clear markers first when route changes - do this immediately
@ -279,7 +278,7 @@ watch(
}
if (routeId) {
if (wasSelectedFromMap.value) {
if (routeStore.wasSelectedFromMap) {
// Only update map visuals if selection came from the Map search flow
await updateMapMarkers(true);
} else {
@ -290,7 +289,7 @@ watch(
} else {
// Clear markers when no route is selected
lastProcessedRouteId.value = null;
wasSelectedFromMap.value = false; // Reset selection origin
routeStore.wasSelectedFromMap = false; // Reset selection origin
clearMapMarkers();
}
},
@ -409,7 +408,7 @@ async function updatePromoMarkers() {
async function selectRouteAndClose(routeId: string, routeName: string) {
console.log(`🤖 JARVIS: Iniciando viaje hacia ${routeName}`);
isInternalSelection.value = true;
wasSelectedFromMap.value = true;
routeStore.wasSelectedFromMap = true;
await routeStore.selectRoute(routeId, routeName);
showRouteDropdown.value = false;
showUberSearch.value = false; // Close the expanded search panel
@ -631,12 +630,12 @@ async function highlightOptimalStopForRoute() {
</div>
<!-- Uber-like Search Interface -->
<div class="uber-search-container" :class="{ 'compact-mode': routeStore.selectedRouteId && wasSelectedFromMap && !showUberSearch }">
<div class="uber-search-container" :class="{ 'compact-mode': routeStore.selectedRouteId && routeStore.wasSelectedFromMap && !showUberSearch }">
<!-- Floating Triggers -->
<div v-if="!showUberSearch" class="triggers-row">
<!-- Shrunk Trigger (Icon only) - Only if selected from MAP -->
<div
v-if="routeStore.selectedRouteId && wasSelectedFromMap"
v-if="routeStore.selectedRouteId && routeStore.wasSelectedFromMap"
class="uber-search-trigger circular"
@click="openUberSearch"
:title="t('map.search')"
@ -657,7 +656,7 @@ async function highlightOptimalStopForRoute() {
<!-- Nuevo Banner de Parada Cercana Alineado (Redimensionado y con ETA) -->
<Transition name="banner-slide">
<div
v-if="paradaCercana && routeStore.selectedRouteId && !showETACard && !isBannerClosing && wasSelectedFromMap"
v-if="paradaCercana && routeStore.selectedRouteId && !showETACard && !isBannerClosing && routeStore.wasSelectedFromMap"
class="best-stop-banner-compact"
>
<div class="banner-icon-bg">
@ -712,7 +711,7 @@ async function highlightOptimalStopForRoute() {
v-for="route in routeStore.allRoutes"
:key="route.id"
class="uber-result-item"
:class="{ 'selected-route': route.id === routeStore.selectedRouteId && wasSelectedFromMap }"
:class="{ 'selected-route': route.id === routeStore.selectedRouteId && routeStore.wasSelectedFromMap }"
@click="selectRouteAndClose(route.id, route.name)"
>
<div class="result-icon">