diff --git a/client/src/components/faceoff.jsx b/client/src/components/faceoff.jsx index 251f10e6..ea3858cd 100644 --- a/client/src/components/faceoff.jsx +++ b/client/src/components/faceoff.jsx @@ -1,34 +1,25 @@ const preact = require('preact'); const { connect } = require('preact-redux'); -const actions = require('../actions'); - const { ConstructAvatar } = require('./construct'); -const Controls = require('./controls'); const addState = connect( function receiveState(state) { const { - ws, instance, account, } = state; - function sendInstanceReady() { - return ws.sendInstanceReady(instance.id); - } - return { instance, account, - sendInstanceReady, }; - }, + } ); function FaceoffConstruct(args) { const { - construct + construct, } = args; return ( @@ -39,75 +30,82 @@ function FaceoffConstruct(args) { - ) -} - -function Faceoff(props) { - const { - instance, - account, - sendInstanceReady, - } = props; - - if (!instance) return
...
; - - const otherTeam = instance.players.find(t => t.id !== account.id); - const playerTeam = instance.players.find(t => t.id === account.id); - - function PlayerTeam(team) { - const constructs = team.constructs.map((c, i) => - ); - - const winner = instance.winner === team.id; - const classes = `team player ${winner ? 'winner' : team.ready ? 'ready' : ''}` - return ( -
- {constructs} -
- ); - } - - - function OpponentTeam(team) { - const constructs = team.constructs.map((c, i) => - ); - - const winner = instance.winner === team.id; - const classes = `team opponent ${winner ? 'winner' : team.ready ? 'ready' : ''}` - - return ( -
- {constructs} -
- ); - } - function faceoffText() { - if (!instance.winner) { - return ( -
-
{otherTeam.name}
-
vs
-
{playerTeam.name}
-
- ); - } - const winner = instance.winner === playerTeam.id ? playerTeam : otherTeam; - return ( -
-
{winner.name}
-
wins
-
- ) - - } - - return ( -
- {OpponentTeam(otherTeam)} - {faceoffText()} - {PlayerTeam(playerTeam)} -
); } +class Faceoff extends preact.Component { + shouldComponentUpdate(newProps) { + if (newProps.instance !== this.props.instance) return true; + if (newProps.account !== this.props.account) return true; + return false; + } + + render(props) { + const { + instance, + account, + } = props; + + if (!instance) return
...
; + + const otherTeam = instance.players.find(t => t.id !== account.id); + const playerTeam = instance.players.find(t => t.id === account.id); + + function PlayerTeam(team) { + const constructs = team.constructs.map((c, i) => + ); + + const winner = instance.winner === team.id; + const classes = `team player ${winner ? 'winner' : team.ready ? 'ready' : ''}`; + return ( +
+ {constructs} +
+ ); + } + + + function OpponentTeam(team) { + const constructs = team.constructs.map((c, i) => + ); + + const winner = instance.winner === team.id; + const classes = `team opponent ${winner ? 'winner' : team.ready ? 'ready' : ''}`; + + return ( +
+ {constructs} +
+ ); + } + function faceoffText() { + if (!instance.winner) { + return ( +
+
{otherTeam.name}
+
vs
+
{playerTeam.name}
+
+ ); + } + const winner = instance.winner === playerTeam.id ? playerTeam : otherTeam; + return ( +
+
{winner.name}
+
wins
+
+ ) + + } + + return ( +
+ {OpponentTeam(otherTeam)} + {faceoffText()} + {PlayerTeam(playerTeam)} +
+ ); + } +} + module.exports = addState(Faceoff); diff --git a/client/src/components/info.component.jsx b/client/src/components/info.component.jsx index 87c96eeb..1c7010fc 100644 --- a/client/src/components/info.component.jsx +++ b/client/src/components/info.component.jsx @@ -3,7 +3,7 @@ const reactStringReplace = require('react-string-replace'); const specThresholds = require('./info.thresholds'); const { INFO } = require('./../constants'); -const { convertItem, removeTier, formatInfo } = require('../utils'); +const { convertItem, removeTier } = require('../utils'); const { tutorialStage } = require('../tutorial.utils'); const shapes = require('./shapes'); @@ -75,8 +75,8 @@ class InfoComponent extends preact.Component { }; if (isSkill || isSpec) { - let infoText = info; - while (infoText.includes('Plus')) infoText = infoText.replace('Plus', '+'); + let infoName = info; + while (infoName.includes('Plus')) infoName = infoName.replace('Plus', '+'); const header = isSkill ?

SKILL

:

SPEC

; @@ -101,7 +101,7 @@ class InfoComponent extends preact.Component { return (
-

{infoText} {fullInfo.cost}b

+

{infoName} {fullInfo.cost}b

{header} {itemSourceInfo} {cooldown} diff --git a/client/src/components/instance.component.jsx b/client/src/components/instance.component.jsx index d4953550..b5e98674 100644 --- a/client/src/components/instance.component.jsx +++ b/client/src/components/instance.component.jsx @@ -13,11 +13,13 @@ const actions = require('../actions'); const addState = connect( function receiveState(state) { - const { instance, + const { + instance, nav, navInstance, } = state; - return { instance, + return { + instance, nav, navInstance, }; @@ -52,7 +54,7 @@ const addState = connect( ); class Instance extends Component { - componentShouldUpdate(newProps) { + shouldComponentUpdate(newProps) { if (newProps.instance !== this.props.instance) return true; return false; } diff --git a/client/src/components/main.jsx b/client/src/components/main.jsx index ab923182..b03e0069 100644 --- a/client/src/components/main.jsx +++ b/client/src/components/main.jsx @@ -16,35 +16,45 @@ const addState = connect( } ); -function Main(props) { - const { - game, - instance, - account, - nav, - } = props; - - if (!account) { - return ; +class Main extends preact.Component { + shouldComponentUpdate(newProps) { + if (newProps.game !== this.props.game) return true; + if (newProps.instance !== this.props.instance) return true; + if (newProps.account !== this.props.account) return true; + if (newProps.nav !== this.props.nav) return true; + return false; } - if (game) { - return ; + render(props) { + const { + game, + instance, + account, + nav, + } = props; + + if (!account) { + return ; + } + + if (game) { + return ; + } + + if (instance) { + return ; + } + + if (nav === 'transition') return false; + + return ( +
+
+ + +
+ ); } - - if (instance) { - return ; - } - - if (nav === 'transition') return false; - - return ( -
-
- - -
- ); } module.exports = addState(Main); diff --git a/client/src/components/mnml.jsx b/client/src/components/mnml.jsx index 5c4ae51b..60dad587 100644 --- a/client/src/components/mnml.jsx +++ b/client/src/components/mnml.jsx @@ -10,11 +10,21 @@ const addState = connect( state => ({ showNav: state.showNav }) ); -const Mnml = ({ showNav }) => -
-
- -
-
; +class Mnml extends preact.Component { + shouldComponentUpdate(newProps) { + if (newProps.showNav !== this.props.showNav) return true; + return false; + } + + render(args) { + return ( +
+
+ +
+ ); + } +} module.exports = addState(Mnml);