possibly fixed routing?

This commit is contained in:
muerwre 2019-02-07 14:41:44 +07:00
parent 1b720fd40e
commit d46236672d
4 changed files with 21 additions and 6 deletions

View file

@ -13,6 +13,7 @@ export const setActiveSticker = activeSticker => ({ type: ACTIONS.SET_ACTIVE_STI
export const setLogo = logo => ({ type: ACTIONS.SET_LOGO, logo });
export const setTitle = title => ({ type: ACTIONS.SET_TITLE, title });
export const setAddress = address => ({ type: ACTIONS.SET_ADDRESS, address });
export const setAddressOrigin = address_origin => ({ type: ACTIONS.SET_ADDRESS_ORIGIN, address_origin });
export const setPublic = is_public => ({ type: ACTIONS.SET_PUBLIC, is_public });
export const setSpeed = speed => ({ type: ACTIONS.SET_SPEED, speed });

View file

@ -13,6 +13,7 @@ export const ACTIONS = ({
SET_LOGO: 'SET_LOGO',
SET_TITLE: 'SET_TITLE',
SET_ADDRESS: 'SET_ADDRESS',
SET_ADDRESS_ORIGIN: 'SET_ADDRESS_ORIGIN',
SET_PUBLIC: 'SET_PUBLIC',
START_EDITING: 'START_EDITING',

View file

@ -39,6 +39,7 @@ const setActiveSticker = (state, { activeSticker }) => ({
const setLogo = (state, { logo }) => ({ ...state, logo });
const setTitle = (state, { title }) => ({ ...state, title });
const setAddress = (state, { address }) => ({ ...state, address });
const setAddressOrigin = (state, { address_origin }) => ({ ...state, address_origin });
const sendSaveRequest = state => ({ ...state, save_processing: true, });
const setSaveError = (state, { save_error }) => ({
@ -169,6 +170,7 @@ const HANDLERS = ({
[ACTIONS.SET_LOGO]: setLogo,
[ACTIONS.SET_TITLE]: setTitle,
[ACTIONS.SET_ADDRESS]: setAddress,
[ACTIONS.SET_ADDRESS_ORIGIN]: setAddressOrigin,
[ACTIONS.SET_SAVE_ERROR]: setSaveError,
[ACTIONS.SET_SAVE_OVERWRITE]: setSaveOverwrite,
@ -208,6 +210,7 @@ export const INITIAL_STATE = {
activeSticker: { set: null, sticker: null },
title: '',
address: '',
address_origin: '',
changed: false,
provider: DEFAULT_PROVIDER,
is_public: false,

View file

@ -17,7 +17,7 @@ import {
setSaveError,
setSaveOverwrite, setSaveSuccess, setTitle,
searchSetTab,
setUser, setDialog, setPublic,
setUser, setDialog, setPublic, setAddressOrigin,
} from '$redux/user/actions';
import { getUrlData, parseQuery, pushLoaderState, pushNetworkInitError, pushPath, replacePath } from '$utils/history';
import { editor } from '$modules/Editor';
@ -77,7 +77,9 @@ function* startEditingSaga() {
}
function* stopEditingSaga() {
const { changed, editing, mode } = yield select(getState);
const {
changed, editing, mode, address_origin
} = yield select(getState);
const { path } = getUrlData();
if (!editing) return;
@ -91,7 +93,7 @@ function* stopEditingSaga() {
yield put(setChanged(false));
yield put(setEditing(editor.hasEmptyHistory)); // don't close editor if no previous map
yield pushPath(`/${path}/`);
yield pushPath(`/${(address_origin || path)}/`);
}
function* loadMapSaga(path) {
@ -115,6 +117,10 @@ function* iframeLoginVkSaga({ viewer_id, access_token, auth_key }) {
function* replaceAddressIfItsBusy(destination, original) {
if (original) {
yield put(setAddressOrigin(original));
}
pushPath(`/${destination}/edit`);
}
@ -139,7 +145,9 @@ function* mapInitSaga() {
if (mode && mode === 'edit') {
if (map && map.owner && mode === 'edit' && map.owner.id !== id) {
hideLoader();
yield call(replaceAddressIfItsBusy, map.random_url);
yield call(replaceAddressIfItsBusy, map.random_url, map.address);
} else {
yield put(setAddressOrigin(''));
}
yield put(setEditing(true));
@ -396,11 +404,13 @@ function* locationChangeSaga({ location }) {
if (map && map.owner && mode === 'edit' && map.owner.id !== id) {
// pushPath(`/${map.random_url}/edit`);
return yield call(replaceAddressIfItsBusy, map.random_url);
return yield call(replaceAddressIfItsBusy, map.random_url, map.address);
}
} else if (mode === 'edit' && editor.owner.id !== id) {
// pushPath(`/${random_url}/edit`);
return yield call(replaceAddressIfItsBusy, random_url);
return yield call(replaceAddressIfItsBusy, random_url, address);
} else {
yield put(setAddressOrigin(''));
}
if (mode !== 'edit') {