From 82142b0cb183925087f25d5177533e3967eb8805 Mon Sep 17 00:00:00 2001 From: felixlinker Date: Sun, 9 Aug 2020 19:00:45 +0200 Subject: [PATCH] Use Module.setEnabled in Power Management table --- src/app/components/PowerManagement.jsx | 18 +----------------- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/src/app/components/PowerManagement.jsx b/src/app/components/PowerManagement.jsx index 0b87b647..386dbb98 100644 --- a/src/app/components/PowerManagement.jsx +++ b/src/app/components/PowerManagement.jsx @@ -46,7 +46,6 @@ export default class PowerManagement extends TranslatedComponent { static propTypes = { ship: PropTypes.instanceOf(Ship).isRequired, code: PropTypes.string.isRequired, - onChange: PropTypes.func.isRequired }; /** @@ -107,19 +106,6 @@ export default class PowerManagement extends TranslatedComponent { return modules; } - /** - * Creates a callback for flipping the enabled state of a module. - * @param {Module} m Module to flip - * @returns {Function} Callback - */ - _flipEnabledCb(m) { - const { onChange } = this.props; - return () => { - m.setEnabled(); - onChange(); - }; - } - /** * Creates a callback that changes the power priority for the given module * based on the given delta. @@ -128,13 +114,11 @@ export default class PowerManagement extends TranslatedComponent { * @returns {Function} Callback */ _prioCb(m, delta) { - const { onChange } = this.props; return () => { const prio = m.getPowerPriority(); const newPrio = Math.max(0, prio + delta); if (0 < newPrio) { m.setPowerPriority(newPrio); - onChange(); } }; } @@ -153,7 +137,7 @@ export default class PowerManagement extends TranslatedComponent { let modules = this._sortAndFilter(ship.getModules()); for (let m of modules) { let retractedElem = null, deployedElem = null; - const flipEnabled = this._flipEnabledCb(m); + const flipEnabled = () => m.setEnabled(); if (m.isEnabled()) { let powered = m.isPowered(); retractedElem = {getPowerIcon(powered.retracted)};