From 5d14a753f7b775d4cce6ce5c94f113a99472ed52 Mon Sep 17 00:00:00 2001 From: muerwre Date: Mon, 26 Nov 2018 17:40:49 +0700 Subject: [PATCH] redux: fixed bugs --- src/components/save/CancelDialog.jsx | 8 ++++---- src/index.html | 6 ++++++ src/index.js | 1 - src/modules/Editor.js | 13 +------------ src/modules/Stickers.js | 4 ++-- src/redux/user/sagas.js | 19 +++++++------------ 6 files changed, 20 insertions(+), 31 deletions(-) diff --git a/src/components/save/CancelDialog.jsx b/src/components/save/CancelDialog.jsx index 1f54151..613945f 100644 --- a/src/components/save/CancelDialog.jsx +++ b/src/components/save/CancelDialog.jsx @@ -11,10 +11,10 @@ type Props = { export class CancelDialog extends React.Component { cancel = () => { - editor.cancelEditing(); - // this.props.stopEditing(); - this.props.setEditing(false); - this.props.setMode(MODES.NONE); + this.props.stopEditing(); + // editor.cancelEditing(); + // this.props.setEditing(false); + // this.props.setMode(MODES.NONE); }; proceed = () => { diff --git a/src/index.html b/src/index.html index 458c14f..33c5525 100644 --- a/src/index.html +++ b/src/index.html @@ -20,6 +20,12 @@ z-index: 10; transition: opacity 1s; } + + body { + overflow: hidden; + padding: 0; + margin: 0; + } diff --git a/src/index.js b/src/index.js index 5f071a7..3017bf0 100644 --- a/src/index.js +++ b/src/index.js @@ -1,7 +1,6 @@ import React from 'react'; import ReactDOM from 'react-dom'; - import { App } from '$containers/App'; import '$styles/main.less'; diff --git a/src/modules/Editor.js b/src/modules/Editor.js index 34e0b7b..2c882c5 100644 --- a/src/modules/Editor.js +++ b/src/modules/Editor.js @@ -244,7 +244,6 @@ export class Editor { }; startEditing = () => { - console.log('ED START'); const { path } = getUrlData(); const { random_url, id } = this.getUser(); @@ -257,13 +256,9 @@ export class Editor { if (this.poly.latlngs && this.poly.latlngs.length > 1) this.poly.poly.enableEdit(); this.stickers.startEditing(); - - // this.setEditing(true); - // console.log(this.initialData); }; stopEditing = () => { - console.log('ED STOP'); const { path } = getUrlData(); pushPath(`/${(this.initialData && this.initialData.path) || path}`); @@ -274,20 +269,14 @@ export class Editor { }; cancelEditing = () => { - this.stopEditing(); - - console.log('trying to set initial data'); - if (this.hasEmptyHistory()) { - console.log('empty history'); this.clearAll(); this.startEditing(); } else { - console.log('setting initial'); this.setData(this.initialData); - console.log('setting initial - done'); } + this.stopEditing(); this.clearChanged(); return true; diff --git a/src/modules/Stickers.js b/src/modules/Stickers.js index 49142cc..2a916c3 100644 --- a/src/modules/Stickers.js +++ b/src/modules/Stickers.js @@ -57,9 +57,9 @@ export class Stickers { startEditing = () => { this.stickers.map(sticker => sticker.startEditing()); - } + }; stopEditing = () => { this.stickers.map(sticker => sticker.stopEditing()); - } + }; } diff --git a/src/redux/user/sagas.js b/src/redux/user/sagas.js index 5d7a15a..edb0468 100644 --- a/src/redux/user/sagas.js +++ b/src/redux/user/sagas.js @@ -48,16 +48,14 @@ function* stopEditingSaga() { const { changed, editing, mode } = yield select(getState); if (!editing) return; - - if (!changed) { - yield editor.cancelEditing(); - yield put(setEditing(false)); - yield put(setMode(MODES.NONE)); - } else { - // editor.changeMode(MODES.CONFIRM_CANCEL); - // this.props.setMode(MODES.CONFIRM_CANCEL); + if (changed && mode !== MODES.CONFIRM_CANCEL) { yield put(setMode(MODES.CONFIRM_CANCEL)); + return; } + + yield editor.cancelEditing(); + yield put(setEditing(false)); + yield put(setMode(MODES.NONE)); } function* mapInitSaga() { @@ -67,8 +65,6 @@ function* mapInitSaga() { const map = yield call(getStoredMap, { name: path }); if (map) { - console.log('setting!', map, mode); - yield editor.setData(map); yield put(setChanged(false)); @@ -77,10 +73,9 @@ function* mapInitSaga() { // yield put(setEditing(true)); // editor.startEditing(); } else { - console.log('stopping edit'); yield put(setEditing(false)); // yield call(stopEditingSaga); - // editor.stopEditing(); + editor.stopEditing(); } return hideLoader();