mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-24 18:46:40 +07:00
setting changed on actual map change
This commit is contained in:
parent
34f98fb08b
commit
1a00b98ba3
3 changed files with 17 additions and 8 deletions
|
@ -13,13 +13,15 @@ import { Stickers } from '~/containers/map/Stickers';
|
|||
import { KmMarks } from '~/containers/map/KmMarks';
|
||||
|
||||
import 'leaflet/dist/leaflet.css';
|
||||
import { selectEditorEditing } from '~/redux/editor/selectors';
|
||||
import { selectEditorEditing, selectEditorMode } from '~/redux/editor/selectors';
|
||||
import { MODES } from '~/constants/modes';
|
||||
|
||||
const mapStateToProps = state => ({
|
||||
provider: selectMapProvider(state),
|
||||
route: selectMapRoute(state),
|
||||
stickers: selectMapStickers(state),
|
||||
editing: selectEditorEditing(state),
|
||||
mode: selectEditorMode(state),
|
||||
});
|
||||
|
||||
const mapDispatchToProps = {
|
||||
|
@ -37,6 +39,7 @@ const MapUnconnected: React.FC<IProps> = ({
|
|||
provider,
|
||||
stickers,
|
||||
editing,
|
||||
mode,
|
||||
|
||||
mapClicked,
|
||||
mapSetSticker,
|
||||
|
@ -44,11 +47,11 @@ const MapUnconnected: React.FC<IProps> = ({
|
|||
}) => {
|
||||
const onClick = React.useCallback(
|
||||
event => {
|
||||
if (!MainMap.clickable) return;
|
||||
if (!MainMap.clickable || mode === MODES.NONE) return;
|
||||
|
||||
mapClicked(event.latlng);
|
||||
},
|
||||
[mapClicked]
|
||||
[mapClicked, mode]
|
||||
);
|
||||
|
||||
React.useEffect(() => {
|
||||
|
|
|
@ -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;
|
||||
|
|
|
@ -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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue