Merge branch 'nuke-mobile-pages' into 'develop'

Delete "mobile" pages

See merge request soapbox-pub/soapbox!1837
environments/review-develop-3zknud/deployments/1157
Alex Gleason 2022-10-14 16:55:15 +00:00
commit 526fabcf21
5 zmienionych plików z 0 dodań i 139 usunięć

Wyświetl plik

@ -1,27 +0,0 @@
import { staticClient } from '../api';
import type { AppDispatch } from 'soapbox/store';
const FETCH_MOBILE_PAGE_REQUEST = 'FETCH_MOBILE_PAGE_REQUEST';
const FETCH_MOBILE_PAGE_SUCCESS = 'FETCH_MOBILE_PAGE_SUCCESS';
const FETCH_MOBILE_PAGE_FAIL = 'FETCH_MOBILE_PAGE_FAIL';
const fetchMobilePage = (slug = 'index', locale?: string) =>
(dispatch: AppDispatch) => {
dispatch({ type: FETCH_MOBILE_PAGE_REQUEST, slug, locale });
const filename = `${slug}${locale ? `.${locale}` : ''}.html`;
return staticClient.get(`/instance/mobile/${filename}`).then(({ data: html }) => {
dispatch({ type: FETCH_MOBILE_PAGE_SUCCESS, slug, locale, html });
return html;
}).catch(error => {
dispatch({ type: FETCH_MOBILE_PAGE_FAIL, slug, locale, error });
throw error;
});
};
export {
FETCH_MOBILE_PAGE_REQUEST,
FETCH_MOBILE_PAGE_SUCCESS,
FETCH_MOBILE_PAGE_FAIL,
fetchMobilePage,
};

Wyświetl plik

@ -138,7 +138,6 @@ const SoapboxMount = () => {
)}
<Route exact path='/about/:slug?' component={PublicLayout} />
<Route exact path='/mobile/:slug?' component={PublicLayout} />
<Route path='/login' component={AuthLayout} />
{(features.accountCreation && instance.registrations) && (

Wyświetl plik

@ -1,108 +0,0 @@
import React from 'react';
import ImmutablePureComponent from 'react-immutable-pure-component';
import { injectIntl, FormattedMessage } from 'react-intl';
import { connect } from 'react-redux';
import { fetchMobilePage } from 'soapbox/actions/mobile';
import { getSettings } from 'soapbox/actions/settings';
import { getSoapboxConfig } from 'soapbox/actions/soapbox';
import { languages } from '../preferences';
const mapStateToProps = state => ({
locale: getSettings(state).get('locale'),
mobilePages: getSoapboxConfig(state).get('mobilePages'),
});
@connect(mapStateToProps)
@injectIntl
class MobilePage extends ImmutablePureComponent {
state = {
pageHtml: '',
locale: this.props.locale,
}
loadPageHtml = () => {
const { dispatch, match, mobilePages } = this.props;
const { locale } = this.state;
const { slug } = match.params;
const page = mobilePages.get(slug || 'mobile');
const fetchLocale = page && locale !== page.get('default') && page.get('locales').includes(locale);
dispatch(fetchMobilePage(slug, fetchLocale && locale)).then(html => {
this.setState({ pageHtml: html });
}).catch(error => {
// TODO: Better error handling. 404 page?
this.setState({ pageHtml: '<h1>Page not found</h1>' });
});
}
setLocale = (locale) => () => {
this.setState({ locale });
};
componentDidMount() {
this.loadPageHtml();
}
componentDidUpdate(prevProps, prevState) {
const { locale, match, mobilePages } = this.props;
const { locale: prevLocale, mobilePages: prevMobilePages } = prevProps;
const { locale: stateLocale } = this.state;
const { locale: prevStateLocale } = prevState;
const { slug } = match.params;
const { slug: prevSlug } = prevProps.match.params;
if (locale !== prevLocale) this.setState({ locale });
if (
slug !== prevSlug ||
stateLocale !== prevStateLocale ||
(!prevMobilePages.get(slug || 'mobile') && mobilePages.get(slug || 'mobile'))
)
this.loadPageHtml();
}
render() {
const { match, mobilePages } = this.props;
const { slug } = match.params;
const page = mobilePages.get(slug || 'mobile');
const defaultLocale = page && page.get('default');
const alsoAvailable = page && (
<div className='rich-formatting also-available'>
<FormattedMessage id='mobile.also_available' defaultMessage='Available in:' />
{' '}
<ul>
<li>
<a href='#' onClick={this.setLocale(defaultLocale)}>
{languages[defaultLocale] || defaultLocale}
</a>
</li>
{
page.get('locales').map(locale => (
<li key={locale}>
<a href='#' onClick={this.setLocale(locale)}>
{languages[locale] || locale}
</a>
</li>
))
}
</ul>
</div>
);
return (
<div>
<div
dangerouslySetInnerHTML={{ __html: this.state.pageHtml }}
/>
{alsoAvailable}
</div>
);
}
}
export default MobilePage;

Wyświetl plik

@ -7,7 +7,6 @@ import { isStandalone } from 'soapbox/utils/state';
import AboutPage from '../about';
import LandingPage from '../landing_page';
import MobilePage from '../mobile';
import Footer from './components/footer';
import Header from './components/header';
@ -31,7 +30,6 @@ const PublicLayout = () => {
<Switch>
<Route exact path='/' component={LandingPage} />
<Route exact path='/about/:slug?' component={AboutPage} />
<Route exact path='/mobile/:slug?' component={MobilePage} />
</Switch>
</div>
</div>

Wyświetl plik

@ -106,7 +106,6 @@ export const SoapboxConfigRecord = ImmutableRecord({
limit: 1,
}),
aboutPages: ImmutableMap<string, ImmutableMap<string, unknown>>(),
mobilePages: ImmutableMap<string, ImmutableMap<string, unknown>>(),
authenticatedProfile: true,
singleUserMode: false,
singleUserModeProfile: '',