Move Soapbox config to fetchable endpoint
This commit is contained in:
parent
2a245d076a
commit
c9c08dff5c
8 changed files with 56 additions and 9 deletions
29
app/gabsocial/actions/soapbox.js
Normal file
29
app/gabsocial/actions/soapbox.js
Normal file
|
@ -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,
|
||||
};
|
||||
};
|
|
@ -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]);
|
||||
|
|
|
@ -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 (
|
||||
<div className='page'>
|
||||
|
@ -31,7 +31,7 @@ class HomePage extends ImmutablePureComponent {
|
|||
<div className='columns-area__panels__pane columns-area__panels__pane--left'>
|
||||
<div className='columns-area__panels__pane__inner'>
|
||||
<UserPanel />
|
||||
{soapbox.features.patron && <FundingPanel />}
|
||||
{hasPatron && <FundingPanel />}
|
||||
<PromoPanel />
|
||||
<LinkFooter />
|
||||
</div>
|
||||
|
|
|
@ -38,6 +38,7 @@ import group_lists from './group_lists';
|
|||
import group_editor from './group_editor';
|
||||
import sidebar from './sidebar';
|
||||
import patron from './patron';
|
||||
import soapbox from './soapbox';
|
||||
|
||||
const reducers = {
|
||||
dropdown_menu,
|
||||
|
@ -79,6 +80,7 @@ const reducers = {
|
|||
group_editor,
|
||||
sidebar,
|
||||
patron,
|
||||
soapbox,
|
||||
};
|
||||
|
||||
export default combineReducers(reducers);
|
||||
|
|
13
app/gabsocial/reducers/soapbox.js
Normal file
13
app/gabsocial/reducers/soapbox.js
Normal file
|
@ -0,0 +1,13 @@
|
|||
import { SOAPBOX_CONFIG_IMPORT } from '../actions/soapbox';
|
||||
import { Map as ImmutableMap, fromJS } from 'immutable';
|
||||
|
||||
const initialState = ImmutableMap();
|
||||
|
||||
export default function soapbox(state = initialState, action) {
|
||||
switch(action.type) {
|
||||
case SOAPBOX_CONFIG_IMPORT:
|
||||
return ImmutableMap(fromJS(action.soapboxConfig));
|
||||
default:
|
||||
return state;
|
||||
}
|
||||
};
|
|
@ -1,5 +0,0 @@
|
|||
export default {
|
||||
features: {
|
||||
patron: true,
|
||||
},
|
||||
}
|
5
public/soapbox/soapbox.json
Normal file
5
public/soapbox/soapbox.json
Normal file
|
@ -0,0 +1,5 @@
|
|||
{
|
||||
"features": {
|
||||
"patron": false
|
||||
}
|
||||
}
|
|
@ -69,6 +69,7 @@ module.exports = merge(sharedConfig, {
|
|||
'/socket': backendUrl,
|
||||
'/oauth/revoke': backendUrl,
|
||||
'/.well-known/webfinger': backendUrl,
|
||||
'/static': backendUrl,
|
||||
'/patron': patronUrl,
|
||||
},
|
||||
},
|
||||
|
|
Loading…
Reference in a new issue