@@ -19,7 +20,7 @@ export const LogoDialog = ({ logo, setLogo }: Props) => (
Object.keys(LOGOS).map(item => (
setLogo(item)}
+ onMouseDown={() => mapSetLogo(item)}
key={item}
>
{LOGOS[item][0]}
diff --git a/src/components/panels/EditorDialog.tsx b/src/components/panels/EditorDialog.tsx
index af07059..8cfe48f 100644
--- a/src/components/panels/EditorDialog.tsx
+++ b/src/components/panels/EditorDialog.tsx
@@ -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 & {
+ 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);
-
diff --git a/src/components/panels/EditorPanel.tsx b/src/components/panels/EditorPanel.tsx
index e310053..4b4af05 100644
--- a/src/components/panels/EditorPanel.tsx
+++ b/src/components/panels/EditorPanel.tsx
@@ -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,
diff --git a/src/components/panels/TopRightPanel.tsx b/src/components/panels/TopRightPanel.tsx
index 9b70fe8..e376b77 100644
--- a/src/components/panels/TopRightPanel.tsx
+++ b/src/components/panels/TopRightPanel.tsx
@@ -45,8 +45,12 @@ const Component = ({
function mapStateToProps(state) {
const {
+ map: {
+ provider,
+ logo,
+ },
user: {
- provider, logo, markers_shown, editing
+ markers_shown, editing
},
} = state;
diff --git a/src/modules/Editor.ts b/src/modules/Editor.ts
index 50b9db3..13492f0 100644
--- a/src/modules/Editor.ts
+++ b/src/modules/Editor.ts
@@ -12,7 +12,8 @@ import {
resetSaveDialog,
setActiveSticker,
setAddress,
- setChanged, setDescription,
+ setChanged,
+ setDescription,
setDistance,
setIsEmpty, setIsRouting,
setLogo,
diff --git a/src/redux/map/actions.ts b/src/redux/map/actions.ts
index 13a8966..df2ba18 100644
--- a/src/redux/map/actions.ts
+++ b/src/redux/map/actions.ts
@@ -63,3 +63,8 @@ export const mapSetPublic = (is_public: IMapReducer['is_public']) => ({
type: MAP_ACTIONS.SET_PUBLIC,
is_public,
});
+
+export const mapSetLogo = (logo: IMapReducer['logo']) => ({
+ type: MAP_ACTIONS.SET_LOGO,
+ logo,
+});
diff --git a/src/redux/map/constants.ts b/src/redux/map/constants.ts
index 9bfb6bf..477f3a2 100644
--- a/src/redux/map/constants.ts
+++ b/src/redux/map/constants.ts
@@ -9,6 +9,7 @@ export const MAP_ACTIONS = {
SET_ADDRESS: `${P}-SET_ADDRESS`,
SET_OWNER: `${P}-SET_OWNER`,
SET_PUBLIC: `${P}-SET_PUBLIC`,
+ SET_LOGO: `${P}-SET_LOGO`,
ADD_STICKER: `${P}-ADD_STICKER`,
SET_STICKER: `${P}-SET_STICKER`,
diff --git a/src/redux/map/handlers.ts b/src/redux/map/handlers.ts
index dbfb5d7..baaa51e 100644
--- a/src/redux/map/handlers.ts
+++ b/src/redux/map/handlers.ts
@@ -11,6 +11,7 @@ import {
mapSetDescription,
mapSetOwner,
mapSetPublic,
+ mapSetLogo,
} from './actions';
const setMap = (state: IMapReducer, { map }: ReturnType): IMapReducer => ({
@@ -80,6 +81,11 @@ const setPublic = (state: IMapReducer, { is_public }: ReturnType): IMapReducer => ({
+ ...state,
+ logo,
+});
+
export const MAP_HANDLERS = {
[MAP_ACTIONS.SET_MAP]: setMap,
[MAP_ACTIONS.SET_PROVIDER]: setProvider,
@@ -92,4 +98,5 @@ export const MAP_HANDLERS = {
[MAP_ACTIONS.SET_DESCRIPTION]: setDescription,
[MAP_ACTIONS.SET_OWNER]: setOwner,
[MAP_ACTIONS.SET_PUBLIC]: setPublic,
+ [MAP_ACTIONS.SET_LOGO]: setLogo,
};
diff --git a/src/redux/map/index.ts b/src/redux/map/index.ts
index 41ecff2..e6cb1f1 100644
--- a/src/redux/map/index.ts
+++ b/src/redux/map/index.ts
@@ -3,12 +3,14 @@ import { MAP_HANDLERS } from './handlers';
import { DEFAULT_PROVIDER } from '$constants/providers';
import { IMapRoute } from './types';
import { IStickerDump } from '$modules/Sticker';
+import { DEFAULT_LOGO } from '$constants/logos';
export interface IMapReducer {
provider: string;
route: IMapRoute;
stickers: IStickerDump[];
title: string;
+ logo: string;
address: string;
description: string;
owner: { id: string };
@@ -17,6 +19,7 @@ export interface IMapReducer {
export const MAP_INITIAL_STATE: IMapReducer = {
provider: DEFAULT_PROVIDER,
+ logo: DEFAULT_LOGO,
route: [],
stickers: [],
title: '',
diff --git a/src/redux/map/sagas.ts b/src/redux/map/sagas.ts
index 6acec43..51f52a8 100644
--- a/src/redux/map/sagas.ts
+++ b/src/redux/map/sagas.ts
@@ -52,15 +52,15 @@ function* onMapClick({ latlng }: ReturnType) {
// return put(setMode(MODES.NONE));
// }
-function* setLogoSaga({ logo }: { type: string; logo: string }) {
- const { mode } = yield select(selectUser);
+// function* setLogoSaga({ logo }: { type: string; logo: string }) {
+// const { mode } = yield select(selectUser);
- yield put(setChanged(true));
+// yield put(setChanged(true));
- if (mode === MODES.LOGO) {
- yield put(setMode(MODES.NONE));
- }
-}
+// if (mode === MODES.LOGO) {
+// yield put(setMode(MODES.NONE));
+// }
+// }
export function* replaceAddressIfItsBusy(destination, original) {
if (original) {
@@ -303,10 +303,12 @@ function* setSaveSuccessSaga({
}
export function* mapSaga() {
+ // TODO: setChanged on set route, logo, provider, stickers
+
yield takeEvery(USER_ACTIONS.SET_ACTIVE_STICKER, setActiveStickerSaga); // TODO: move active sticker to maps
yield takeEvery(MAP_ACTIONS.MAP_CLICKED, onMapClick);
yield takeEvery(MAP_ACTIONS.SET_TITLE, setTitleSaga);
- yield takeEvery(USER_ACTIONS.SET_LOGO, setLogoSaga);
+ // yield takeEvery(USER_ACTIONS.SET_LOGO, setLogoSaga);
yield takeLatest(USER_ACTIONS.SEND_SAVE_REQUEST, sendSaveRequestSaga);
yield takeLatest(USER_ACTIONS.SET_SAVE_SUCCESS, setSaveSuccessSaga);
diff --git a/src/redux/user/actions.ts b/src/redux/user/actions.ts
index 3c48f15..25c72f2 100644
--- a/src/redux/user/actions.ts
+++ b/src/redux/user/actions.ts
@@ -11,12 +11,12 @@ export const setDistance = (distance: IRootState['distance']) => ({ type: USER_A
export const setChanged = (changed: IRootState['changed']) => ({ type: USER_ACTIONS.SET_CHANGED, changed });
export const setRouterPoints = routerPoints => ({ type: USER_ACTIONS.SET_ROUTER_POINTS, routerPoints });
export const setActiveSticker = activeSticker => ({ type: USER_ACTIONS.SET_ACTIVE_STICKER, activeSticker });
-export const setLogo = logo => ({ type: USER_ACTIONS.SET_LOGO, logo });
-export const setTitle = title => ({ type: USER_ACTIONS.SET_TITLE, title });
-export const setDescription = description => ({ type: USER_ACTIONS.SET_DESCRIPTION, description });
-export const setAddress = address => ({ type: USER_ACTIONS.SET_ADDRESS, address });
+// export const setLogo = logo => ({ type: USER_ACTIONS.SET_LOGO, logo });
+// export const setTitle = title => ({ type: USER_ACTIONS.SET_TITLE, title });
+// export const setDescription = description => ({ type: USER_ACTIONS.SET_DESCRIPTION, description });
+// export const setAddress = address => ({ type: USER_ACTIONS.SET_ADDRESS, address });
export const setAddressOrigin = address_origin => ({ type: USER_ACTIONS.SET_ADDRESS_ORIGIN, address_origin });
-export const setPublic = is_public => ({ type: USER_ACTIONS.SET_PUBLIC, is_public });
+// export const setPublic = is_public => ({ type: USER_ACTIONS.SET_PUBLIC, is_public });
export const setStarred = is_published => ({ type: USER_ACTIONS.SET_STARRED, is_published });
export const setSpeed = speed => ({ type: USER_ACTIONS.SET_SPEED, speed });
diff --git a/src/redux/user/handlers.ts b/src/redux/user/handlers.ts
index da2da64..1354c55 100644
--- a/src/redux/user/handlers.ts
+++ b/src/redux/user/handlers.ts
@@ -53,25 +53,25 @@ const setActiveSticker: ActionHandler =
activeSticker: activeSticker || { set: null, sticker: null }
});
-const setLogo: ActionHandler = (state, { logo }) => ({
- ...state,
- logo
-});
+// const setLogo: ActionHandler = (state, { logo }) => ({
+// ...state,
+// logo
+// });
-const setTitle: ActionHandler = (state, { title }) => ({
- ...state,
- title
-});
+// const setTitle: ActionHandler = (state, { title }) => ({
+// ...state,
+// title
+// });
-const setDescription: ActionHandler = (state, { description }) => ({
- ...state,
- description
-});
+// const setDescription: ActionHandler = (state, { description }) => ({
+// ...state,
+// description
+// });
-const setAddress: ActionHandler = (state, { address }) => ({
- ...state,
- address
-});
+// const setAddress: ActionHandler = (state, { address }) => ({
+// ...state,
+// address
+// });
const setAddressOrigin: ActionHandler = (state, { address_origin }) => ({
...state,
@@ -199,7 +199,7 @@ const searchSetLoading: ActionHandler =
}
});
-const setPublic: ActionHandler = (state, { is_public = false }) => ({ ...state, is_public });
+// const setPublic: ActionHandler = (state, { is_public = false }) => ({ ...state, is_public });
const setStarred: ActionHandler = (state, { is_published = false }) => ({ ...state, is_published });
const setSpeed: ActionHandler = (state, { speed = 15 }) => ({
@@ -254,10 +254,10 @@ export const USER_HANDLERS = ({
[USER_ACTIONS.SET_DISTANCE]: setDistance,
[USER_ACTIONS.SET_ROUTER_POINTS]: setRouterPoints,
[USER_ACTIONS.SET_ACTIVE_STICKER]: setActiveSticker,
- [USER_ACTIONS.SET_LOGO]: setLogo,
- [USER_ACTIONS.SET_TITLE]: setTitle,
- [USER_ACTIONS.SET_DESCRIPTION]: setDescription,
- [USER_ACTIONS.SET_ADDRESS]: setAddress,
+ // [USER_ACTIONS.SET_LOGO]: setLogo,
+ // [USER_ACTIONS.SET_TITLE]: setTitle,
+ // [USER_ACTIONS.SET_DESCRIPTION]: setDescription,
+ // [USER_ACTIONS.SET_ADDRESS]: setAddress,
[USER_ACTIONS.SET_ADDRESS_ORIGIN]: setAddressOrigin,
[USER_ACTIONS.SET_SAVE_ERROR]: setSaveError,
@@ -282,7 +282,7 @@ export const USER_HANDLERS = ({
[USER_ACTIONS.SEARCH_SET_TAB]: searchSetTab,
[USER_ACTIONS.SEARCH_PUT_ROUTES]: searchPutRoutes,
[USER_ACTIONS.SEARCH_SET_LOADING]: searchSetLoading,
- [USER_ACTIONS.SET_PUBLIC]: setPublic,
+ // [USER_ACTIONS.SET_PUBLIC]: setPublic,
[USER_ACTIONS.SET_STARRED]: setStarred,
[USER_ACTIONS.SET_SPEED]: setSpeed,