mirror of
https://github.com/muerwre/vault-frontend.git
synced 2025-04-25 12:56:41 +07:00
added initial profile dialog
This commit is contained in:
parent
f6baedc4cd
commit
618c2e3275
28 changed files with 315 additions and 58 deletions
|
@ -25,7 +25,7 @@ import playerSaga from '~/redux/player/sagas';
|
|||
import { IAuthState } from '~/redux/auth/types';
|
||||
|
||||
import modalReducer, { IModalState } from '~/redux/modal/reducer';
|
||||
import { gotPostMessage } from './auth/actions';
|
||||
import { gotAuthPostMessage, authOpenProfile } from './auth/actions';
|
||||
|
||||
const authPersistConfig: PersistConfig = {
|
||||
key: 'auth',
|
||||
|
@ -46,6 +46,13 @@ export interface IState {
|
|||
export const sagaMiddleware = createSagaMiddleware();
|
||||
export const history = createBrowserHistory();
|
||||
|
||||
history.listen(({ pathname }) => {
|
||||
if (pathname.match(/~([\wа-яА-Я]+)/)) {
|
||||
const [, username] = pathname.match(/~([\wа-яА-Я]+)/);
|
||||
window.postMessage({ type: 'username', username }, '*');
|
||||
}
|
||||
});
|
||||
|
||||
const composeEnhancers =
|
||||
typeof window === 'object' && (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__
|
||||
? (<any>window).__REDUX_DEVTOOLS_EXTENSION_COMPOSE__({})
|
||||
|
@ -72,9 +79,11 @@ export function configureStore(): { store: Store<IState>; persistor: Persistor }
|
|||
sagaMiddleware.run(playerSaga);
|
||||
|
||||
window.addEventListener('message', message => {
|
||||
if (!message || !message.data || message.data.type !== 'oauth_login' || !message.data.token)
|
||||
return;
|
||||
store.dispatch(gotPostMessage({ token: message.data.token }));
|
||||
if (message && message.data && message.data.type === 'oauth_login' && message.data.token)
|
||||
return store.dispatch(gotAuthPostMessage({ token: message.data.token }));
|
||||
|
||||
if (message && message.data && message.data.type === 'username' && message.data.username)
|
||||
return store.dispatch(authOpenProfile(message.data.username));
|
||||
});
|
||||
|
||||
const persistor = persistStore(store);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue