setting changed on actual map change

This commit is contained in:
Fedor Katurov 2020-01-14 10:47:25 +07:00
parent 34f98fb08b
commit 1a00b98ba3
3 changed files with 17 additions and 8 deletions

View file

@ -5,7 +5,6 @@ import { simplify } from '~/utils/simplify';
import {
editorHideRenderer,
editorSetChanged,
editorSetEditing,
editorSetMode,
editorSetReady,
editorSetRenderer,
@ -40,7 +39,7 @@ import {
import { selectMap, selectMapRoute } from '../map/selectors';
import { selectUser } from '../user/selectors';
import { LOGOS } from '~/constants/logos';
import { loadMapSaga, startEmptyEditorSaga, loadMapFromPath } from '../map/sagas';
import { loadMapFromPath } from '../map/sagas';
import { mapClicked, mapSetRoute } from '../map/actions';
import { MAP_ACTIONS } from '../map/constants';
import { OsrmRouter } from '~/utils/osrm';
@ -56,12 +55,10 @@ const hideLoader = () => {
};
function* stopEditingSaga() {
const { changed, editing, mode }: ReturnType<typeof selectEditor> = yield select(selectEditor);
const { changed, mode }: ReturnType<typeof selectEditor> = yield select(selectEditor);
const { address_origin }: ReturnType<typeof selectMap> = yield select(selectMap);
const { path } = getUrlData();
// if (!editing) return;
if (changed && mode !== MODES.CONFIRM_CANCEL) {
yield put(editorSetMode(MODES.CONFIRM_CANCEL));
return;

View file

@ -313,7 +313,16 @@ function* sendSaveRequestSaga({
);
}
function* setChanged() {
const { changed } = yield select(selectEditor);
if (changed) return;
yield put(editorSetChanged(true));
}
export function* mapSaga() {
yield takeEvery([MAP_ACTIONS.SET_ROUTE, MAP_ACTIONS.SET_STICKER], setChanged);
// TODO: setChanged on set route, logo, provider, stickers
yield takeEvery(EDITOR_ACTIONS.START_EDITING, startEditingSaga);
yield takeEvery(EDITOR_ACTIONS.SET_ACTIVE_STICKER, setActiveStickerSaga);