Fix (!me) logic
This commit is contained in:
parent
d3952925d7
commit
cbf799d53f
3 changed files with 8 additions and 3 deletions
|
@ -39,6 +39,7 @@ const mapStateToProps = (state) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
showIntroduction,
|
showIntroduction,
|
||||||
|
me,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,6 +51,8 @@ class GabSocialMount extends React.PureComponent {
|
||||||
};
|
};
|
||||||
|
|
||||||
render () {
|
render () {
|
||||||
|
const { me } = this.props;
|
||||||
|
if (me == null) return null;
|
||||||
// Disabling introduction for launch
|
// Disabling introduction for launch
|
||||||
// const { showIntroduction } = this.props;
|
// const { showIntroduction } = this.props;
|
||||||
//
|
//
|
||||||
|
|
|
@ -72,7 +72,7 @@ class WrappedRoute extends React.Component {
|
||||||
render () {
|
render () {
|
||||||
const { component: Component, content, publicRoute, me, ...rest } = this.props;
|
const { component: Component, content, publicRoute, me, ...rest } = this.props;
|
||||||
|
|
||||||
if (!publicRoute && !me) {
|
if (!publicRoute && me == false) {
|
||||||
const actualUrl = encodeURIComponent(this.props.computedMatch.url);
|
const actualUrl = encodeURIComponent(this.props.computedMatch.url);
|
||||||
return <Route path={this.props.path} component={() => {
|
return <Route path={this.props.path} component={() => {
|
||||||
window.location.href = `/auth/sign_in?redirect_uri=${actualUrl}`;
|
window.location.href = `/auth/sign_in?redirect_uri=${actualUrl}`;
|
||||||
|
|
|
@ -1,12 +1,14 @@
|
||||||
import { ME_FETCH_SUCCESS } from '../actions/me';
|
import { ME_FETCH_SUCCESS, ME_FETCH_FAIL } from '../actions/me';
|
||||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||||
|
|
||||||
const initialState = ImmutableMap();
|
const initialState = null;
|
||||||
|
|
||||||
export default function me(state = initialState, action) {
|
export default function me(state = initialState, action) {
|
||||||
switch(action.type) {
|
switch(action.type) {
|
||||||
case ME_FETCH_SUCCESS:
|
case ME_FETCH_SUCCESS:
|
||||||
return fromJS(action.me.id);
|
return fromJS(action.me.id);
|
||||||
|
case ME_FETCH_FAIL:
|
||||||
|
return false;
|
||||||
default:
|
default:
|
||||||
return state;
|
return state;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue