Skip to content

Commit

Permalink
store location in local storage
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaya committed Jun 29, 2020
1 parent d011968 commit 6eec954
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions src/components/RunMap/RunMap.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import React from 'react';
import React, { useEffect } from 'react';
import {
Map,
Marker,
Expand All @@ -12,7 +12,7 @@ import { useDispatch, useSelector } from 'react-redux';
import 'leaflet/dist/leaflet.css';

import { LatLng } from '../../server/types';
import { safeStoredLocation } from '../../utils/localStorage';
import { safeStoredLocation, storeLocation } from '../../utils/localStorage';
import { flippedSelector, locationSelector, routeSelector } from '../../store/route/selectors';

import iconUrl from './Marker.png';
Expand Down Expand Up @@ -45,12 +45,12 @@ const RunMap: React.FC = () => {
? [...stateCoordinates].reverse()
: stateCoordinates;

// @TODO side effect in middleware
// useEffect(() => {
// if (startLocation.state === 'hasValue' && startLocation.contents) {
// storeLocation(startLocation.contents);
// }
// }, [startLocation.contents, startLocation.state]);
// store starting location in localStorage
useEffect(() => {
if (startLocation) {
storeLocation(startLocation);
}
}, [startLocation]);

const center = coordinates.length > 0 ? coordinates[0] : defaultCenter;
const bounds = coordinates.length > 0 ? coordinates : undefined;
Expand Down

0 comments on commit 6eec954

Please sign in to comment.