Skip to content

Commit

Permalink
refactor: set explorer mode feature flag as store getter #403
Browse files Browse the repository at this point in the history
  • Loading branch information
wazolab committed Oct 28, 2024
1 parent f92a72c commit 42a6aa5
Show file tree
Hide file tree
Showing 15 changed files with 9 additions and 38 deletions.
6 changes: 0 additions & 6 deletions components/Home/Embedded.vue
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,6 @@ onMounted(() => {
//
// Computed
//
const explorerModeEnabled = computed(() => {
return settings!.themes[0]?.explorer_mode ?? true
})
const filters = computed(() => {
return route.query.menuItemIds
? route.query.menuItemIds
Expand Down Expand Up @@ -187,7 +183,6 @@ function toggleExploreAroundSelectedPoi() {
<PoiCardContent
:details-is-external="true"
:poi="selectedFeature"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="false"
@explore-click="toggleExploreAroundSelectedPoi"
@zoom-click="goToSelectedFeature"
Expand All @@ -207,7 +202,6 @@ function toggleExploreAroundSelectedPoi() {
:features="mapFeatures"
:selected-categories-ids="selectedCategoryIds"
:style-icon-filter="poiFilters"
:explorer-mode-enabled="explorerModeEnabled"
:cooperative-gestures="false"
:boundary-area="boundaryArea || settings!.polygon.data"
/>
Expand Down
8 changes: 0 additions & 8 deletions components/Home/Home.vue
Original file line number Diff line number Diff line change
Expand Up @@ -141,10 +141,6 @@ onMounted(async () => {
//
// Computed
//
const explorerModeEnabled = computed(() => {
return settings!.themes[0]?.explorer_mode ?? true
})
const favoritesModeEnabled = computed(() => {
return settings!.themes[0]?.favorites_mode ?? true
})
Expand Down Expand Up @@ -560,7 +556,6 @@ function handlePoiCardClose() {
:explore-around-selected-poi="toggleExploreAroundSelectedPoi"
:go-to-selected-poi="goToSelectedFeature"
:toggle-favorite="toggleFavorite"
:explorer-mode-enabled="explorerModeEnabled"
@toggle-favorite-mode="toggleFavoriteMode"
@toggle-note-book-mode="toggleNoteBookMode"
/>
Expand All @@ -585,7 +580,6 @@ function handlePoiCardClose() {
:features="mapFeatures"
:selected-categories-ids="isModeExplorer ? [] : selectedCategoryIds"
:style-icon-filter="poiFilters"
:explorer-mode-enabled="explorerModeEnabled"
:enable-filter-route-by-categories="!isModeFavorites"
:enable-filter-route-by-features="isModeFavorites"
:boundary-area="boundaryArea || settings!.polygon.data"
Expand Down Expand Up @@ -625,7 +619,6 @@ function handlePoiCardClose() {
"
:poi="selectedFeature"
class="tw-grow-0"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="favoritesModeEnabled"
@explore-click="toggleExploreAroundSelectedPoi(undefined)"
@favorite-click="toggleFavorite"
Expand Down Expand Up @@ -656,7 +649,6 @@ function handlePoiCardClose() {
"
:poi="selectedFeature"
class="tw-grow-0 tw-text-left tw-h-full"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="favoritesModeEnabled"
@explore-click="toggleExploreAroundSelectedPoi(undefined)"
@favorite-click="toggleFavorite"
Expand Down
2 changes: 0 additions & 2 deletions components/MainMap/FavoriteMenu.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import { favoriteStore as useFavoriteStore } from '~/stores/favorite'
const props = defineProps<{
exploreAroundSelectedPoi: Function
explorerModeEnabled: boolean
goToSelectedPoi: Function
toggleFavorite: Function
}>()
Expand Down Expand Up @@ -108,7 +107,6 @@ async function toggleNoteBookMode() {
max-width="80rem"
>
<FavoriteNoteBook
:explorer-mode-enabled="explorerModeEnabled"
@explore-click="explore"
@favorite-click="handleFavorite"
@zoom-click="onZoomClick"
Expand Down
5 changes: 0 additions & 5 deletions components/MainMap/FavoriteNoteBook.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@ import type { ApiPoi } from '~/lib/apiPois'
import { favoriteStore as useFavoriteStore } from '~/stores/favorite'
import { siteStore as useSiteStore } from '~/stores/site'
defineProps<{
explorerModeEnabled: boolean
}>()
defineEmits<{
(e: 'onClose'): void
(e: 'exploreClick', poi: ApiPoi): void
Expand Down Expand Up @@ -131,7 +127,6 @@ function removeFavorites() {
<PoisDeck
:pois="favoriteFeatures"
:is-card-light="false"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="true"
class="tw-pb-4"
@explore-click="$emit('exploreClick', $event)"
Expand Down
1 change: 0 additions & 1 deletion components/MainMap/MapFeatures.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ const defaultProps = {
},
} as ApiMenuCategory,
],
explorerModeEnabled: false,
}

export const Default = bind(
Expand Down
1 change: 0 additions & 1 deletion components/MainMap/MapFeatures.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ const defaultProps = {
},
} as ApiMenuCategory,
],
explorerModeEnabled: false,
}
const feature1: ApiPoi = {
Expand Down
9 changes: 4 additions & 5 deletions components/MainMap/MapFeatures.vue
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,6 @@ export default defineNuxtComponent({
type: Array as PropType<Array<string[]> | null>,
default: null,
},
explorerModeEnabled: {
type: Boolean,
required: true,
},
enableFilterRouteByCategories: {
type: Boolean,
default: true,
Expand All @@ -122,7 +118,9 @@ export default defineNuxtComponent({
setup() {
const device = useDevice()
const { config } = storeToRefs(useSiteStore())
const siteStore = useSiteStore()
const { config } = siteStore
const { explorerModeEnabled } = storeToRefs(useSiteStore())
const mapStore = useMapStore()
const { center, selectedFeature, pinMarker, teritorioCluster } = storeToRefs(mapStore)
const mapStyleLoaded = ref(false)
Expand All @@ -131,6 +129,7 @@ export default defineNuxtComponent({
center,
config,
device,
explorerModeEnabled,
mapBase: ref<InstanceType<typeof MapBase>>(),
mapStore,
mapStyleLoaded,
Expand Down
1 change: 0 additions & 1 deletion components/PoisCard/PoiCard.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ export default {

const defaultProps = {
poi,
explorerModeEnabled: false,
favoritesModeEnabled: false,
}

Expand Down
1 change: 0 additions & 1 deletion components/PoisCard/PoiCard.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ import type { ApiPoi } from '~/lib/apiPois'
const defaultProps = {
poi: poi as ApiPoi,
explorerModeEnabled: false,
favoritesModeEnabled: false,
}
Expand Down
2 changes: 0 additions & 2 deletions components/PoisCard/PoiCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ import type { ApiPoi } from '~/lib/apiPois'
withDefaults(defineProps<{
canClose?: boolean
poi: ApiPoi
explorerModeEnabled: boolean
favoritesModeEnabled: boolean
showImage?: boolean
}>(), {
Expand Down Expand Up @@ -85,7 +84,6 @@ const closeBtnStyles = reactive({
<PoiCardContent
:poi="poi"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="favoritesModeEnabled"
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"
@explore-click="$emit('exploreClick', $event)"
Expand Down
3 changes: 2 additions & 1 deletion components/PoisCard/PoiCardContent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import type { ApiPoi } from '~/lib/apiPois'
import { coordinatesHref } from '~/lib/coordinates'
import { favoriteStore as useFavoriteStore } from '~/stores/favorite'
import { mapStore as useMapStore } from '~/stores/map'
import { siteStore as useSiteStore } from '~/stores/site'
import ContribFieldGroup from '~/components/Fields/ContribFieldGroup.vue'
import useDevice from '~/composables/useDevice'
import IsochroneTrigger from '~/components/Isochrone/IsochroneTrigger.vue'
Expand All @@ -17,7 +18,6 @@ import IsochroneTrigger from '~/components/Isochrone/IsochroneTrigger.vue'
//
const props = withDefaults(defineProps<{
detailsIsExternal?: boolean
explorerModeEnabled: boolean
favoritesModeEnabled: boolean
poi: ApiPoi
}>(), {
Expand All @@ -43,6 +43,7 @@ const { contribMode, isContribEligible, getContributorFields } = useContrib()
const { isModeExplorer } = storeToRefs(useMapStore())
const device = useDevice()
const { enabled: isochroneEnabled } = useIsochrone()
const { explorerModeEnabled } = storeToRefs(useSiteStore())
//
// Data
Expand Down
1 change: 0 additions & 1 deletion components/PoisCard/PoisDeck.stories.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ const defaultProps = {
),
),
selectedPoiIds: points.map(feature => feature.properties.id),
explorerModeEnabled: false,
favoritesModeEnabled: false,
}

Expand Down
1 change: 0 additions & 1 deletion components/PoisCard/PoisDeck.story.vue
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ const defaultProps = {
),
),
selectedPoiIds: points.map(feature => feature.properties.id as ApiPoiId),
explorerModeEnabled: false,
favoritesModeEnabled: false,
isCardLight: true,
}
Expand Down
3 changes: 0 additions & 3 deletions components/PoisCard/PoisDeck.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,10 @@ import PoiCard from '~/components/PoisCard/PoiCard.vue'
import PoiCardLight from '~/components/PoisCard/PoiCardLight.vue'
withDefaults(defineProps<{
explorerModeEnabled?: boolean
favoritesModeEnabled?: boolean
pois: ApiPoi[]
isCardLight: boolean
}>(), {
explorerModeEnabled: false,
favoritesModeEnabled: false,
})
Expand Down Expand Up @@ -38,7 +36,6 @@ defineEmits<{
:can-close="false"
:poi="item"
class="tw-grow-1 poi-deck"
:explorer-mode-enabled="explorerModeEnabled"
:favorites-mode-enabled="favoritesModeEnabled"
@explore-click="$emit('exploreClick', $event)"
@favorite-click="$emit('favoriteClick', $event)"
Expand Down
3 changes: 3 additions & 0 deletions stores/site.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@ export const siteStore = defineStore('site', {
contents: undefined,
translations: undefined,
}),
getters: {
explorerModeEnabled: (state: State) => state.settings?.themes[0]?.explorer_mode || true,
},
actions: {
async init(headers: Record<string, string>) {
this.config = vidoConfig(headers)
Expand Down

0 comments on commit 42a6aa5

Please sign in to comment.