Skip to content

Commit

Permalink
Allow changing position when adding location
Browse files Browse the repository at this point in the history
  • Loading branch information
wbazant committed Oct 25, 2024
1 parent 23b5ec1 commit f4e0081
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/redux/locationSlice.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import {
getLocationById,
} from '../utils/api'
import { fetchReviewData } from './reviewSlice'
import { updateLastMapView } from './viewportSlice'

export const fetchLocationData = createAsyncThunk(
'location/fetchLocationData',
Expand Down Expand Up @@ -185,6 +186,11 @@ const locationSlice = createSlice({
},
},
extraReducers: {
[updateLastMapView]: (state, action) => {
if (state.locationId === 'new') {
state.position = action.payload.center
}
},
[fetchLocationData.pending]: (state, action) => {
state.location = null
state.locationId = parseInt(action.meta.arg.locationId)
Expand Down

0 comments on commit f4e0081

Please sign in to comment.