Skip to content

Commit

Permalink
close drawer on receiving route
Browse files Browse the repository at this point in the history
  • Loading branch information
Gaya committed Jun 29, 2020
1 parent ed4514f commit 376dc44
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 6 deletions.
7 changes: 5 additions & 2 deletions src/store/app/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
import { AppState } from '../types';
import { safeStoredDistance } from '../../utils/localStorage';
import { AppActions } from './actions';

import { safeStoredDistance } from '../../utils/localStorage';
import { RouteActions } from '../route/actions';

const storedDistanceSettings = safeStoredDistance();

const initialState: AppState = {
Expand All @@ -11,13 +13,14 @@ const initialState: AppState = {
maximumDistance: storedDistanceSettings?.max || 50,
};

function app(state = initialState, action: AppActions): AppState {
function app(state = initialState, action: AppActions | RouteActions): AppState {
switch (action.type) {
case 'APP_OPEN_DRAWER':
return {
...state,
drawerOpened: true,
};
case 'ROUTE_RECEIVE':
case 'APP_CLOSE_DRAWER':
return {
...state,
Expand Down
4 changes: 2 additions & 2 deletions src/store/route/actions.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export interface UpdateRouteParameters {
}

export function updateRouteParameters(payload: RouteParameters) {
return (dispatch: Dispatch<routeActions>): void => {
return (dispatch: Dispatch<RouteActions>): void => {
dispatch({
type: 'ROUTE_UPDATE_PARAMETERS',
payload,
Expand All @@ -55,4 +55,4 @@ interface GenerateRun {
type: 'ROUTE_GENERATE_RUN';
}

export type routeActions = UpdateRouteParameters | GenerateRun | ReceiveRoute;
export type RouteActions = UpdateRouteParameters | GenerateRun | ReceiveRoute;
4 changes: 2 additions & 2 deletions src/store/route/reducer.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { safeStoredLocation } from '../../utils/localStorage';

import { RouteState } from '../types';
import { routeActions } from './actions';
import { RouteActions } from './actions';

const defaultRouteState: RouteState = {
location: safeStoredLocation()?.key,
Expand All @@ -10,7 +10,7 @@ const defaultRouteState: RouteState = {
},
};

function route(state: RouteState = defaultRouteState, action: routeActions): RouteState {
function route(state: RouteState = defaultRouteState, action: RouteActions): RouteState {
switch (action.type) {
case 'ROUTE_RECEIVE':
return {
Expand Down

0 comments on commit 376dc44

Please sign in to comment.