diff --git a/src/stores/app.ts b/src/stores/app.ts index dc8ef70b..de3f0d2c 100644 --- a/src/stores/app.ts +++ b/src/stores/app.ts @@ -1,5 +1,5 @@ import { defineStore, storeToRefs } from 'pinia' -import { ref } from 'vue' +import { computed, ref } from 'vue' import { watchOnce } from '@vueuse/core' import { useCluster } from './cluster' @@ -7,6 +7,8 @@ export const useApp = defineStore('app', () => { // We just track the first load, so we can show a loading indicator const firstLocationsLoaded = ref(false) const isListShown = ref(false) + const mapLoaded = ref(false) + const showSplashScreen = computed(() => !mapLoaded.value || !firstLocationsLoaded.value) const { singles, clusters } = storeToRefs(useCluster()) @@ -27,5 +29,7 @@ export const useApp = defineStore('app', () => { isListShown, shouldShowSearchBoxHint, hideSearchBoxHint, + mapLoaded, + showSplashScreen, } }) diff --git a/src/stores/cluster.ts b/src/stores/cluster.ts index 7b999be9..534ee18a 100644 --- a/src/stores/cluster.ts +++ b/src/stores/cluster.ts @@ -47,7 +47,7 @@ export const useCluster = defineStore('cluster', () => { const item: LocationClusterSet | undefined = memoized.get(key) // If the item exists and the bounding box is within the memoized area, we can reuse the memoized item and there is no need to re-cluster - const needsToUpdate = !item || !bBoxIsWithinArea(boundingBox.value!, item.memoizedArea) + const needsToUpdate = !item || !boundingBox.value || !bBoxIsWithinArea(boundingBox.value, item.memoizedArea) // Update the memoized item if it exists if (!needsToUpdate) { diff --git a/src/stores/map.ts b/src/stores/map.ts index ce5cad87..b5f82949 100644 --- a/src/stores/map.ts +++ b/src/stores/map.ts @@ -39,6 +39,8 @@ export const useMap = defineStore('map', () => { } function onBoundsChanged() { + if (!map.value || !map.value.getBounds()) + return boundingBox.value = boundsToBox(map.value!.getBounds()) updateRouteDebouncer()