mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
removed console.log
This commit is contained in:
parent
205af22aa7
commit
430b39e977
1 changed files with 54 additions and 32 deletions
|
@ -1,36 +1,46 @@
|
||||||
import { createStore, applyMiddleware, combineReducers, compose, Store } from 'redux';
|
import {
|
||||||
|
createStore,
|
||||||
|
applyMiddleware,
|
||||||
|
combineReducers,
|
||||||
|
compose,
|
||||||
|
Store
|
||||||
|
} from "redux";
|
||||||
|
|
||||||
import { persistStore, persistReducer } from 'redux-persist';
|
import { persistStore, persistReducer } from "redux-persist";
|
||||||
import storage from 'redux-persist/lib/storage';
|
import storage from "redux-persist/lib/storage";
|
||||||
import createSagaMiddleware from 'redux-saga';
|
import createSagaMiddleware from "redux-saga";
|
||||||
import { connectRouter, RouterState, routerMiddleware } from 'connected-react-router';
|
import {
|
||||||
import { createBrowserHistory } from 'history';
|
connectRouter,
|
||||||
import { PersistConfig, Persistor } from 'redux-persist/es/types';
|
RouterState,
|
||||||
|
routerMiddleware
|
||||||
|
} from "connected-react-router";
|
||||||
|
import { createBrowserHistory } from "history";
|
||||||
|
import { PersistConfig, Persistor } from "redux-persist/es/types";
|
||||||
|
|
||||||
import authReducer from '~/redux/auth/reducer';
|
import authReducer from "~/redux/auth/reducer";
|
||||||
import authSaga from '~/redux/auth/sagas';
|
import authSaga from "~/redux/auth/sagas";
|
||||||
|
|
||||||
import nodeReducer, { INodeState } from '~/redux/node/reducer';
|
import nodeReducer, { INodeState } from "~/redux/node/reducer";
|
||||||
import nodeSaga from '~/redux/node/sagas';
|
import nodeSaga from "~/redux/node/sagas";
|
||||||
|
|
||||||
import flowReducer, { IFlowState } from '~/redux/flow/reducer';
|
import flowReducer, { IFlowState } from "~/redux/flow/reducer";
|
||||||
import flowSaga from '~/redux/flow/sagas';
|
import flowSaga from "~/redux/flow/sagas";
|
||||||
|
|
||||||
import uploadReducer, { IUploadState } from '~/redux/uploads/reducer';
|
import uploadReducer, { IUploadState } from "~/redux/uploads/reducer";
|
||||||
import uploadSaga from '~/redux/uploads/sagas';
|
import uploadSaga from "~/redux/uploads/sagas";
|
||||||
|
|
||||||
import playerReducer, { IPlayerState } from '~/redux/player/reducer';
|
import playerReducer, { IPlayerState } from "~/redux/player/reducer";
|
||||||
import playerSaga from '~/redux/player/sagas';
|
import playerSaga from "~/redux/player/sagas";
|
||||||
|
|
||||||
import { IAuthState } from '~/redux/auth/types';
|
import { IAuthState } from "~/redux/auth/types";
|
||||||
|
|
||||||
import modalReducer, { IModalState } from '~/redux/modal/reducer';
|
import modalReducer, { IModalState } from "~/redux/modal/reducer";
|
||||||
import { gotAuthPostMessage, authOpenProfile } from './auth/actions';
|
import { gotAuthPostMessage, authOpenProfile } from "./auth/actions";
|
||||||
|
|
||||||
const authPersistConfig: PersistConfig = {
|
const authPersistConfig: PersistConfig = {
|
||||||
key: 'auth',
|
key: "auth",
|
||||||
whitelist: ['token', 'user', 'updates'],
|
whitelist: ["token", "user", "updates"],
|
||||||
storage,
|
storage
|
||||||
};
|
};
|
||||||
|
|
||||||
export interface IState {
|
export interface IState {
|
||||||
|
@ -47,16 +57,15 @@ export const sagaMiddleware = createSagaMiddleware();
|
||||||
export const history = createBrowserHistory();
|
export const history = createBrowserHistory();
|
||||||
|
|
||||||
history.listen(({ pathname }) => {
|
history.listen(({ pathname }) => {
|
||||||
console.log({ pathname });
|
|
||||||
|
|
||||||
if (pathname.match(/~([\wа-яА-Я]+)/)) {
|
if (pathname.match(/~([\wа-яА-Я]+)/)) {
|
||||||
const [, username] = pathname.match(/~([\wа-яА-Я]+)/);
|
const [, username] = pathname.match(/~([\wа-яА-Я]+)/);
|
||||||
window.postMessage({ type: 'username', username }, '*');
|
window.postMessage({ type: "username", username }, "*");
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
const composeEnhancers =
|
const composeEnhancers =
|
||||||
typeof window === 'object' && (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
typeof window === "object" &&
|
||||||
|
(<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||||
? (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
? (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
||||||
: compose;
|
: compose;
|
||||||
|
|
||||||
|
@ -68,23 +77,36 @@ export const store = createStore(
|
||||||
node: nodeReducer,
|
node: nodeReducer,
|
||||||
uploads: uploadReducer,
|
uploads: uploadReducer,
|
||||||
flow: flowReducer,
|
flow: flowReducer,
|
||||||
player: playerReducer,
|
player: playerReducer
|
||||||
}),
|
}),
|
||||||
composeEnhancers(applyMiddleware(routerMiddleware(history), sagaMiddleware))
|
composeEnhancers(applyMiddleware(routerMiddleware(history), sagaMiddleware))
|
||||||
);
|
);
|
||||||
|
|
||||||
export function configureStore(): { store: Store<IState>; persistor: Persistor } {
|
export function configureStore(): {
|
||||||
|
store: Store<IState>;
|
||||||
|
persistor: Persistor;
|
||||||
|
} {
|
||||||
sagaMiddleware.run(authSaga);
|
sagaMiddleware.run(authSaga);
|
||||||
sagaMiddleware.run(nodeSaga);
|
sagaMiddleware.run(nodeSaga);
|
||||||
sagaMiddleware.run(uploadSaga);
|
sagaMiddleware.run(uploadSaga);
|
||||||
sagaMiddleware.run(flowSaga);
|
sagaMiddleware.run(flowSaga);
|
||||||
sagaMiddleware.run(playerSaga);
|
sagaMiddleware.run(playerSaga);
|
||||||
|
|
||||||
window.addEventListener('message', message => {
|
window.addEventListener("message", message => {
|
||||||
if (message && message.data && message.data.type === 'oauth_login' && message.data.token)
|
if (
|
||||||
|
message &&
|
||||||
|
message.data &&
|
||||||
|
message.data.type === "oauth_login" &&
|
||||||
|
message.data.token
|
||||||
|
)
|
||||||
return store.dispatch(gotAuthPostMessage({ token: message.data.token }));
|
return store.dispatch(gotAuthPostMessage({ token: message.data.token }));
|
||||||
|
|
||||||
if (message && message.data && message.data.type === 'username' && message.data.username)
|
if (
|
||||||
|
message &&
|
||||||
|
message.data &&
|
||||||
|
message.data.type === "username" &&
|
||||||
|
message.data.username
|
||||||
|
)
|
||||||
return store.dispatch(authOpenProfile(message.data.username));
|
return store.dispatch(authOpenProfile(message.data.username));
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue