diff --git a/app/soapbox/containers/soapbox.tsx b/app/soapbox/containers/soapbox.tsx index 66541e8ed..c7f2f3c87 100644 --- a/app/soapbox/containers/soapbox.tsx +++ b/app/soapbox/containers/soapbox.tsx @@ -22,6 +22,7 @@ import WaitlistPage from 'soapbox/features/verification/waitlist_page'; import { createGlobals } from 'soapbox/globals'; import { useAppSelector, useAppDispatch, useOwnAccount, useFeatures, useSoapboxConfig, useSettings, useSystemTheme } from 'soapbox/hooks'; import MESSAGES from 'soapbox/locales/messages'; +import { useCachedLocationHandler } from 'soapbox/utils/redirect'; import { generateThemeCss } from 'soapbox/utils/theme'; import { checkOnboardingStatus } from '../actions/onboarding'; @@ -64,6 +65,7 @@ const loadInitial = () => { }; const SoapboxMount = () => { + useCachedLocationHandler(); const dispatch = useAppDispatch(); const me = useAppSelector(state => state.me); diff --git a/app/soapbox/features/auth_layout/index.tsx b/app/soapbox/features/auth_layout/index.tsx index f96904580..1ac59b3de 100644 --- a/app/soapbox/features/auth_layout/index.tsx +++ b/app/soapbox/features/auth_layout/index.tsx @@ -1,13 +1,14 @@ import React from 'react'; -import { Link, Redirect, Route, Switch } from 'react-router-dom'; +import { defineMessages, useIntl } from 'react-intl'; +import { Link, Redirect, Route, Switch, useHistory } from 'react-router-dom'; import LandingGradient from 'soapbox/components/landing-gradient'; import SiteLogo from 'soapbox/components/site-logo'; import BundleContainer from 'soapbox/features/ui/containers/bundle_container'; import { NotificationsContainer } from 'soapbox/features/ui/util/async-components'; -import { useAppSelector } from 'soapbox/hooks'; +import { useAppSelector, useFeatures, useSoapboxConfig } from 'soapbox/hooks'; -import { Card, CardBody } from '../../components/ui'; +import { Button, Card, CardBody } from '../../components/ui'; import LoginPage from '../auth_login/components/login_page'; import PasswordReset from '../auth_login/components/password_reset'; import PasswordResetConfirm from '../auth_login/components/password_reset_confirm'; @@ -17,22 +18,52 @@ import RegisterInvite from '../register_invite'; import Verification from '../verification'; import EmailPassthru from '../verification/email_passthru'; +const messages = defineMessages({ + register: { id: 'auth_layout.register', defaultMessage: 'Create an account' }, +}); + const AuthLayout = () => { + const intl = useIntl(); + const history = useHistory(); + const siteTitle = useAppSelector(state => state.instance.title); + const soapboxConfig = useSoapboxConfig(); + const pepeEnabled = soapboxConfig.getIn(['extensions', 'pepe', 'enabled']) === true; + + const features = useFeatures(); + const instance = useAppSelector((state) => state.instance); + const isOpen = features.accountCreation && instance.registrations; + const pepeOpen = useAppSelector(state => state.verification.getIn(['instance', 'registrations'], false) === true); + const isLoginPage = history.location.pathname === '/login'; + const shouldShowRegisterLink = (isLoginPage && (isOpen || (pepeEnabled && pepeOpen))); return (