Skip to content

Commit

Permalink
fix: map use default style when backgroundmaps flagdisabled
Browse files Browse the repository at this point in the history
  • Loading branch information
lightlii committed Aug 30, 2023
1 parent 0f15556 commit 9b19b39
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 6 deletions.
2 changes: 0 additions & 2 deletions src/renderer/components/BackgroundMaps/BackgroundMapInfo.js
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ export const BackgroundMapInfo = ({ map, unsetMapValue }) => {

const isCurrentMap = mapStyle?.id === map.id

console.log({ map })

return (
<Fade in timeout={0}>
<Paper
Expand Down
12 changes: 10 additions & 2 deletions src/renderer/components/MapFilter/MapView/MapView.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
// @ts-check

import React, { useState } from 'react'

import MapViewContent from './MapViewContent'
import ViewWrapper from '../ViewWrapper'
import { Avatar, makeStyles } from '@material-ui/core'
import { LayersOutlined } from '@material-ui/icons'
import { BackgroundMapSelector } from './BackgroundMapSelector'
import { useSelectedMapStyle } from '../../../hooks/useMapStylesQuery'
import {
useBackgroundMapStore,
useExperimentsFlagsStore
} from '../../../hooks/store'
import { useMapStylesQuery } from '../../../hooks/useMapStylesQuery'

const MapView = (
{
Expand All @@ -30,6 +32,12 @@ const MapView = (
store => store.backgroundMaps
)
const selectedMapStyle = useBackgroundMapStore(store => store.mapStyle)
const { data: mapStyles } = useMapStylesQuery()

const mapStyleUrl =
backgroundMapsFlag && selectedMapStyle
? selectedMapStyle?.url
: mapStyles && mapStyles[0] && mapStyles[0].url

return (
<>
Expand Down Expand Up @@ -62,7 +70,7 @@ const MapView = (
getMedia={getMedia}
presets={presets}
{...otherProps}
mapStyle={selectedMapStyle && selectedMapStyle?.url}
mapStyle={mapStyleUrl}
/>
)}
</ViewWrapper>
Expand Down
5 changes: 3 additions & 2 deletions src/renderer/hooks/useMapStylesQuery.js
Original file line number Diff line number Diff line change
Expand Up @@ -56,10 +56,11 @@ const useLegacyMapStyleQuery = enabled => {

const queryResult = useQuery({
queryKey: ['getLegacyMapStyle'],
queryFn: () => {
queryFn: async () => {
try {
// This checks whether an offline style is available
api.getMapStyle('default')
await api.getMapStyle('default')

return [
{
id: CUSTOM_MAP_ID,
Expand Down

0 comments on commit 9b19b39

Please sign in to comment.