mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
removed unnecessary action creators
This commit is contained in:
parent
b75c028ce1
commit
de5726929f
12 changed files with 98 additions and 89 deletions
|
@ -63,3 +63,8 @@ export const mapSetPublic = (is_public: IMapReducer['is_public']) => ({
|
|||
type: MAP_ACTIONS.SET_PUBLIC,
|
||||
is_public,
|
||||
});
|
||||
|
||||
export const mapSetLogo = (logo: IMapReducer['logo']) => ({
|
||||
type: MAP_ACTIONS.SET_LOGO,
|
||||
logo,
|
||||
});
|
||||
|
|
|
@ -9,6 +9,7 @@ export const MAP_ACTIONS = {
|
|||
SET_ADDRESS: `${P}-SET_ADDRESS`,
|
||||
SET_OWNER: `${P}-SET_OWNER`,
|
||||
SET_PUBLIC: `${P}-SET_PUBLIC`,
|
||||
SET_LOGO: `${P}-SET_LOGO`,
|
||||
|
||||
ADD_STICKER: `${P}-ADD_STICKER`,
|
||||
SET_STICKER: `${P}-SET_STICKER`,
|
||||
|
|
|
@ -11,6 +11,7 @@ import {
|
|||
mapSetDescription,
|
||||
mapSetOwner,
|
||||
mapSetPublic,
|
||||
mapSetLogo,
|
||||
} from './actions';
|
||||
|
||||
const setMap = (state: IMapReducer, { map }: ReturnType<typeof mapSet>): IMapReducer => ({
|
||||
|
@ -80,6 +81,11 @@ const setPublic = (state: IMapReducer, { is_public }: ReturnType<typeof mapSetPu
|
|||
is_public,
|
||||
});
|
||||
|
||||
const setLogo = (state: IMapReducer, { logo }: ReturnType<typeof mapSetLogo>): IMapReducer => ({
|
||||
...state,
|
||||
logo,
|
||||
});
|
||||
|
||||
export const MAP_HANDLERS = {
|
||||
[MAP_ACTIONS.SET_MAP]: setMap,
|
||||
[MAP_ACTIONS.SET_PROVIDER]: setProvider,
|
||||
|
@ -92,4 +98,5 @@ export const MAP_HANDLERS = {
|
|||
[MAP_ACTIONS.SET_DESCRIPTION]: setDescription,
|
||||
[MAP_ACTIONS.SET_OWNER]: setOwner,
|
||||
[MAP_ACTIONS.SET_PUBLIC]: setPublic,
|
||||
[MAP_ACTIONS.SET_LOGO]: setLogo,
|
||||
};
|
||||
|
|
|
@ -3,12 +3,14 @@ import { MAP_HANDLERS } from './handlers';
|
|||
import { DEFAULT_PROVIDER } from '$constants/providers';
|
||||
import { IMapRoute } from './types';
|
||||
import { IStickerDump } from '$modules/Sticker';
|
||||
import { DEFAULT_LOGO } from '$constants/logos';
|
||||
|
||||
export interface IMapReducer {
|
||||
provider: string;
|
||||
route: IMapRoute;
|
||||
stickers: IStickerDump[];
|
||||
title: string;
|
||||
logo: string;
|
||||
address: string;
|
||||
description: string;
|
||||
owner: { id: string };
|
||||
|
@ -17,6 +19,7 @@ export interface IMapReducer {
|
|||
|
||||
export const MAP_INITIAL_STATE: IMapReducer = {
|
||||
provider: DEFAULT_PROVIDER,
|
||||
logo: DEFAULT_LOGO,
|
||||
route: [],
|
||||
stickers: [],
|
||||
title: '',
|
||||
|
|
|
@ -52,15 +52,15 @@ function* onMapClick({ latlng }: ReturnType<typeof mapClicked>) {
|
|||
// return put(setMode(MODES.NONE));
|
||||
// }
|
||||
|
||||
function* setLogoSaga({ logo }: { type: string; logo: string }) {
|
||||
const { mode } = yield select(selectUser);
|
||||
// function* setLogoSaga({ logo }: { type: string; logo: string }) {
|
||||
// const { mode } = yield select(selectUser);
|
||||
|
||||
yield put(setChanged(true));
|
||||
// yield put(setChanged(true));
|
||||
|
||||
if (mode === MODES.LOGO) {
|
||||
yield put(setMode(MODES.NONE));
|
||||
}
|
||||
}
|
||||
// if (mode === MODES.LOGO) {
|
||||
// yield put(setMode(MODES.NONE));
|
||||
// }
|
||||
// }
|
||||
|
||||
export function* replaceAddressIfItsBusy(destination, original) {
|
||||
if (original) {
|
||||
|
@ -303,10 +303,12 @@ function* setSaveSuccessSaga({
|
|||
}
|
||||
|
||||
export function* mapSaga() {
|
||||
// TODO: setChanged on set route, logo, provider, stickers
|
||||
|
||||
yield takeEvery(USER_ACTIONS.SET_ACTIVE_STICKER, setActiveStickerSaga); // TODO: move active sticker to maps
|
||||
yield takeEvery(MAP_ACTIONS.MAP_CLICKED, onMapClick);
|
||||
yield takeEvery(MAP_ACTIONS.SET_TITLE, setTitleSaga);
|
||||
yield takeEvery(USER_ACTIONS.SET_LOGO, setLogoSaga);
|
||||
// yield takeEvery(USER_ACTIONS.SET_LOGO, setLogoSaga);
|
||||
yield takeLatest(USER_ACTIONS.SEND_SAVE_REQUEST, sendSaveRequestSaga);
|
||||
yield takeLatest(USER_ACTIONS.SET_SAVE_SUCCESS, setSaveSuccessSaga);
|
||||
|
||||
|
|
|
@ -11,12 +11,12 @@ export const setDistance = (distance: IRootState['distance']) => ({ type: USER_A
|
|||
export const setChanged = (changed: IRootState['changed']) => ({ type: USER_ACTIONS.SET_CHANGED, changed });
|
||||
export const setRouterPoints = routerPoints => ({ type: USER_ACTIONS.SET_ROUTER_POINTS, routerPoints });
|
||||
export const setActiveSticker = activeSticker => ({ type: USER_ACTIONS.SET_ACTIVE_STICKER, activeSticker });
|
||||
export const setLogo = logo => ({ type: USER_ACTIONS.SET_LOGO, logo });
|
||||
export const setTitle = title => ({ type: USER_ACTIONS.SET_TITLE, title });
|
||||
export const setDescription = description => ({ type: USER_ACTIONS.SET_DESCRIPTION, description });
|
||||
export const setAddress = address => ({ type: USER_ACTIONS.SET_ADDRESS, address });
|
||||
// export const setLogo = logo => ({ type: USER_ACTIONS.SET_LOGO, logo });
|
||||
// export const setTitle = title => ({ type: USER_ACTIONS.SET_TITLE, title });
|
||||
// export const setDescription = description => ({ type: USER_ACTIONS.SET_DESCRIPTION, description });
|
||||
// export const setAddress = address => ({ type: USER_ACTIONS.SET_ADDRESS, address });
|
||||
export const setAddressOrigin = address_origin => ({ type: USER_ACTIONS.SET_ADDRESS_ORIGIN, address_origin });
|
||||
export const setPublic = is_public => ({ type: USER_ACTIONS.SET_PUBLIC, is_public });
|
||||
// export const setPublic = is_public => ({ type: USER_ACTIONS.SET_PUBLIC, is_public });
|
||||
export const setStarred = is_published => ({ type: USER_ACTIONS.SET_STARRED, is_published });
|
||||
export const setSpeed = speed => ({ type: USER_ACTIONS.SET_SPEED, speed });
|
||||
|
||||
|
|
|
@ -53,25 +53,25 @@ const setActiveSticker: ActionHandler<typeof ActionCreators.setActiveSticker> =
|
|||
activeSticker: activeSticker || { set: null, sticker: null }
|
||||
});
|
||||
|
||||
const setLogo: ActionHandler<typeof ActionCreators.setLogo> = (state, { logo }) => ({
|
||||
...state,
|
||||
logo
|
||||
});
|
||||
// const setLogo: ActionHandler<typeof ActionCreators.setLogo> = (state, { logo }) => ({
|
||||
// ...state,
|
||||
// logo
|
||||
// });
|
||||
|
||||
const setTitle: ActionHandler<typeof ActionCreators.setTitle> = (state, { title }) => ({
|
||||
...state,
|
||||
title
|
||||
});
|
||||
// const setTitle: ActionHandler<typeof ActionCreators.setTitle> = (state, { title }) => ({
|
||||
// ...state,
|
||||
// title
|
||||
// });
|
||||
|
||||
const setDescription: ActionHandler<typeof ActionCreators.setDescription> = (state, { description }) => ({
|
||||
...state,
|
||||
description
|
||||
});
|
||||
// const setDescription: ActionHandler<typeof ActionCreators.setDescription> = (state, { description }) => ({
|
||||
// ...state,
|
||||
// description
|
||||
// });
|
||||
|
||||
const setAddress: ActionHandler<typeof ActionCreators.setAddress> = (state, { address }) => ({
|
||||
...state,
|
||||
address
|
||||
});
|
||||
// const setAddress: ActionHandler<typeof ActionCreators.setAddress> = (state, { address }) => ({
|
||||
// ...state,
|
||||
// address
|
||||
// });
|
||||
|
||||
const setAddressOrigin: ActionHandler<typeof ActionCreators.setAddressOrigin> = (state, { address_origin }) => ({
|
||||
...state,
|
||||
|
@ -199,7 +199,7 @@ const searchSetLoading: ActionHandler<typeof ActionCreators.searchSetLoading> =
|
|||
}
|
||||
});
|
||||
|
||||
const setPublic: ActionHandler<typeof ActionCreators.setPublic> = (state, { is_public = false }) => ({ ...state, is_public });
|
||||
// const setPublic: ActionHandler<typeof ActionCreators.setPublic> = (state, { is_public = false }) => ({ ...state, is_public });
|
||||
const setStarred: ActionHandler<typeof ActionCreators.setStarred> = (state, { is_published = false }) => ({ ...state, is_published });
|
||||
|
||||
const setSpeed: ActionHandler<typeof ActionCreators.setSpeed> = (state, { speed = 15 }) => ({
|
||||
|
@ -254,10 +254,10 @@ export const USER_HANDLERS = ({
|
|||
[USER_ACTIONS.SET_DISTANCE]: setDistance,
|
||||
[USER_ACTIONS.SET_ROUTER_POINTS]: setRouterPoints,
|
||||
[USER_ACTIONS.SET_ACTIVE_STICKER]: setActiveSticker,
|
||||
[USER_ACTIONS.SET_LOGO]: setLogo,
|
||||
[USER_ACTIONS.SET_TITLE]: setTitle,
|
||||
[USER_ACTIONS.SET_DESCRIPTION]: setDescription,
|
||||
[USER_ACTIONS.SET_ADDRESS]: setAddress,
|
||||
// [USER_ACTIONS.SET_LOGO]: setLogo,
|
||||
// [USER_ACTIONS.SET_TITLE]: setTitle,
|
||||
// [USER_ACTIONS.SET_DESCRIPTION]: setDescription,
|
||||
// [USER_ACTIONS.SET_ADDRESS]: setAddress,
|
||||
[USER_ACTIONS.SET_ADDRESS_ORIGIN]: setAddressOrigin,
|
||||
|
||||
[USER_ACTIONS.SET_SAVE_ERROR]: setSaveError,
|
||||
|
@ -282,7 +282,7 @@ export const USER_HANDLERS = ({
|
|||
[USER_ACTIONS.SEARCH_SET_TAB]: searchSetTab,
|
||||
[USER_ACTIONS.SEARCH_PUT_ROUTES]: searchPutRoutes,
|
||||
[USER_ACTIONS.SEARCH_SET_LOADING]: searchSetLoading,
|
||||
[USER_ACTIONS.SET_PUBLIC]: setPublic,
|
||||
// [USER_ACTIONS.SET_PUBLIC]: setPublic,
|
||||
[USER_ACTIONS.SET_STARRED]: setStarred,
|
||||
[USER_ACTIONS.SET_SPEED]: setSpeed,
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue