Display homepage when user is logged out
This commit is contained in:
parent
e003e084e5
commit
a1a427e4e0
4 changed files with 36 additions and 8 deletions
|
@ -5,7 +5,7 @@ import { Provider, connect } from 'react-redux';
|
||||||
import PropTypes from 'prop-types';
|
import PropTypes from 'prop-types';
|
||||||
import configureStore from '../store/configureStore';
|
import configureStore from '../store/configureStore';
|
||||||
import { INTRODUCTION_VERSION } from '../actions/onboarding';
|
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 { ScrollContext } from 'react-router-scroll-4';
|
||||||
import UI from '../features/ui';
|
import UI from '../features/ui';
|
||||||
import Introduction from '../features/introduction';
|
import Introduction from '../features/introduction';
|
||||||
|
@ -18,6 +18,7 @@ import ErrorBoundary from '../components/error_boundary';
|
||||||
import { fetchInstance } from 'gabsocial/actions/instance';
|
import { fetchInstance } from 'gabsocial/actions/instance';
|
||||||
import { fetchSoapboxConfig } from 'gabsocial/actions/soapbox';
|
import { fetchSoapboxConfig } from 'gabsocial/actions/soapbox';
|
||||||
import { fetchMe } from 'gabsocial/actions/me';
|
import { fetchMe } from 'gabsocial/actions/me';
|
||||||
|
import LandingPage from 'gabsocial/features/landing_page';
|
||||||
|
|
||||||
const { localeData, messages } = getLocale();
|
const { localeData, messages } = getLocale();
|
||||||
addLocaleData(localeData);
|
addLocaleData(localeData);
|
||||||
|
@ -38,6 +39,7 @@ const mapStateToProps = (state) => {
|
||||||
|
|
||||||
return {
|
return {
|
||||||
showIntroduction,
|
showIntroduction,
|
||||||
|
me,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -49,6 +51,9 @@ 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;
|
||||||
//
|
//
|
||||||
|
@ -59,7 +64,10 @@ class GabSocialMount extends React.PureComponent {
|
||||||
return (
|
return (
|
||||||
<BrowserRouter basename='/web'>
|
<BrowserRouter basename='/web'>
|
||||||
<ScrollContext>
|
<ScrollContext>
|
||||||
|
<Switch>
|
||||||
|
{!me && <Route exact path='/' component={LandingPage} />}
|
||||||
<Route path='/' component={UI} />
|
<Route path='/' component={UI} />
|
||||||
|
</Switch>
|
||||||
</ScrollContext>
|
</ScrollContext>
|
||||||
</BrowserRouter>
|
</BrowserRouter>
|
||||||
);
|
);
|
||||||
|
|
|
@ -41,7 +41,7 @@ class LoginForm extends ImmutablePureComponent {
|
||||||
|
|
||||||
render() {
|
render() {
|
||||||
const { me } = this.props;
|
const { me } = this.props;
|
||||||
if (me) return <Redirect to="/home" />;
|
if (me) return <Redirect to='/' />;
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<form onSubmit={this.handleSubmit}>
|
<form onSubmit={this.handleSubmit}>
|
||||||
|
|
18
app/gabsocial/features/landing_page/index.js
Normal file
18
app/gabsocial/features/landing_page/index.js
Normal file
|
@ -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 (
|
||||||
|
<h1>Hello world</h1>
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
export default connect(mapStateToProps)(LandingPage);
|
|
@ -189,12 +189,11 @@ class SwitchingColumnsArea extends React.PureComponent {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Switch>
|
<Switch>
|
||||||
<Redirect from='/' to='/home' exact />
|
|
||||||
{/* <WrappedRoute path='/' component={} publicRoute exact /> */}
|
{/* <WrappedRoute path='/' component={} publicRoute exact /> */}
|
||||||
<WrappedRoute path='/auth/sign_in' component={LoginForm} publicRoute exact />
|
<WrappedRoute path='/auth/sign_in' component={LoginForm} publicRoute exact />
|
||||||
{/* <WrappedRoute path='/auth/sign_out' component={LogoutForm} publicRoute exact /> */}
|
{/* <WrappedRoute path='/auth/sign_out' component={LogoutForm} publicRoute exact /> */}
|
||||||
|
|
||||||
<WrappedRoute path='/home' exact page={HomePage} component={HomeTimeline} content={children} />
|
<WrappedRoute path='/' exact page={HomePage} component={HomeTimeline} content={children} />
|
||||||
<WrappedRoute path='/timeline/local' exact page={HomePage} component={CommunityTimeline} content={children} />
|
<WrappedRoute path='/timeline/local' exact page={HomePage} component={CommunityTimeline} content={children} />
|
||||||
<WrappedRoute path='/timeline/fediverse' exact page={HomePage} component={PublicTimeline} content={children} />
|
<WrappedRoute path='/timeline/fediverse' exact page={HomePage} component={PublicTimeline} content={children} />
|
||||||
<WrappedRoute path='/messages' component={DirectTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
<WrappedRoute path='/messages' component={DirectTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
||||||
|
@ -404,9 +403,6 @@ class UI extends React.PureComponent {
|
||||||
componentDidMount () {
|
componentDidMount () {
|
||||||
const { me } = this.props;
|
const { me } = this.props;
|
||||||
if (!me) return;
|
if (!me) return;
|
||||||
this.hotkeys.__mousetrap__.stopCallback = (e, element) => {
|
|
||||||
return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName);
|
|
||||||
};
|
|
||||||
this.connectStreaming();
|
this.connectStreaming();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -480,7 +476,13 @@ class UI extends React.PureComponent {
|
||||||
}
|
}
|
||||||
|
|
||||||
setHotkeysRef = c => {
|
setHotkeysRef = c => {
|
||||||
|
const { me } = this.props;
|
||||||
this.hotkeys = c;
|
this.hotkeys = c;
|
||||||
|
|
||||||
|
if (!me) return;
|
||||||
|
this.hotkeys.__mousetrap__.stopCallback = (e, element) => {
|
||||||
|
return ['TEXTAREA', 'SELECT', 'INPUT'].includes(element.tagName);
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
handleHotkeyToggleHelp = () => {
|
handleHotkeyToggleHelp = () => {
|
||||||
|
|
Loading…
Reference in a new issue