Skip to content

Commit c6fa887

Browse files
committed
refactor: set favorites mode feature flag in store #408
1 parent 9bba529 commit c6fa887

14 files changed

+19
-38
lines changed

components/Home/Embedded.vue

-1
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,6 @@ function toggleExploreAroundSelectedPoi() {
183183
<PoiCardContent
184184
:details-is-external="true"
185185
:poi="selectedFeature"
186-
:favorites-mode-enabled="false"
187186
@explore-click="toggleExploreAroundSelectedPoi"
188187
@zoom-click="goToSelectedFeature"
189188
/>

components/Home/Home.vue

+3-7
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,9 @@ const menuStore = useMenuStore()
4747
const { apiMenuCategory, features, selectedCategoryIds } = storeToRefs(menuStore)
4848
const favoriteStore = useFavoriteStore()
4949
const { favoritesIds, favoriteAddresses, favoriteFeatures, favoriteCount } = storeToRefs(favoriteStore)
50-
const { config, settings, contents } = useSiteStore()
50+
const siteStore = useSiteStore()
51+
const { config, settings, contents } = siteStore
52+
const { favoritesModeEnabled } = storeToRefs(siteStore)
5153
const { $tracking } = useNuxtApp()
5254
const route = useRoute()
5355
const router = useRouter()
@@ -141,10 +143,6 @@ onMounted(async () => {
141143
//
142144
// Computed
143145
//
144-
const favoritesModeEnabled = computed(() => {
145-
return settings!.themes[0]?.favorites_mode ?? true
146-
})
147-
148146
const isBottomMenuOpened = computed(() => {
149147
return ((device.value.smallScreen && isPoiCardShown.value) || isMenuItemOpen.value)
150148
})
@@ -622,7 +620,6 @@ function handlePoiCardClose() {
622620
"
623621
:poi="selectedFeature"
624622
class="tw-grow-0"
625-
:favorites-mode-enabled="favoritesModeEnabled"
626623
@explore-click="toggleExploreAroundSelectedPoi(undefined)"
627624
@favorite-click="toggleFavorite"
628625
@zoom-click="goToSelectedFeature"
@@ -652,7 +649,6 @@ function handlePoiCardClose() {
652649
"
653650
:poi="selectedFeature"
654651
class="tw-grow-0 tw-text-left tw-h-full"
655-
:favorites-mode-enabled="favoritesModeEnabled"
656652
@explore-click="toggleExploreAroundSelectedPoi(undefined)"
657653
@favorite-click="toggleFavorite"
658654
@zoom-click="goToSelectedFeature"

components/MainMap/FavoriteNoteBook.vue

-1
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,6 @@ function removeFavorites() {
127127
<PoisDeck
128128
:pois="favoriteFeatures"
129129
:is-card-light="false"
130-
:favorites-mode-enabled="true"
131130
class="tw-pb-4"
132131
@explore-click="$emit('exploreClick', $event)"
133132
@favorite-click="$emit('favoriteClick', $event)"

components/PoisCard/PoiCard.stories.ts

-1
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ export default {
1111

1212
const defaultProps = {
1313
poi,
14-
favoritesModeEnabled: false,
1514
}
1615

1716
export const Default = bind(PoiCard, {

components/PoisCard/PoiCard.story.vue

-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@ import type { ApiPoi } from '~/lib/apiPois'
55
66
const defaultProps = {
77
poi: poi as ApiPoi,
8-
favoritesModeEnabled: false,
98
}
109
1110
const props = {

components/PoisCard/PoiCard.vue

-2
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ import type { ApiPoi } from '~/lib/apiPois'
1111
withDefaults(defineProps<{
1212
canClose?: boolean
1313
poi: ApiPoi
14-
favoritesModeEnabled: boolean
1514
showImage?: boolean
1615
}>(), {
1716
canClose: true,
@@ -84,7 +83,6 @@ const closeBtnStyles = reactive({
8483

8584
<PoiCardContent
8685
:poi="poi"
87-
:favorites-mode-enabled="favoritesModeEnabled"
8886
class="tw-px-4 tw-py-5 tw-flex tw-flex-col md:tw-overflow-y-auto tw-flex-grow md:tw-max-h-full tw-box-border tw-w-full md:tw-h-80 md:tw-w-96"
8987
@explore-click="$emit('exploreClick', $event)"
9088
@favorite-click="$emit('favoriteClick', $event)"

components/PoisCard/PoiCardContent.vue

+1-2
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ import IsochroneTrigger from '~/components/Isochrone/IsochroneTrigger.vue'
1818
//
1919
const props = withDefaults(defineProps<{
2020
detailsIsExternal?: boolean
21-
favoritesModeEnabled: boolean
2221
poi: ApiPoi
2322
}>(), {
2423
detailsIsExternal: false,
@@ -43,7 +42,7 @@ const { contribMode, isContribEligible, getContributorFields } = useContrib()
4342
const { isModeExplorer } = storeToRefs(useMapStore())
4443
const device = useDevice()
4544
const { enabled: isochroneEnabled } = useIsochrone()
46-
const { explorerModeEnabled } = storeToRefs(useSiteStore())
45+
const { explorerModeEnabled, favoritesModeEnabled } = storeToRefs(useSiteStore())
4746
4847
//
4948
// Data

components/PoisCard/PoisDeck.stories.ts

-1
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,6 @@ const defaultProps = {
2525
),
2626
),
2727
selectedPoiIds: points.map(feature => feature.properties.id),
28-
favoritesModeEnabled: false,
2928
}
3029

3130
export const Default = bind(PoisDeck, {

components/PoisCard/PoisDeck.story.vue

-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ const defaultProps = {
1818
),
1919
),
2020
selectedPoiIds: points.map(feature => feature.properties.id as ApiPoiId),
21-
favoritesModeEnabled: false,
2221
isCardLight: true,
2322
}
2423

components/PoisCard/PoisDeck.vue

+2-6
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,10 @@ import type { ApiPoi } from '~/lib/apiPois'
33
import PoiCard from '~/components/PoisCard/PoiCard.vue'
44
import PoiCardLight from '~/components/PoisCard/PoiCardLight.vue'
55
6-
withDefaults(defineProps<{
7-
favoritesModeEnabled?: boolean
6+
defineProps<{
87
pois: ApiPoi[]
98
isCardLight: boolean
10-
}>(), {
11-
favoritesModeEnabled: false,
12-
})
9+
}>()
1310
1411
defineEmits<{
1512
(e: 'exploreClick', poi: ApiPoi): void
@@ -36,7 +33,6 @@ defineEmits<{
3633
:can-close="false"
3734
:poi="item"
3835
class="tw-grow-1 poi-deck"
39-
:favorites-mode-enabled="favoritesModeEnabled"
4036
@explore-click="$emit('exploreClick', $event)"
4137
@favorite-click="$emit('favoriteClick', $event)"
4238
@zoom-click="$emit('zoomClick', $event)"

components/PoisDetails/PoiDetails.vue

-5
Original file line numberDiff line numberDiff line change
@@ -86,10 +86,6 @@ export default defineNuxtComponent({
8686
return PropertyTranslationsContextEnum.Details
8787
},
8888
89-
favoritesModeEnabled(): boolean {
90-
return this.settings.themes[0]?.favorites_mode ?? true
91-
},
92-
9389
properties(): ApiPoi['properties'] {
9490
if (!this.isLargeLayeout) {
9591
return this.poi.properties
@@ -306,7 +302,6 @@ export default defineNuxtComponent({
306302
:route="poiDeps"
307303
:color-fill="colorFill"
308304
:color-line="colorLine"
309-
:favorites-mode-enabled="favoritesModeEnabled"
310305
/>
311306
</template>
312307

components/PoisDetails/Route/RouteMap.vue

-4
Original file line numberDiff line numberDiff line change
@@ -43,10 +43,6 @@ export default defineNuxtComponent({
4343
type: String as PropType<string>,
4444
required: true,
4545
},
46-
favoritesModeEnabled: {
47-
type: Boolean,
48-
required: true,
49-
},
5046
},
5147
5248
data(): {

pages/embedded.vue

+10-6
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ import { mapStore as useMapStore } from '~/stores/map'
1010
// Composables
1111
//
1212
const { params, query, path } = useRoute()
13-
const siteStore = useSiteStore()
1413
const mapStore = useMapStore()
15-
const { config, settings } = storeToRefs(siteStore)
16-
const { API_ENDPOINT, API_PROJECT, API_THEME } = config.value!
14+
const siteStore = useSiteStore()
15+
const { config, settings } = siteStore
16+
const { favoritesModeEnabled } = storeToRefs(siteStore)
17+
const { API_ENDPOINT, API_PROJECT, API_THEME } = config!
1718
const { $trackingInit } = useNuxtApp()
1819
1920
//
@@ -28,12 +29,12 @@ const categoryIds = ref<number[]>()
2829
// Hooks
2930
//
3031
onBeforeMount(() => {
31-
$trackingInit(config.value!)
32+
$trackingInit(config!)
3233
})
3334
3435
const { boundary } = query
35-
if (boundary && typeof boundary === 'string' && settings.value!.polygons_extra) {
36-
const boundaryObject = settings.value!.polygons_extra[boundary]
36+
if (boundary && typeof boundary === 'string' && settings!.polygons_extra) {
37+
const boundaryObject = settings!.polygons_extra[boundary]
3738
if (boundaryObject) {
3839
if (typeof boundaryObject.data === 'string') {
3940
const geojson = (await (await fetch(boundaryObject.data)).json()) as GeoJSON
@@ -78,6 +79,9 @@ if (categoryIds.value && poiId.value) {
7879
7980
mapStore.setSelectedFeature(data.value!)
8081
}
82+
83+
// Disable Favorite Mode
84+
favoritesModeEnabled.value = false
8185
</script>
8286

8387
<template>

stores/site.ts

+3
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ interface State {
99
locale: string | null
1010
config: VidoConfig | undefined
1111
explorerModeEnabled: boolean
12+
favoritesModeEnabled: boolean
1213
settings: Settings | undefined
1314
contents: ContentEntry[] | undefined
1415
translations: PropertyTranslations | undefined
@@ -19,6 +20,7 @@ export const siteStore = defineStore('site', {
1920
locale: null,
2021
config: undefined,
2122
explorerModeEnabled: false,
23+
favoritesModeEnabled: false,
2224
settings: undefined,
2325
contents: undefined,
2426
translations: undefined,
@@ -28,6 +30,7 @@ export const siteStore = defineStore('site', {
2830
this.config = vidoConfig(headers)
2931
this.settings = await getSettings(this.config)
3032
this.explorerModeEnabled = this.settings?.themes[0]?.explorer_mode || true
33+
this.favoritesModeEnabled = this.settings?.themes[0]?.favorites_mode || true
3134
this.contents = await getContents(this.config)
3235
this.translations = await getPropertyTranslations(this.config)
3336
},

0 commit comments

Comments
 (0)