From a2d71abf479c0377fcfa1ca7a562034ae474e3b7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?No=C3=A9=20Viricel?= Date: Mon, 28 Oct 2024 18:02:21 +0100 Subject: [PATCH] refactor: move event from prop to emit #401 --- components/Home/Home.vue | 11 +++++++---- components/MainMap/FavoriteMenu.vue | 29 ++++++++++++++--------------- 2 files changed, 21 insertions(+), 19 deletions(-) diff --git a/components/Home/Home.vue b/components/Home/Home.vue index 8d33d60b..277ca095 100644 --- a/components/Home/Home.vue +++ b/components/Home/Home.vue @@ -284,7 +284,10 @@ watch(isModeFavorites, async (isEnabled) => { // // Methods // -function goToSelectedFeature() { +function goToSelectedFeature(feature?: ApiPoi) { + if (feature) + mapStore.setSelectedFeature(feature) + if (mapFeaturesRef.value) mapFeaturesRef.value.goToSelectedFeature() } @@ -553,11 +556,11 @@ function handlePoiCardClose() { > () -const emit = defineEmits(['toggleFavoriteMode', 'toggleNoteBookMode']) +const emit = defineEmits<{ + (e: 'exploreClick', poi: ApiPoi): void + (e: 'favoriteClick', poi: ApiPoi): void + (e: 'toggleFavoriteMode'): void + (e: 'toggleNoteBookMode'): void + (e: 'zoomClick', poi: ApiPoi): void +}>() const device = useDevice() const notebookModal = ref(false) @@ -24,9 +28,9 @@ const mapStore = useMapStore() const { isModeFavorites } = storeToRefs(mapStore) const { favoriteCount } = storeToRefs(useFavoriteStore()) -function explore(poi: ApiPoi) { +function onExploreClick(poi: ApiPoi) { notebookModal.value = false - props.exploreAroundSelectedPoi(poi) + emit('exploreClick', poi) } function onClose() { @@ -35,13 +39,8 @@ function onClose() { } function onZoomClick(poi: ApiPoi) { - mapStore.setSelectedFeature(poi) notebookModal.value = false - props.goToSelectedPoi(poi) -} - -function handleFavorite(poi: ApiPoi) { - props.toggleFavorite(poi) + emit('zoomClick', poi) } const { $tracking } = useNuxtApp() @@ -107,8 +106,8 @@ async function toggleNoteBookMode() { max-width="80rem" >