From ba9e7f1a323cc3eef0959bb19ec9e027eeb0b5b5 Mon Sep 17 00:00:00 2001 From: Felix Linker Date: Thu, 16 Apr 2020 15:12:38 +0200 Subject: [PATCH] Add code props variable as ship hash to update changes --- src/app/components/PowerBands.jsx | 1 + src/app/components/PowerManagement.jsx | 5 +++-- src/app/components/ShipSummaryTable.jsx | 14 +------------- src/app/components/SlotSection.jsx | 1 + src/app/pages/OutfittingPage.jsx | 10 +++++----- 5 files changed, 11 insertions(+), 20 deletions(-) diff --git a/src/app/components/PowerBands.jsx b/src/app/components/PowerBands.jsx index bd3c1233..87c278c6 100644 --- a/src/app/components/PowerBands.jsx +++ b/src/app/components/PowerBands.jsx @@ -32,6 +32,7 @@ function getClass(selected, relDraw) { export default class PowerBands extends TranslatedComponent { static propTypes = { ship: PropTypes.instanceOf(Ship).isRequired, + code: PropTypes.string.isRequired, width: PropTypes.number.isRequired, }; diff --git a/src/app/components/PowerManagement.jsx b/src/app/components/PowerManagement.jsx index 3335403c..df2161ea 100644 --- a/src/app/components/PowerManagement.jsx +++ b/src/app/components/PowerManagement.jsx @@ -45,6 +45,7 @@ function getPowerIcon(enabled) { export default class PowerManagement extends TranslatedComponent { static propTypes = { ship: PropTypes.instanceOf(Ship).isRequired, + code: PropTypes.string.isRequired, onChange: PropTypes.func.isRequired }; @@ -215,7 +216,7 @@ export default class PowerManagement extends TranslatedComponent { * @return {React.Component} contents */ render() { - let { ship } = this.props; + let { ship, code } = this.props; let { translate, formats } = this.context.language; let pp = ship.getPowerPlant(); @@ -248,7 +249,7 @@ export default class PowerManagement extends TranslatedComponent { {this._renderPowerRows(ship, translate, formats.f2, formats.pct1)} - + ); } diff --git a/src/app/components/ShipSummaryTable.jsx b/src/app/components/ShipSummaryTable.jsx index 8e467d34..f0ba67cf 100644 --- a/src/app/components/ShipSummaryTable.jsx +++ b/src/app/components/ShipSummaryTable.jsx @@ -11,7 +11,6 @@ const { ARMOUR_METRICS, CARGO_CAPACITY, FUEL_CAPACITY, UNLADEN_MASS, MAXIMUM_MASS, MODULE_PROTECTION_METRICS } = ShipProps; -import { OBJECT_EVENT } from 'ed-forge/lib/Ship'; /** * Ship Summary Table / Stats @@ -19,6 +18,7 @@ import { OBJECT_EVENT } from 'ed-forge/lib/Ship'; export default class ShipSummaryTable extends TranslatedComponent { static propTypes = { ship: PropTypes.object.isRequired, + code: PropTypes.string.isRequired, }; /** @@ -33,18 +33,6 @@ export default class ShipSummaryTable extends TranslatedComponent { }; } - _onChange() { - this.forceUpdate(); - } - - componentWillMount() { - this.props.ship.on(OBJECT_EVENT, this._onChange); - } - - componentWillUnmount() { - this.props.ship.removeListener(OBJECT_EVENT, this._onChange); - } - /** * Render the table * @return {React.Component} Summary table diff --git a/src/app/components/SlotSection.jsx b/src/app/components/SlotSection.jsx index 082345a0..2f15d8c7 100644 --- a/src/app/components/SlotSection.jsx +++ b/src/app/components/SlotSection.jsx @@ -15,6 +15,7 @@ const browser = require('detect-browser'); export default class SlotSection extends TranslatedComponent { static propTypes = { ship: PropTypes.instanceOf(Ship), + code: PropTypes.string.isRequired, togglePwr: PropTypes.func, }; diff --git a/src/app/pages/OutfittingPage.jsx b/src/app/pages/OutfittingPage.jsx index deefdc53..a28b5c01 100644 --- a/src/app/pages/OutfittingPage.jsx +++ b/src/app/pages/OutfittingPage.jsx @@ -631,11 +631,11 @@ export default class OutfittingPage extends Page { {/* Main tables */} - - - - - + + + + + {/* Control of ship and opponent */} {/*