From a1a427e4e0cdc975d2296f08635658b35ff1dc74 Mon Sep 17 00:00:00 2001 From: Alex Gleason Date: Wed, 8 Apr 2020 18:38:22 -0500 Subject: [PATCH] Display homepage when user is logged out --- app/gabsocial/containers/gabsocial.js | 12 ++++++++++-- app/gabsocial/features/auth_login/index.js | 2 +- app/gabsocial/features/landing_page/index.js | 18 ++++++++++++++++++ app/gabsocial/features/ui/index.js | 12 +++++++----- 4 files changed, 36 insertions(+), 8 deletions(-) create mode 100644 app/gabsocial/features/landing_page/index.js diff --git a/app/gabsocial/containers/gabsocial.js b/app/gabsocial/containers/gabsocial.js index 3e8066d3e..c64767813 100644 --- a/app/gabsocial/containers/gabsocial.js +++ b/app/gabsocial/containers/gabsocial.js @@ -5,7 +5,7 @@ import { Provider, connect } from 'react-redux'; import PropTypes from 'prop-types'; import configureStore from '../store/configureStore'; import { INTRODUCTION_VERSION } from '../actions/onboarding'; -import { BrowserRouter, Route } from 'react-router-dom'; +import { Switch, BrowserRouter, Route } from 'react-router-dom'; import { ScrollContext } from 'react-router-scroll-4'; import UI from '../features/ui'; import Introduction from '../features/introduction'; @@ -18,6 +18,7 @@ import ErrorBoundary from '../components/error_boundary'; import { fetchInstance } from 'gabsocial/actions/instance'; import { fetchSoapboxConfig } from 'gabsocial/actions/soapbox'; import { fetchMe } from 'gabsocial/actions/me'; +import LandingPage from 'gabsocial/features/landing_page'; const { localeData, messages } = getLocale(); addLocaleData(localeData); @@ -38,6 +39,7 @@ const mapStateToProps = (state) => { return { showIntroduction, + me, } } @@ -49,6 +51,9 @@ class GabSocialMount extends React.PureComponent { }; render () { + const { me } = this.props; + if (me == null) return null; + // Disabling introduction for launch // const { showIntroduction } = this.props; // @@ -59,7 +64,10 @@ class GabSocialMount extends React.PureComponent { return ( - + + {!me && } + + ); diff --git a/app/gabsocial/features/auth_login/index.js b/app/gabsocial/features/auth_login/index.js index d2ea0a60e..6a846b2ce 100644 --- a/app/gabsocial/features/auth_login/index.js +++ b/app/gabsocial/features/auth_login/index.js @@ -41,7 +41,7 @@ class LoginForm extends ImmutablePureComponent { render() { const { me } = this.props; - if (me) return ; + if (me) return ; return (
diff --git a/app/gabsocial/features/landing_page/index.js b/app/gabsocial/features/landing_page/index.js new file mode 100644 index 000000000..1aa4298c8 --- /dev/null +++ b/app/gabsocial/features/landing_page/index.js @@ -0,0 +1,18 @@ +import React from 'react'; +import { connect } from 'react-redux' +import ImmutablePureComponent from 'react-immutable-pure-component'; + +const mapStateToProps = (state, props) => ({ + me: state.get('me'), +}); + +class LandingPage extends ImmutablePureComponent { + + render() { + return ( +

Hello world

+ ) + } +} + +export default connect(mapStateToProps)(LandingPage); diff --git a/app/gabsocial/features/ui/index.js b/app/gabsocial/features/ui/index.js index ea3410bb4..48c9edd5d 100644 --- a/app/gabsocial/features/ui/index.js +++ b/app/gabsocial/features/ui/index.js @@ -189,12 +189,11 @@ class SwitchingColumnsArea extends React.PureComponent { return ( - {/* */} {/* */} - + @@ -404,9 +403,6 @@ class UI extends React.PureComponent { componentDidMount () { const { me } = this.props; if (!me) return; - this.hotkeys.__mousetrap__.stopCallback = (e, element) => { - return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName); - }; this.connectStreaming(); } @@ -480,7 +476,13 @@ class UI extends React.PureComponent { } setHotkeysRef = c => { + const { me } = this.props; this.hotkeys = c; + + if (!me) return; + this.hotkeys.__mousetrap__.stopCallback = (e, element) => { + return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName); + }; } handleHotkeyToggleHelp = () => {