save: public switch

This commit is contained in:
muerwre 2018-12-18 14:45:45 +07:00
parent 69f23c9e48
commit b7f2c7c382
10 changed files with 31 additions and 27 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 setPublic = is_public => ({ type: ACTIONS.SET_PUBLIC, is_public });
export const startEditing = () => ({ type: ACTIONS.START_EDITING });
export const stopEditing = () => ({ type: ACTIONS.STOP_EDITING });

View file

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

View file

@ -152,6 +152,11 @@ const searchSetLoading = (state, { loading = false }) => ({
}
});
const setPublic = (state, { is_public = false }) => ({
...state,
is_public,
});
const HANDLERS = ({
[ACTIONS.SET_USER]: setUser,
[ACTIONS.SET_EDITING]: setEditing,
@ -185,6 +190,7 @@ const HANDLERS = ({
[ACTIONS.SEARCH_SET_TAB]: searchSetTab,
[ACTIONS.SEARCH_PUT_ROUTES]: searchPutRoutes,
[ACTIONS.SEARCH_SET_LOADING]: searchSetLoading,
[ACTIONS.SET_PUBLIC]: setPublic,
}: { [key: String]: Function });
export const INITIAL_STATE = {
@ -201,6 +207,7 @@ export const INITIAL_STATE = {
address: '',
changed: false,
provider: DEFAULT_PROVIDER,
is_public: false,
save_error: '',
save_finished: false,

View file

@ -257,7 +257,7 @@ function* clearSaga({ type }) {
yield put(setMode(MODES.NONE));
}
function* sendSaveRequestSaga({ title, address, force }) {
function* sendSaveRequestSaga({ title, address, force, is_public }) {
if (editor.isEmpty) return yield put(setSaveError(TIPS.SAVE_EMPTY));
const { route, stickers, provider } = editor.dumpData();
@ -266,7 +266,7 @@ function* sendSaveRequestSaga({ title, address, force }) {
const { result, timeout, cancel } = yield race({
result: postMap({
id, token, route, stickers, title, force, address, logo, distance, provider,
id, token, route, stickers, title, force, address, logo, distance, provider, is_public
}),
timeout: delay(10000),
cancel: take(ACTIONS.RESET_SAVE_DIALOG),
@ -280,12 +280,12 @@ function* sendSaveRequestSaga({ title, address, force }) {
return yield put(setSaveSuccess({ address: result.address, save_error: TIPS.SAVE_SUCCESS, title }));
}
function* refreshUserData() {
const user = yield select(getUser);
const data = yield call(checkUserToken, user);
return yield put(setUser(data));
}
// function* refreshUserData() {
// const user = yield select(getUser);
// const data = yield call(checkUserToken, user);
//
// return yield put(setUser(data));
// }
function* getRenderData() {
yield put(setRenderer({ info: 'Загрузка тайлов', progress: 0.1 }));