From e6d009d4f2d6596728b01207bf2d57dc7e72a236 Mon Sep 17 00:00:00 2001 From: crockwave Date: Mon, 10 Aug 2020 19:29:38 -0500 Subject: [PATCH] Trying to update nested state on element change events --- app/soapbox/features/configuration/index.js | 36 ++++++++++++--------- 1 file changed, 21 insertions(+), 15 deletions(-) diff --git a/app/soapbox/features/configuration/index.js b/app/soapbox/features/configuration/index.js index cc850edb0..8d3d95bde 100644 --- a/app/soapbox/features/configuration/index.js +++ b/app/soapbox/features/configuration/index.js @@ -142,13 +142,13 @@ class ConfigSoapbox extends ImmutablePureComponent { obj.configs[0].value[0].tuple[1].extensions.patron = state.extensions.patron; obj.configs[0].value[0].tuple[1].defaultSettings.autoPlayGif = state.defaultSettings.autoPlayGif; obj.configs[0].value[0].tuple[1].copyright = state.copyright; - this.state.homeFooterItems.forEach((f) => + this.state.navlinks.homeFooter.forEach((f) => obj.configs[0].value[0].tuple[1].navlinks.homeFooter.push({ title: f.get('title'), url: f.get('url') }) ); - this.state.promoItems.forEach((f) => + this.state.promoPanel.items.forEach((f) => obj.configs[0].value[0].tuple[1].promoPanel.items.push({ icon: f.get('icon'), text: f.get('text'), url: f.get('url') }) ); - this.state.customCssItems.forEach((f) => + this.state.customCss.forEach((f) => obj.configs[0].value[0].tuple[1].customCss.push(f) ); return obj; @@ -205,7 +205,9 @@ class ConfigSoapbox extends ImmutablePureComponent { return (e) => { // this.state.soapbox.promoItems.setIn([i, key], e.target.value); this.setState({ - promoItems: this.state.promoItems.setIn([i, key], e.target.value), + promoPanel: { + items: this.state.promoPanel.items.setIn([i, key], e.target.value), + }, }); }; } @@ -214,7 +216,9 @@ class ConfigSoapbox extends ImmutablePureComponent { return (e) => { // this.state.soapbox.homeFooterItems.setIn([i, key], e.target.value); this.setState({ - homeFooterItems: this.state.homeFooterItems.setIn([i, key], e.target.value), + navlinks: { + homeFooter: this.state.navlinks.homeFooter.setIn([i, key], e.target.value), + }, }); }; } @@ -223,7 +227,7 @@ class ConfigSoapbox extends ImmutablePureComponent { return (e) => { // this.state.soapbox.customCssItems.setIn([i], e.target.value); this.setState({ - customCssItems: this.state.customCssItems.setIn([i], e.target.value), + customCss: this.state.customCss.setIn([i], e.target.value), }); }; } @@ -243,7 +247,7 @@ class ConfigSoapbox extends ImmutablePureComponent { handleAddPromoPanelItem = () => { this.setState({ - Items: this.state.promoPanel.Items.concat([ + Items: this.state.promoPanel.items.concat([ ImmutableMap({ icon: '', text: '', @@ -274,6 +278,8 @@ class ConfigSoapbox extends ImmutablePureComponent { const { intl } = this.props; const { logo, banner, brandColor, extensions, defaultSettings, copyright, promoPanel, navlinks, customCss } = this.state; + const patron = (extensions.patron === 'true'); + const autoPlayGif = (defaultSettings.autoPlayGif === 'true'); // console.log(navlinks.homeFooter); // console.log(promoPanel.items); @@ -324,14 +330,14 @@ class ConfigSoapbox extends ImmutablePureComponent { label={} hint={} name='patron' - checked={extensions.patron ? extensions.patron : false} + checked={patron ? patron : false} onChange={this.handleExtensionsCheckboxChange} /> } hint={} name='autoPlayGif' - checked={defaultSettings.autoPlayGif ? defaultSettings.autoPlayGif : false} + checked={autoPlayGif ? autoPlayGif : false} onChange={this.handleDefaultSettingsCheckboxChange} /> @@ -379,9 +385,9 @@ class ConfigSoapbox extends ImmutablePureComponent { )) }
- +
@@ -408,9 +414,9 @@ class ConfigSoapbox extends ImmutablePureComponent { )) }
- +
@@ -432,9 +438,9 @@ class ConfigSoapbox extends ImmutablePureComponent { )) }
- +