From cbf799d53f500932c780a4071fe08fa1b2c59adf Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Thu, 2 Apr 2020 14:28:19 -0500 Subject: [PATCH] Fix (!me) logic --- app/gabsocial/containers/gabsocial.js | 3 +++ app/gabsocial/features/ui/util/react_router_helpers.js | 2 +- app/gabsocial/reducers/me.js | 6 ++++-- 3 files changed, 8 insertions(+), 3 deletions(-) diff --git a/app/gabsocial/containers/gabsocial.js b/app/gabsocial/containers/gabsocial.js index 424295956..9029f4dd6 100644 --- a/app/gabsocial/containers/gabsocial.js +++ b/app/gabsocial/containers/gabsocial.js @@ -39,6 +39,7 @@ const mapStateToProps = (state) => { return { showIntroduction, + me, } } @@ -50,6 +51,8 @@ class GabSocialMount extends React.PureComponent { }; render () { + const { me } = this.props; + if (me == null) return null; // Disabling introduction for launch // const { showIntroduction } = this.props; // diff --git a/app/gabsocial/features/ui/util/react_router_helpers.js b/app/gabsocial/features/ui/util/react_router_helpers.js index 9ee8d28f0..284cc38d2 100644 --- a/app/gabsocial/features/ui/util/react_router_helpers.js +++ b/app/gabsocial/features/ui/util/react_router_helpers.js @@ -72,7 +72,7 @@ class WrappedRoute extends React.Component { render () { const { component: Component, content, publicRoute, me, ...rest } = this.props; - if (!publicRoute && !me) { + if (!publicRoute && me == false) { const actualUrl = encodeURIComponent(this.props.computedMatch.url); return { window.location.href = `/auth/sign_in?redirect_uri=${actualUrl}`; diff --git a/app/gabsocial/reducers/me.js b/app/gabsocial/reducers/me.js index b1a101418..649b0db40 100644 --- a/app/gabsocial/reducers/me.js +++ b/app/gabsocial/reducers/me.js @@ -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'; -const initialState = ImmutableMap(); +const initialState = null; export default function me(state = initialState, action) { switch(action.type) { case ME_FETCH_SUCCESS: return fromJS(action.me.id); + case ME_FETCH_FAIL: + return false; default: return state; }