sforkowany z mirror/soapbox
Display homepage when user is logged out
rodzic
e003e084e5
commit
a1a427e4e0
|
@ -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 (
|
||||
<BrowserRouter basename='/web'>
|
||||
<ScrollContext>
|
||||
<Route path='/' component={UI} />
|
||||
<Switch>
|
||||
{!me && <Route exact path='/' component={LandingPage} />}
|
||||
<Route path='/' component={UI} />
|
||||
</Switch>
|
||||
</ScrollContext>
|
||||
</BrowserRouter>
|
||||
);
|
||||
|
|
|
@ -41,7 +41,7 @@ class LoginForm extends ImmutablePureComponent {
|
|||
|
||||
render() {
|
||||
const { me } = this.props;
|
||||
if (me) return <Redirect to="/home" />;
|
||||
if (me) return <Redirect to='/' />;
|
||||
|
||||
return (
|
||||
<form onSubmit={this.handleSubmit}>
|
||||
|
|
|
@ -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 (
|
||||
<Switch>
|
||||
<Redirect from='/' to='/home' exact />
|
||||
{/* <WrappedRoute path='/' component={} publicRoute exact /> */}
|
||||
<WrappedRoute path='/auth/sign_in' component={LoginForm} 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/fediverse' exact page={HomePage} component={PublicTimeline} content={children} />
|
||||
<WrappedRoute path='/messages' component={DirectTimeline} content={children} componentParams={{ shouldUpdateScroll: this.shouldUpdateScroll }} />
|
||||
|
@ -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 = () => {
|
||||
|
|
Ładowanie…
Reference in New Issue