From e53ef85ae916fbf2ba8e654bb3a9a4241890dea8 Mon Sep 17 00:00:00 2001 From: muerwre Date: Wed, 12 Dec 2018 11:45:31 +0700 Subject: [PATCH] stickers: separated stickers and stickers_select modes --- src/components/panels/EditorDialog.jsx | 2 +- src/components/panels/EditorPanel.jsx | 2 +- src/constants/modes.js | 1 + src/modules/Editor.js | 19 +++++-------------- src/redux/user/sagas.js | 8 ++------ 5 files changed, 10 insertions(+), 22 deletions(-) diff --git a/src/components/panels/EditorDialog.jsx b/src/components/panels/EditorDialog.jsx index 9cc48fa..76e404b 100644 --- a/src/components/panels/EditorDialog.jsx +++ b/src/components/panels/EditorDialog.jsx @@ -37,7 +37,7 @@ type Props = { const DIALOG_CONTENTS = { [MODES.ROUTER]: RouterDialog, - [MODES.STICKERS]: StickersDialog, + [MODES.STICKERS_SELECT]: StickersDialog, [MODES.TRASH]: TrashDialog, [MODES.LOGO]: LogoDialog, [MODES.SAVE]: SaveDialog, diff --git a/src/components/panels/EditorPanel.jsx b/src/components/panels/EditorPanel.jsx index 893d14e..91db4b7 100644 --- a/src/components/panels/EditorPanel.jsx +++ b/src/components/panels/EditorPanel.jsx @@ -48,7 +48,7 @@ class Component extends React.PureComponent { } startPolyMode = () => this.props.setMode(MODES.POLY); - startStickerMode = () => this.props.setMode(MODES.STICKERS); + startStickerMode = () => this.props.setMode(MODES.STICKERS_SELECT); startRouterMode = () => this.props.setMode(MODES.ROUTER); startProviderMode = () => this.props.setMode(MODES.PROVIDER); startTrashMode = () => this.props.setMode(MODES.TRASH); diff --git a/src/constants/modes.js b/src/constants/modes.js index 585ac2c..d70bb42 100644 --- a/src/constants/modes.js +++ b/src/constants/modes.js @@ -3,6 +3,7 @@ export const MODES = ({ POLY: 'POLY', STICKERS: 'STICKERS', + STICKERS_SELECT: 'STICKERS_SELECT', ROUTER: 'ROUTER', SHOTTER: 'SHOTTER', TRASH: 'TRASH', diff --git a/src/modules/Editor.js b/src/modules/Editor.js index d3c47bd..8fc25bc 100644 --- a/src/modules/Editor.js +++ b/src/modules/Editor.js @@ -59,6 +59,9 @@ export class Editor { [MODES.STICKERS]: { toggle: this.clearSticker, }, + [MODES.STICKERS_SELECT]: { + toggle: this.clearSticker, + }, [MODES.TRASH]: { // toggle: this.clearAll, toggle: this.clearMode, @@ -143,6 +146,7 @@ export class Editor { this.stickers.createSticker({ latlng, sticker: this.activeSticker.sticker, set: this.activeSticker.set }); this.setActiveSticker(null); this.setChanged(true); + this.setMode(MODES.STICKERS_SELECT); }; changeMode = mode => { @@ -240,8 +244,6 @@ export class Editor { sticker.set && STICKERS[sticker.set].url && this.stickers.createSticker({ latlng: sticker.latlng, - // angle: parseStickerAngle({ sticker, version }), - // sticker: parseStickerStyle({ sticker, version }), angle: sticker.angle, sticker: sticker.sticker, set: sticker.set, @@ -280,27 +282,16 @@ export class Editor { }; startEditing = () => { - const { path } = getUrlData(); - const { random_url, id } = this.getUser(); + const { id } = this.getUser(); this.setInitialData(); - - // const url = (this.owner && this.owner.id === id) ? path : random_url; this.owner = { id }; - // console.log('PATH IS', path); - // pushPath(`/${url}/edit`); - if (this.poly.latlngs && this.poly.latlngs.length > 1) this.poly.poly.enableEdit(); this.stickers.startEditing(); }; stopEditing = () => { - // const { path } = getUrlData(); - - // console.log('PATH IS', path, this.initialData.path); - // pushPath(`/${(this.initialData && this.initialData.path) || path}`); - this.poly.poly.disableEdit(); this.stickers.stopEditing(); }; diff --git a/src/redux/user/sagas.js b/src/redux/user/sagas.js index 2d78310..e31473d 100644 --- a/src/redux/user/sagas.js +++ b/src/redux/user/sagas.js @@ -201,18 +201,14 @@ function* setModeSaga({ mode }) { } function* userLogoutSaga() { - const { id } = yield select(getUser); - - // if (id === editor.owner) { - // editor.owner = { id: null }; - // } - yield put(setUser(DEFAULT_USER)); yield call(generateGuestSaga); } function* setActiveStickerSaga({ activeSticker }) { yield editor.activeSticker = activeSticker; + yield put(setMode(MODES.STICKERS)); + return true; }