adding stickers on click

This commit is contained in:
Fedor Katurov 2019-12-30 17:35:37 +07:00
parent e0048d1fc3
commit 6db2809de5
11 changed files with 83 additions and 20 deletions

40
src/redux/map/sagas.ts Normal file
View file

@ -0,0 +1,40 @@
import { takeEvery, select, put } from "redux-saga/effects";
import { MAP_ACTIONS } from "./constants";
import { mapClicked, mapSet } from "./actions";
import { selectUserMode, selectUserActiveSticker } from "$redux/user/selectors";
import { IRootReducer } from "$redux/user";
import { MODES } from "$constants/modes";
import { selectMapStickers } from "./selectors";
import { setActiveSticker, setMode } from "$redux/user/actions";
function* onMapClick({ latlng }: ReturnType<typeof mapClicked>) {
const mode = yield select(selectUserMode);
const { set, sticker } = yield select(selectUserActiveSticker);
const stickers = yield select(selectMapStickers);
switch (mode) {
case MODES.STICKERS:
yield put(
mapSet({
stickers: [
...stickers,
{
latlng,
set,
sticker,
text: "",
angle: 0,
}
]
})
);
yield put(setMode(MODES.NONE))
break;
default:
}
}
export function* mapSaga() {
yield takeEvery(MAP_ACTIONS.MAP_CLICKED, onMapClick);
}