diff --git a/app/soapbox/features/soapbox_config/index.js b/app/soapbox/features/soapbox_config/index.js index a22990995..a1249a818 100644 --- a/app/soapbox/features/soapbox_config/index.js +++ b/app/soapbox/features/soapbox_config/index.js @@ -110,6 +110,13 @@ class SoapboxConfig extends ImmutablePureComponent { }; }; + handleDeleteItem = path => { + return e => { + const soapbox = this.state.soapbox.deleteIn(path); + this.setState({ soapbox }); + }; + }; + handleItemChange = (path, key, field, template) => { return this.handleChange( path, (e) => @@ -238,6 +245,7 @@ class SoapboxConfig extends ImmutablePureComponent { value={field.get('url')} onChange={this.handlePromoItemChange(i, 'url', field)} /> + Delete )) } @@ -268,6 +276,7 @@ class SoapboxConfig extends ImmutablePureComponent { value={field.get('url')} onChange={this.handleHomeFooterItemChange(i, 'url', field)} /> + Delete )) } @@ -293,6 +302,7 @@ class SoapboxConfig extends ImmutablePureComponent { value={field} onChange={this.handleChange(['customCss', i], (e) => e.target.value)} /> + Delete )) } diff --git a/app/soapbox/reducers/soapbox.js b/app/soapbox/reducers/soapbox.js index 1311c3f88..f1d2f7990 100644 --- a/app/soapbox/reducers/soapbox.js +++ b/app/soapbox/reducers/soapbox.js @@ -6,9 +6,7 @@ const initialState = ImmutableMap(); const updateFromAdmin = (state, config) => { // TODO: Generalize this with an API similar to `Pleroma.Config` in Pleroma BE - const soapboxConfig = config.getIn(['configs', 0, 'value', 0, 'tuple', 1]); - if (soapboxConfig) return state.mergeDeep(soapboxConfig); - return state; + return config.getIn(['configs', 0, 'value', 0, 'tuple', 1], state); }; export default function soapbox(state = initialState, action) {