mirror of
https://github.com/muerwre/orchidmap-front.git
synced 2025-04-25 11:06:40 +07:00
cleanup
This commit is contained in:
parent
cb07aa9fb0
commit
8adf64acb9
6 changed files with 94 additions and 355 deletions
|
@ -50,19 +50,14 @@ import {
|
|||
import { USER_ACTIONS } from '~/redux/user/constants';
|
||||
import { DEFAULT_USER } from '~/constants/auth';
|
||||
|
||||
import { DIALOGS, TABS } from '~/constants/dialogs';
|
||||
import { DIALOGS } from '~/constants/dialogs';
|
||||
|
||||
import * as ActionCreators from '~/redux/user/actions';
|
||||
import { Unwrap } from '~/utils/middleware';
|
||||
import { IState } from '~/redux/store';
|
||||
import { selectUser, selectUserUser } from './selectors';
|
||||
import { mapInitSaga, loadMapSaga, replaceAddressIfItsBusy } from '~/redux/map/sagas';
|
||||
import { mapInitSaga } from '~/redux/map/sagas';
|
||||
import { editorSetDialog, editorSetDialogActive } from '../editor/actions';
|
||||
import { selectEditor } from '../editor/selectors';
|
||||
import { EDITOR_ACTIONS } from '../editor/constants';
|
||||
|
||||
// const getUser = (state: IState) => state.user.user;
|
||||
// const selectUser = (state: IState) => state.user;
|
||||
|
||||
function* generateGuestSaga() {
|
||||
const {
|
||||
|
@ -74,36 +69,6 @@ function* generateGuestSaga() {
|
|||
return { ...user, random_url };
|
||||
}
|
||||
|
||||
// function* stopEditingSaga() {
|
||||
// const { changed, editing, mode, address_origin } = yield select(selectUser);
|
||||
// const { path } = getUrlData();
|
||||
|
||||
// if (!editing) return;
|
||||
// if (changed && mode !== MODES.CONFIRM_CANCEL) {
|
||||
// yield put(setMode(MODES.CONFIRM_CANCEL));
|
||||
// return;
|
||||
// }
|
||||
|
||||
// yield put(setMode(MODES.NONE));
|
||||
// yield put(setChanged(false));
|
||||
|
||||
// yield pushPath(`/${address_origin || path}/`);
|
||||
// }
|
||||
|
||||
// function* checkOSRMServiceSaga() {
|
||||
// const routing = yield call(checkOSRMService, [new LatLng(1,1), new LatLng(2,2)]);
|
||||
|
||||
// yield put(setFeature({ routing }));
|
||||
// }
|
||||
|
||||
// export function* setReadySaga() {
|
||||
// yield put(setReady(true));
|
||||
// hideLoader();
|
||||
|
||||
// yield call(checkOSRMServiceSaga);
|
||||
// yield put(searchSetTab(TABS.MY));
|
||||
// }
|
||||
|
||||
function* authCheckSaga({ key }: RehydrateAction) {
|
||||
if (key !== 'user') return;
|
||||
|
||||
|
@ -155,158 +120,6 @@ function* authCheckSaga({ key }: RehydrateAction) {
|
|||
return yield call(mapInitSaga);
|
||||
}
|
||||
|
||||
// function* setModeSaga({ mode }: ReturnType<typeof ActionCreators.setMode>) {
|
||||
// return yield editor.changeMode(mode);
|
||||
// console.log('change', mode);
|
||||
// }
|
||||
|
||||
// function* setLogoSaga({ logo }: { type: string; logo: string }) {
|
||||
// const { mode } = yield select(selectUser);
|
||||
// editor.logo = logo;
|
||||
|
||||
// yield put(setChanged(true));
|
||||
|
||||
// if (mode === MODES.LOGO) {
|
||||
// yield put(setMode(MODES.NONE));
|
||||
// }
|
||||
// }
|
||||
|
||||
// function* routerCancelSaga() {
|
||||
// yield call(editor.router.cancelDrawing);
|
||||
// yield put(setMode(MODES.NONE));
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// function* routerSubmitSaga() {
|
||||
// yield call(editor.router.submitDrawing);
|
||||
// yield put(setMode(MODES.NONE));
|
||||
|
||||
// return true;
|
||||
// }
|
||||
|
||||
// function* getRenderData() {
|
||||
// yield put(setRenderer({ info: 'Загрузка тайлов', progress: 0.1 }));
|
||||
|
||||
// const { route, stickers, provider }: ReturnType<typeof selectMap> = yield select(selectMap);
|
||||
|
||||
// const canvas = <HTMLCanvasElement>document.getElementById('renderer');
|
||||
// canvas.width = window.innerWidth;
|
||||
// canvas.height = window.innerHeight;
|
||||
// const ctx = canvas.getContext('2d');
|
||||
|
||||
// const geometry = getTilePlacement();
|
||||
// const points = getPolyPlacement(route);
|
||||
// const sticker_points = getStickersPlacement(stickers);
|
||||
// // TODO: get distance:
|
||||
// const distance = 0;
|
||||
// // const distance = editor.poly.poly.distance;
|
||||
|
||||
// ctx.clearRect(0, 0, canvas.width, canvas.height);
|
||||
|
||||
// const images = yield fetchImages(ctx, geometry, provider);
|
||||
|
||||
// yield put(setRenderer({ info: 'Отрисовка', progress: 0.5 }));
|
||||
|
||||
// yield composeImages({ geometry, images, ctx });
|
||||
// yield composePoly({ points, ctx });
|
||||
// yield composeArrows({ points, ctx });
|
||||
// yield composeDistMark({ ctx, points, distance });
|
||||
// yield composeStickers({ stickers: sticker_points, ctx });
|
||||
|
||||
// yield put(setRenderer({ info: 'Готово', progress: 1 }));
|
||||
|
||||
// return yield canvas.toDataURL('image/jpeg');
|
||||
// }
|
||||
|
||||
// function* takeAShotSaga() {
|
||||
// const worker = call(getRenderData);
|
||||
|
||||
// const { result, timeout } = yield race({
|
||||
// result: worker,
|
||||
// timeout: delay(500),
|
||||
// });
|
||||
|
||||
// if (timeout) yield put(setMode(MODES.SHOT_PREFETCH));
|
||||
|
||||
// const data = yield result || worker;
|
||||
|
||||
// yield put(setMode(MODES.NONE));
|
||||
// yield put(
|
||||
// setRenderer({
|
||||
// data,
|
||||
// renderer_active: true,
|
||||
// width: window.innerWidth,
|
||||
// height: window.innerHeight,
|
||||
// })
|
||||
// );
|
||||
// }
|
||||
|
||||
// function* getCropData({ x, y, width, height }) {
|
||||
// const {
|
||||
// logo,
|
||||
// renderer: { data },
|
||||
// } = yield select(selectUser);
|
||||
// const canvas = <HTMLCanvasElement>document.getElementById('renderer');
|
||||
// canvas.width = width;
|
||||
// canvas.height = height;
|
||||
// const ctx = canvas.getContext('2d');
|
||||
// const image = yield imageFetcher(data);
|
||||
|
||||
// ctx.drawImage(image, -x, -y);
|
||||
|
||||
// if (logo && LOGOS[logo][1]) {
|
||||
// const logoImage = yield imageFetcher(LOGOS[logo][1]);
|
||||
// ctx.drawImage(logoImage, width - logoImage.width, height - logoImage.height);
|
||||
// }
|
||||
|
||||
// return yield canvas.toDataURL('image/jpeg');
|
||||
// }
|
||||
|
||||
// function* cropAShotSaga(params) {
|
||||
// const { title, address } = yield select(selectUser);
|
||||
// yield call(getCropData, params);
|
||||
// const canvas = document.getElementById('renderer') as HTMLCanvasElement;
|
||||
|
||||
// downloadCanvas(canvas, (title || address).replace(/\./gi, ' '));
|
||||
|
||||
// return yield put(hideRenderer());
|
||||
// }
|
||||
|
||||
// function* locationChangeSaga({ location }: ReturnType<typeof ActionCreators.locationChanged>) {
|
||||
// const {
|
||||
// address,
|
||||
// ready,
|
||||
// user: { id, random_url },
|
||||
// } = yield select(selectUser);
|
||||
|
||||
// const { owner }: 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(setAddressOrigin(''));
|
||||
// }
|
||||
|
||||
// if (mode !== 'edit') {
|
||||
// yield put(setEditing(false));
|
||||
// // editor.stopEditing();
|
||||
// } else {
|
||||
// yield put(setEditing(true));
|
||||
// // editor.startEditing();
|
||||
// }
|
||||
// }
|
||||
|
||||
function* gotVkUserSaga({ user: u }: ReturnType<typeof ActionCreators.gotVkUser>) {
|
||||
const {
|
||||
data: { user, random_url },
|
||||
|
@ -315,38 +128,6 @@ function* gotVkUserSaga({ user: u }: ReturnType<typeof ActionCreators.gotVkUser>
|
|||
yield put(setUser({ ...user, random_url }));
|
||||
}
|
||||
|
||||
// function* keyPressedSaga({ key, target }: ReturnType<typeof ActionCreators.keyPressed>): any {
|
||||
// if (target === 'INPUT' || target === 'TEXTAREA') {
|
||||
// return;
|
||||
// }
|
||||
|
||||
// if (key === 'Escape') {
|
||||
// const {
|
||||
// dialog_active,
|
||||
// mode,
|
||||
// renderer: { renderer_active },
|
||||
// } = yield select(selectUser);
|
||||
|
||||
// if (renderer_active) return yield put(hideRenderer());
|
||||
// if (dialog_active) return yield put(setDialogActive(false));
|
||||
// if (mode !== MODES.NONE) return yield put(setMode(MODES.NONE));
|
||||
// } else if (key === 'Delete') {
|
||||
// const {
|
||||
// user: { editing },
|
||||
// } = yield select();
|
||||
|
||||
// if (!editing) return;
|
||||
|
||||
// const { mode } = yield select(selectUser);
|
||||
|
||||
// if (mode === MODES.TRASH) {
|
||||
// yield put(clearAll());
|
||||
// } else {
|
||||
// yield put(setMode(MODES.TRASH));
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
function* searchGetRoutes() {
|
||||
const { token }: ReturnType<typeof selectUserUser> = yield select(selectUserUser);
|
||||
|
||||
|
@ -425,7 +206,6 @@ function* openMapDialogSaga({ tab }: ReturnType<typeof ActionCreators.openMapDia
|
|||
}
|
||||
|
||||
if (tab !== current) {
|
||||
// if tab wasnt changed just update data
|
||||
yield put(searchSetTab(tab));
|
||||
}
|
||||
|
||||
|
@ -455,17 +235,6 @@ function* setUserSaga() {
|
|||
return true;
|
||||
}
|
||||
|
||||
// function* getGPXTrackSaga(): SagaIterator {
|
||||
// const { route, stickers }: ReturnType<typeof selectMap> = yield select(selectMap);
|
||||
// const { title, address } = yield select(selectUser);
|
||||
|
||||
// if (!route || route.length <= 0) return;
|
||||
|
||||
// const track = getGPXString({ route, stickers, title: title || address });
|
||||
|
||||
// return downloadGPXTrack({ track, title });
|
||||
// }
|
||||
|
||||
function* mapsLoadMoreSaga() {
|
||||
const {
|
||||
routes: { limit, list, shift, step, loading, filter },
|
||||
|
@ -596,27 +365,11 @@ function* toggleRouteStarredSaga({
|
|||
}
|
||||
|
||||
export function* userSaga() {
|
||||
// yield takeEvery(USER_ACTIONS.STOP_EDITING, stopEditingSaga);
|
||||
// yield takeLatest(USER_ACTIONS.TAKE_A_SHOT, takeAShotSaga);
|
||||
// yield takeLatest(USER_ACTIONS.CROP_A_SHOT, cropAShotSaga);
|
||||
// yield takeLatest(USER_ACTIONS.LOCATION_CHANGED, locationChangeSaga);
|
||||
// yield takeLatest(USER_ACTIONS.KEY_PRESSED, keyPressedSaga);
|
||||
// yield takeLatest(USER_ACTIONS.GET_GPX_TRACK, getGPXTrackSaga);
|
||||
|
||||
yield takeLatest(REHYDRATE, authCheckSaga);
|
||||
|
||||
yield takeEvery(USER_ACTIONS.USER_LOGOUT, userLogoutSaga);
|
||||
|
||||
// yield takeEvery(USER_ACTIONS.ROUTER_CANCEL, routerCancelSaga);
|
||||
// yield takeEvery(USER_ACTIONS.ROUTER_SUBMIT, routerSubmitSaga);
|
||||
|
||||
|
||||
// yield takeEvery(USER_ACTIONS.CHANGE_PROVIDER, changeProviderSaga);
|
||||
|
||||
yield takeLatest(USER_ACTIONS.GOT_VK_USER, gotVkUserSaga);
|
||||
|
||||
// yield takeLatest(USER_ACTIONS.SET_TITLE, setTitleSaga);
|
||||
|
||||
yield takeLatest(
|
||||
[USER_ACTIONS.SEARCH_SET_TITLE, USER_ACTIONS.SEARCH_SET_DISTANCE],
|
||||
searchSetSaga
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue