2022-03-21 11:09:01 -07:00
|
|
|
import { staticClient } from '../api';
|
|
|
|
|
2022-06-15 13:11:36 -07:00
|
|
|
import type { AppDispatch } from 'soapbox/store';
|
2022-03-21 11:09:01 -07:00
|
|
|
|
2022-06-15 13:11:36 -07:00
|
|
|
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) => {
|
2022-03-21 11:09:01 -07:00
|
|
|
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;
|
|
|
|
});
|
|
|
|
};
|
2022-06-15 13:11:36 -07:00
|
|
|
|
|
|
|
export {
|
|
|
|
FETCH_MOBILE_PAGE_REQUEST,
|
|
|
|
FETCH_MOBILE_PAGE_SUCCESS,
|
|
|
|
FETCH_MOBILE_PAGE_FAIL,
|
|
|
|
fetchMobilePage,
|
|
|
|
};
|