diff --git a/app/gabsocial/actions/soapbox.js b/app/gabsocial/actions/soapbox.js new file mode 100644 index 000000000..711790c5a --- /dev/null +++ b/app/gabsocial/actions/soapbox.js @@ -0,0 +1,29 @@ +import api from '../api'; + +export const SOAPBOX_CONFIG_IMPORT = 'SOAPBOX_CONFIG_IMPORT'; +export const SOAPBOX_CONFIG_FAIL = 'SOAPBOX_CONFIG_FAIL'; + +export function fetchSoapboxConfig() { + return (dispatch, getState) => { + api(getState).get(`/soapbox/soapbox.json`).then(response => { + dispatch(importSoapboxConfig(response.data)); + }).catch(error => { + dispatch(soapboxConfigFail(error)); + }); + }; +} + +export function importSoapboxConfig(soapboxConfig) { + return { + type: SOAPBOX_CONFIG_IMPORT, + soapboxConfig + }; +} + +export function soapboxConfigFail(error) { + return { + type: SOAPBOX_CONFIG_FAIL, + error, + skipAlert: true, + }; +}; diff --git a/app/gabsocial/containers/gabsocial.js b/app/gabsocial/containers/gabsocial.js index 03d302380..a54b09b90 100644 --- a/app/gabsocial/containers/gabsocial.js +++ b/app/gabsocial/containers/gabsocial.js @@ -17,6 +17,7 @@ import { getLocale } from '../locales'; import initialState from '../initial_state'; import { me } from '../initial_state'; import ErrorBoundary from '../components/error_boundary'; +import { fetchSoapboxConfig } from 'gabsocial/actions/soapbox'; const { localeData, messages } = getLocale(); addLocaleData(localeData); @@ -26,6 +27,7 @@ const hydrateAction = hydrateStore(initialState); store.dispatch(hydrateAction); store.dispatch(fetchCustomEmojis()); +store.dispatch(fetchSoapboxConfig()); const mapStateToProps = (state) => { const account = state.getIn(['accounts', me]); diff --git a/app/gabsocial/pages/home_page.js b/app/gabsocial/pages/home_page.js index a4056e9c9..c8e6ba650 100644 --- a/app/gabsocial/pages/home_page.js +++ b/app/gabsocial/pages/home_page.js @@ -1,7 +1,6 @@ import React from 'react'; import { connect } from 'react-redux'; -import { me, funding } from 'gabsocial/initial_state'; -import soapbox from 'soapbox/config'; +import { me } from 'gabsocial/initial_state'; import PropTypes from 'prop-types'; import ImmutablePureComponent from 'react-immutable-pure-component'; import WhoToFollowPanel from '../features/ui/components/who_to_follow_panel'; @@ -16,12 +15,13 @@ import GroupSidebarPanel from '../features/groups/sidebar_panel'; const mapStateToProps = state => ({ account: state.getIn(['accounts', me]), + hasPatron: state.getIn(['soapbox', 'features', 'patron']), }); export default @connect(mapStateToProps) class HomePage extends ImmutablePureComponent { render () { - const {children, account} = this.props; + const {children, account, hasPatron} = this.props; return (