fixed map clicks on sticker drag

This commit is contained in:
Fedor Katurov 2020-01-09 12:44:25 +07:00
parent 67eeaa7293
commit 7bdf07cae5
7 changed files with 150 additions and 141 deletions

View file

@ -9,7 +9,6 @@ import {
editorSetMode,
editorSetReady,
editorSetRenderer,
editorSetDialog,
editorSetDialogActive,
editorClearAll,
editorSetFeature,
@ -172,40 +171,25 @@ function* cropAShotSaga(params) {
}
function* locationChangeSaga({ location }: ReturnType<typeof editorLocationChanged>) {
const {
user: { id, random_url },
}: ReturnType<typeof selectUser> = yield select(selectUser);
const { ready }: ReturnType<typeof selectEditor> = yield select(selectEditor);
const { owner, address }: ReturnType<typeof selectMap> = yield select(selectMap);
const { address }: ReturnType<typeof selectMap> = yield select(selectMap);
if (!ready) return;
const { path, mode } = getUrlData(location);
if (address !== path) {
const map = yield call(loadMapSaga, path);
if (map && map.route && map.route.owner && mode === 'edit' && map.route.owner !== id) {
return yield call(replaceAddressIfItsBusy, map.random_url, map.address);
}
} else if (mode === 'edit' && owner.id !== id) {
return yield call(replaceAddressIfItsBusy, random_url, address);
} else {
yield put(mapSetAddressOrigin(''));
yield call(loadMapSaga, path);
}
if (mode !== 'edit') {
yield put(editorSetEditing(false));
// editor.stopEditing();
} else {
yield put(editorSetEditing(true));
// editor.startEditing();
}
}
function* keyPressedSaga({ key, target }: ReturnType<typeof editorKeyPressed>): any {
function* keyPressedSaga({ key, target }: ReturnType<typeof editorKeyPressed>) {
if (target === 'INPUT' || target === 'TEXTAREA') {
return;
}
@ -237,7 +221,6 @@ function* keyPressedSaga({ key, target }: ReturnType<typeof editorKeyPressed>):
function* getGPXTrackSaga(): SagaIterator {
const { route, stickers, title, address }: ReturnType<typeof selectMap> = yield select(selectMap);
// const { title, address }: = yield select(selectUser);
if (!route || route.length <= 0) return;
@ -246,6 +229,11 @@ function* getGPXTrackSaga(): SagaIterator {
return downloadGPXTrack({ track, title });
}
function* routerCancel() {
yield put(editorSetMode(MODES.NONE))
// TODO: clear router
}
export function* editorSaga() {
yield takeEvery(EDITOR_ACTIONS.STOP_EDITING, stopEditingSaga);
yield takeLatest(EDITOR_ACTIONS.TAKE_A_SHOT, takeAShotSaga);
@ -253,4 +241,5 @@ export function* editorSaga() {
yield takeLatest(EDITOR_ACTIONS.LOCATION_CHANGED, locationChangeSaga);
yield takeLatest(EDITOR_ACTIONS.KEY_PRESSED, keyPressedSaga);
yield takeLatest(EDITOR_ACTIONS.GET_GPX_TRACK, getGPXTrackSaga);
yield takeLatest(EDITOR_ACTIONS.ROUTER_CANCEL, routerCancel);
}