-
Notifications
You must be signed in to change notification settings - Fork 32
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Store current location/review in Redux (#410)
Simplifies EntryWrapper and enables several other improvements: * [mobile] Add support for about routes in tabs component (fixes #411) * [mobile] Allow changing settings during "set location position" process (fixed #407) * [desktop] Highlight on click but load only last location when many selected in quick succession (fixes #412) * Avoid calling API again to edit the already- loaded location
- Loading branch information
Showing
18 changed files
with
340 additions
and
259 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import { useEffect } from 'react' | ||
import { useDispatch } from 'react-redux' | ||
|
||
import { fetchLocationData, setNewLocation } from '../../redux/locationSlice' | ||
|
||
const ConnectLocation = ({ locationId }) => { | ||
const dispatch = useDispatch() | ||
|
||
useEffect(() => { | ||
if (locationId === 'new') { | ||
dispatch(setNewLocation()) | ||
} else { | ||
dispatch(fetchLocationData({ locationId })) | ||
} | ||
}, [dispatch, locationId]) | ||
return null | ||
} | ||
|
||
export default ConnectLocation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
import { useEffect } from 'react' | ||
import { useDispatch } from 'react-redux' | ||
|
||
import { fetchReviewData } from '../../redux/reviewSlice' | ||
|
||
const ConnectReview = ({reviewId}) => { | ||
const dispatch = useDispatch() | ||
useEffect(() => { | ||
dispatch(fetchReviewData(reviewId)) | ||
}, [dispatch, reviewId]) | ||
|
||
return null | ||
} | ||
|
||
export default ConnectReview |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { useEffect } from 'react' | ||
import { useDispatch } from 'react-redux' | ||
|
||
import { clearLocation } from '../../redux/locationSlice' | ||
|
||
const DisconnectLocation = () => { | ||
const dispatch = useDispatch() | ||
|
||
useEffect(() => { | ||
dispatch(clearLocation()) | ||
}, [dispatch]) | ||
|
||
return null | ||
} | ||
|
||
export default DisconnectLocation |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
import { Route } from 'react-router-dom' | ||
|
||
import ConnectLocation from './ConnectLocation' | ||
import ConnectReview from './ConnectReview' | ||
import DisconnectLocation from './DisconnectLocation' | ||
|
||
const connectRoutes = [ | ||
<Route key="connect-location" path="/locations/:locationId"> | ||
{({ match }) => | ||
match && <ConnectLocation locationId={match.params.locationId} /> | ||
} | ||
</Route>, | ||
<Route key="connect-review" path="/reviews/:reviewId/edit"> | ||
{({ match }) => match && <ConnectReview reviewId={match.params.reviewId} />} | ||
</Route>, | ||
<Route key="disconnect-location" path={['/map', '/list']}> | ||
{({ match }) => match && <DisconnectLocation />} | ||
</Route>, | ||
] | ||
|
||
export default connectRoutes |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.