mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
riding speed slider
This commit is contained in:
parent
3e16ad4e37
commit
c3ed100105
7 changed files with 91 additions and 19 deletions
|
@ -11,7 +11,7 @@ import { locationChanged } from '$redux/user/actions';
|
|||
|
||||
const userPersistConfig = {
|
||||
key: 'user',
|
||||
whitelist: ['user', 'logo', 'provider'],
|
||||
whitelist: ['user', 'logo', 'provider', 'speed'],
|
||||
storage,
|
||||
};
|
||||
|
||||
|
|
|
@ -14,6 +14,7 @@ export const setLogo = logo => ({ type: ACTIONS.SET_LOGO, logo });
|
|||
export const setTitle = title => ({ type: ACTIONS.SET_TITLE, title });
|
||||
export const setAddress = address => ({ type: ACTIONS.SET_ADDRESS, address });
|
||||
export const setPublic = is_public => ({ type: ACTIONS.SET_PUBLIC, is_public });
|
||||
export const setSpeed = speed => ({ type: ACTIONS.SET_SPEED, speed });
|
||||
|
||||
export const startEditing = () => ({ type: ACTIONS.START_EDITING });
|
||||
export const stopEditing = () => ({ type: ACTIONS.STOP_EDITING });
|
||||
|
|
|
@ -60,4 +60,5 @@ export const ACTIONS = ({
|
|||
SEARCH_SET_LOADING: 'SEARCH_SET_LOADING',
|
||||
|
||||
OPEN_MAP_DIALOG: 'OPEN_MAP_DIALOG',
|
||||
SET_SPEED: 'SET_SPEED',
|
||||
}: { [key: String]: String });
|
||||
|
|
|
@ -8,8 +8,8 @@ import { TIPS } from '$constants/tips';
|
|||
import { DEFAULT_PROVIDER } from '$constants/providers';
|
||||
import { DIALOGS, TABS } from '$constants/dialogs';
|
||||
|
||||
const getEstimated = distance => {
|
||||
const time = (distance && (distance / 15)) || 0;
|
||||
const getEstimated = (distance, speed = 15) => {
|
||||
const time = (distance && (distance / speed)) || 0;
|
||||
return (time && parseFloat(time.toFixed(1)));
|
||||
};
|
||||
|
||||
|
@ -27,7 +27,7 @@ const setMode = (state, { mode }) => ({ ...state, mode });
|
|||
const setDistance = (state, { distance }) => ({
|
||||
...state,
|
||||
distance,
|
||||
estimated: getEstimated(distance),
|
||||
estimated: getEstimated(distance, state.speed),
|
||||
});
|
||||
|
||||
const setRouterPoints = (state, { routerPoints }) => ({ ...state, routerPoints });
|
||||
|
@ -152,9 +152,11 @@ const searchSetLoading = (state, { loading = false }) => ({
|
|||
}
|
||||
});
|
||||
|
||||
const setPublic = (state, { is_public = false }) => ({
|
||||
const setPublic = (state, { is_public = false }) => ({ ...state, is_public });
|
||||
const setSpeed = (state, { speed = 15 }) => ({
|
||||
...state,
|
||||
is_public,
|
||||
speed,
|
||||
estimated: getEstimated(state.distance, speed),
|
||||
});
|
||||
|
||||
const HANDLERS = ({
|
||||
|
@ -191,6 +193,7 @@ const HANDLERS = ({
|
|||
[ACTIONS.SEARCH_PUT_ROUTES]: searchPutRoutes,
|
||||
[ACTIONS.SEARCH_SET_LOADING]: searchSetLoading,
|
||||
[ACTIONS.SET_PUBLIC]: setPublic,
|
||||
[ACTIONS.SET_SPEED]: setSpeed,
|
||||
}: { [key: String]: Function });
|
||||
|
||||
export const INITIAL_STATE = {
|
||||
|
@ -202,6 +205,7 @@ export const INITIAL_STATE = {
|
|||
routerPoints: 0,
|
||||
distance: 0,
|
||||
estimated: 0,
|
||||
speed: 15,
|
||||
activeSticker: { set: null, sticker: null },
|
||||
title: '',
|
||||
address: '',
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue