fix: resolve blank screen on return from external links
This commit is contained in:
@ -143,10 +143,28 @@ async function fetchData() {
|
||||
updateActiveUnits();
|
||||
}
|
||||
|
||||
function handleRefocus() {
|
||||
async function handleRefocus() {
|
||||
// Refrescar datos en fondo
|
||||
fetchData();
|
||||
|
||||
await nextTick();
|
||||
|
||||
if (map.value) {
|
||||
google.maps.event.trigger(map.value, 'resize');
|
||||
// El mapa sigue vivo — solo redimensionar y actualizar
|
||||
try {
|
||||
google.maps.event.trigger(map.value, 'resize');
|
||||
} catch (_) { /* ignorar si google no disponible */ }
|
||||
updateActiveUnits();
|
||||
} else {
|
||||
// El mapa fue destruido por el browser al suspender la pestaña — reinicializar
|
||||
console.log('SIBU | Mapa perdido tras refocus, reinicializando...');
|
||||
if (isLoaded.value) {
|
||||
await initializeMap();
|
||||
} else {
|
||||
const unwatch = watch(isLoaded, async (loaded) => {
|
||||
if (loaded) { await initializeMap(); unwatch(); }
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -154,7 +172,7 @@ function handleRefocus() {
|
||||
onMounted(async () => {
|
||||
analyticsService.logEvent({ event_name: 'screen_view', properties: { screen_name: 'Map' } })
|
||||
window.addEventListener('app-refocus', handleRefocus);
|
||||
|
||||
|
||||
await fetchData();
|
||||
|
||||
const queryRouteId = router.currentRoute.value.query.routeId as string;
|
||||
@ -179,7 +197,6 @@ onMounted(async () => {
|
||||
unitFetchInterval.value = setInterval(updateActiveUnits, 15000);
|
||||
startCarousel();
|
||||
|
||||
// 🛰️ RESIZE FIX: Trigger map resize when app becomes visible again
|
||||
document.addEventListener('visibilitychange', handleVisibilityChange);
|
||||
});
|
||||
|
||||
@ -192,8 +209,9 @@ onUnmounted(() => {
|
||||
|
||||
function handleVisibilityChange() {
|
||||
if (document.visibilityState === 'visible' && map.value) {
|
||||
console.log('SIBU | App visible, redimensionando mapa...');
|
||||
google.maps.event.trigger(map.value, 'resize');
|
||||
try {
|
||||
google.maps.event.trigger(map.value, 'resize');
|
||||
} catch (_) { /* ignorar */ }
|
||||
updateActiveUnits();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user