removed unnecessary action creators

This commit is contained in:
Fedor Katurov 2019-12-30 21:16:04 +07:00
parent b75c028ce1
commit de5726929f
12 changed files with 98 additions and 89 deletions

View file

@ -2,14 +2,15 @@ import * as React from 'react';
import { LOGOS } from '$constants/logos';
import { Icon } from '$components/panels/Icon';
import classnames from 'classnames';
import { setLogo as setLogoAction } from "$redux/user/actions";
import { IRootState } from "$redux/user";
import * as MAP_ACTIONS from "$redux/map/actions"
import { IMapReducer } from '$redux/map';
interface Props extends IRootState {
setLogo: typeof setLogoAction,
interface Props {
logo: IMapReducer['logo'],
mapSetLogo: typeof MAP_ACTIONS.mapSetLogo,
}
export const LogoDialog = ({ logo, setLogo }: Props) => (
export const LogoDialog = ({ logo, mapSetLogo }: Props) => (
<div className="control-dialog top">
<div className="helper logo-helper">
<div className="helper-back">
@ -19,7 +20,7 @@ export const LogoDialog = ({ logo, setLogo }: Props) => (
Object.keys(LOGOS).map(item => (
<div
className={classnames('helper-menu-item', { active: (item === logo) })}
onMouseDown={() => setLogo(item)}
onMouseDown={() => mapSetLogo(item)}
key={item}
>
{LOGOS[item][0]}

View file

@ -11,28 +11,33 @@ import { CancelDialog } from '$components/dialogs/CancelDialog';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import {
setMode,
setLogo,
routerCancel,
routerSubmit,
setActiveSticker,
clearStickers,
clearPoly,
clearAll,
clearCancel,
stopEditing,
setEditing,
sendSaveRequest,
changeProvider,
} from '$redux/user/actions';
import * as USER_ACTIONS from '$redux/user/actions';
import { ProviderDialog } from '$components/dialogs/ProviderDialog';
import { ShotPrefetchDialog } from '$components/dialogs/ShotPrefetchDialog';
import { IRootState } from "$redux/user";
import * as MAP_ACTIONS from '$redux/map/actions';
import { selectUserMode } from '$redux/user/selectors';
interface Props extends IRootState {
width: number,
}
const mapStateToProps = state => ({ mode: selectUserMode(state) });
// const mapDispatchToProps = dispatch => bindActionCreators({
// routerCancel: USER_ACTIONS.routerCancel,
// routerSubmit: USER_ACTIONS.routerSubmit,
// setActiveSticker: USER_ACTIONS.setActiveSticker,
// clearStickers: USER_ACTIONS.clearStickers,
// clearPoly: USER_ACTIONS.clearPoly,
// clearAll: USER_ACTIONS.clearAll,
// clearCancel: USER_ACTIONS.clearCancel,
// stopEditing: USER_ACTIONS.stopEditing,
// setEditing: USER_ACTIONS.setEditing,
// setMode: USER_ACTIONS.setMode,
// sendSaveRequest: USER_ACTIONS.sendSaveRequest,
// changeProvider: USER_ACTIONS.changeProvider,
// mapSetLogo: MAP_ACTIONS.mapSetLogo,
// }, dispatch);
type Props = ReturnType<typeof mapStateToProps> & {
width: number;
};
const DIALOG_CONTENTS: { [x: string]: any } = {
[MODES.ROUTER]: RouterDialog,
@ -45,32 +50,12 @@ const DIALOG_CONTENTS: { [x: string]: any } = {
[MODES.SHOT_PREFETCH]: ShotPrefetchDialog,
};
export const Component = (props: Props) => (
export const Component = (props: Props) =>
props.mode && DIALOG_CONTENTS[props.mode]
? React.createElement(DIALOG_CONTENTS[props.mode], { ...props })
: null
);
const mapStateToProps = ({ user }) => ({ ...user });
const mapDispatchToProps = dispatch => bindActionCreators({
routerCancel,
routerSubmit,
setLogo,
setActiveSticker,
clearStickers,
clearPoly,
clearAll,
clearCancel,
stopEditing,
setEditing,
setMode,
sendSaveRequest,
changeProvider,
}, dispatch);
? React.createElement(DIALOG_CONTENTS[props.mode])
: null;
export const EditorDialog = connect(
mapStateToProps,
mapDispatchToProps
mapStateToProps
// mapDispatchToProps
)(Component);

View file

@ -6,7 +6,7 @@ import { Icon } from '$components/panels/Icon';
import { EditorDialog } from '$components/panels/EditorDialog';
import { bindActionCreators } from 'redux';
import { connect } from 'react-redux';
import { setMode, startEditing, stopEditing, setLogo, takeAShot, keyPressed } from '$redux/user/actions';
import { setMode, startEditing, stopEditing, takeAShot, keyPressed } from '$redux/user/actions';
import { IRootState } from "$redux/user";
import { Tooltip } from "$components/panels/Tooltip";
@ -159,7 +159,7 @@ function mapStateToProps(state) {
const mapDispatchToProps = dispatch => bindActionCreators({
setMode,
setLogo,
// setLogo,
startEditing,
stopEditing,
takeAShot,

View file

@ -45,8 +45,12 @@ const Component = ({
function mapStateToProps(state) {
const {
map: {
provider,
logo,
},
user: {
provider, logo, markers_shown, editing
markers_shown, editing
},
} = state;