BUGFIX: Equipment page data was being overwritten

This commit is contained in:
2019-06-06 14:43:04 +10:00
parent 92385bb72d
commit 5d542ebdb9
7 changed files with 32 additions and 29 deletions
+3
View File
@@ -5,6 +5,8 @@ Major
* Write the instructions for badges. * Write the instructions for badges.
* Implement countdown timers for combat and training. * Implement countdown timers for combat and training.
* Implement referral links. * Implement referral links.
* Implement admin panel / stats page.
* Implement bug tracker.
Minor Minor
--- ---
@@ -20,6 +22,7 @@ Patch
* Game Balance. * Game Balance.
* Images to social media instead of links. * Images to social media instead of links.
* Occasional flickering when rendering Profile page.
Potential And Confirmed Bugs Potential And Confirmed Bugs
--- ---
-7
View File
@@ -22,7 +22,6 @@ class SpyingLog extends React.Component {
length: parseInt(params.length) || 20, length: parseInt(params.length) || 20,
fetch: null, fetch: null,
buttonsVisible: false,
warning: '' warning: ''
}; };
@@ -84,10 +83,6 @@ class SpyingLog extends React.Component {
} }
buttonHeader() { buttonHeader() {
if (!this.buttonsVisible && this.props.spies <= 0) {
return null;
}
//TODO: prettier messages
return ( return (
<div className='table noCollapse'> <div className='table noCollapse'>
<div className='row'> <div className='row'>
@@ -151,8 +146,6 @@ class SpyingLog extends React.Component {
} }
onReceived(data) { onReceived(data) {
this.setState({ buttonsVisible: data.length > 0 });
if (data.length === 0) { if (data.length === 0) {
let start = Math.max(0, this.state.start - this.state.length); let start = Math.max(0, this.state.start - this.state.length);
+8 -9
View File
@@ -32,17 +32,16 @@ class Equipment extends React.Component {
return ( return (
<div className='panel'> <div className='panel'>
<div className='table'> <div className='table'>
<div className='row'> <div className='row mobile hide'>
<p className='col centered truncate'>Name</p> <p className='col centered truncate'>Name</p>
<p className='col centered truncate'>Type</p> <p className='col centered truncate'>Type</p>
<p className='col centered truncate'>Boost</p> <p className='col centered truncate'>Boost</p>
<p className='col centered truncate'>Owned</p> <p className='col centered truncate'>Owned</p>
<p className='col centered truncate mobile hide alwaysCentered'>Buy</p> <p className='col centered truncate'>Buy</p>
<p className='col centered truncate mobile hide alwaysCentered'>Sell</p> <p className='col centered truncate'>Sell</p>
</div> </div>
<hr className='mobile show' /> <hr className='mobile show' />
<div className='break mobile show' />
{Object.keys(display).map((key) => <div key={key}> {Object.keys(display).map((key) => <div key={key}>
<hr className='mobile hide'/> <hr className='mobile hide'/>
@@ -50,12 +49,12 @@ class Equipment extends React.Component {
<div className='row'> <div className='row'>
<p className='col centered truncate equipmentTextPadding'>{display[key].name}</p> <p className='col centered truncate equipmentTextPadding'>{display[key].name}</p>
<p className='col centered truncate equipmentTextPadding'>{display[key].type}</p> <p className='col centered truncate equipmentTextPadding'>{display[key].type}</p>
<p className='col centered truncate equipmentTextPadding'>{display[key].combatBoost * 100}%</p> <p className='col centered truncate equipmentTextPadding'><span className='mobile show' style={{whiteSpace: 'pre'}}>+</span>{display[key].combatBoost * 100}%</p>
<p className='col centered truncate equipmentTextPadding'>{display[key].owned}</p> <p className='col centered truncate equipmentTextPadding'><span className='mobile show' style={{whiteSpace: 'pre'}}>Owned: </span>{display[key].owned}</p>
<div className='break mobile show' /> <div className='break mobile show' />
<div className='col row noCollapse' style={{flex: '1 1 17.5%'}}> <div className='col row noCollapse' style={{flex: '1 1 17.5%'}}>
{display[key].purchasable ? <button className='col centered truncate' onClick={() => this.sendRequest('/equipmentpurchaserequest', { name: display[key].name, type: display[key].type }) } disabled={display[key].cost > this.props.gold}>Buy ({display[key].cost} gold)</button> : <div className='col centered truncate' />} {display[key].purchasable ? <button className='col centered truncate' onClick={() => this.sendRequest('/equipmentpurchaserequest', { name: display[key].name, type: display[key].type }) } disabled={display[key].cost > this.props.gold}>Buy <span className='mobile show' style={{whiteSpace:'pre'}}>{display[key].name} </span>({display[key].cost} gold)</button> : <div className='col' />}
{display[key].saleable ? <button className='col centered truncate' onClick={() => this.sendRequest('/equipmentsellrequest', { name: display[key].name, type: display[key].type }) } disabled={display[key].owned === 0}>Sell ({Math.floor(display[key].cost/2)} gold)</button> : <div className='col centered truncate' />} {display[key].saleable ? <button className='col centered truncate' onClick={() => this.sendRequest('/equipmentsellrequest', { name: display[key].name, type: display[key].type }) } disabled={display[key].owned === 0}>Sell <span className='mobile show' style={{whiteSpace:'pre'}}>{display[key].name} </span>({Math.floor(display[key].cost/2)} gold)</button> : <div className='col' />}
</div> </div>
</div> </div>
<div className='break' /> <div className='break' />
@@ -77,7 +76,7 @@ class Equipment extends React.Component {
let json = JSON.parse(xhr.responseText); let json = JSON.parse(xhr.responseText);
//on success //on success
this.setState({ data: json }); this.setState({ data: Object.assign({}, this.state.data, json) });
if (this.props.onSuccess) { if (this.props.onSuccess) {
this.props.onSuccess(json); this.props.onSuccess(json);
+1 -1
View File
@@ -7,7 +7,7 @@ class News extends React.Component {
super(props); super(props);
this.state = { this.state = {
// //TODO: data?
}; };
if (props.getFetch) { if (props.getFetch) {
+13 -3
View File
@@ -1,4 +1,5 @@
import React from 'react'; import React from 'react';
import { withRouter, Link } from 'react-router-dom';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
@@ -18,8 +19,17 @@ class PagedCombatLog extends React.Component {
} }
render() { render() {
//nothing to report
if (this.state.data.length === 0) {
return ( return (
<div> <div className='panel'>
<p className='centered'>Go and <Link to='/ladder'>attack someone!</Link></p>
</div>
);
}
return (
<div className='panel'>
{Object.keys(this.state.data).map((key) => <CombatLogRecord key={key} username={this.props.username} {...this.state.data[key]} />)} {Object.keys(this.state.data).map((key) => <CombatLogRecord key={key} username={this.props.username} {...this.state.data[key]} />)}
</div> </div>
); );
@@ -39,7 +49,7 @@ class PagedCombatLog extends React.Component {
json.sort((a, b) => new Date(b.eventTime) - new Date(a.eventTime)); json.sort((a, b) => new Date(b.eventTime) - new Date(a.eventTime));
//on success //on success
this.setState({ data: json }); this.setState({ data: json }); //OVERRIDE existing data
if (this.props.onReceived) { if (this.props.onReceived) {
this.props.onReceived(json); this.props.onReceived(json);
@@ -88,4 +98,4 @@ const mapDispatchToProps = (dispatch) => {
PagedCombatLog = connect(mapStoreToProps, mapDispatchToProps)(PagedCombatLog); PagedCombatLog = connect(mapStoreToProps, mapDispatchToProps)(PagedCombatLog);
export default PagedCombatLog; export default withRouter(PagedCombatLog);
+2 -2
View File
@@ -6,7 +6,7 @@ class PagedLadder extends React.Component {
constructor(props) { constructor(props) {
super(props); super(props);
this.state = { this.state = {
// //TODO: data?
} }
if (props.getFetch) { if (props.getFetch) {
@@ -16,7 +16,7 @@ class PagedLadder extends React.Component {
render() { render() {
return ( return (
<div className='table'> <div className='panel table'>
<div className='row mobile hide'> <div className='row mobile hide'>
<p className='col centered'>Username</p> <p className='col centered'>Username</p>
<p className='col centered'>Soldiers</p> <p className='col centered'>Soldiers</p>
+5 -7
View File
@@ -1,5 +1,4 @@
import React from 'react'; import React from 'react';
import { withRouter, Link } from 'react-router-dom';
import { connect } from 'react-redux'; import { connect } from 'react-redux';
import PropTypes from 'prop-types'; import PropTypes from 'prop-types';
@@ -20,17 +19,16 @@ class PagedSpyingLog extends React.Component {
render() { render() {
//if there are no spies //if there are no spies
if (this.props.spies <= 0 && this.state.data.length <= 0) { if (this.state.data.length === 0) {
return ( return (
<div className='panel'> <div className='panel'>
<p className='centered'>You have no spies!</p> <p className='centered'>It's empty in here, isn't it?</p>
<p className='centered'>Go and <Link to='/profile'>train some!</Link></p>
</div> </div>
); );
} }
return ( return (
<div> <div className='panel'>
{Object.keys(this.state.data).map((key) => <SpyingLogRecord key={key} username={this.props.username} {...this.state.data[key]} />)} {Object.keys(this.state.data).map((key) => <SpyingLogRecord key={key} username={this.props.username} {...this.state.data[key]} />)}
</div> </div>
); );
@@ -50,7 +48,7 @@ class PagedSpyingLog extends React.Component {
json.sort((a, b) => new Date(b.eventTime) - new Date(a.eventTime)); json.sort((a, b) => new Date(b.eventTime) - new Date(a.eventTime));
//on success //on success
this.setState({ data: json }); this.setState({ data: json }); //OVERRIDE existing data
if (this.props.onReceived) { if (this.props.onReceived) {
this.props.onReceived(json); this.props.onReceived(json);
@@ -99,4 +97,4 @@ const mapDispatchToProps = (dispatch) => {
PagedSpyingLog = connect(mapStoreToProps, mapDispatchToProps)(PagedSpyingLog); PagedSpyingLog = connect(mapStoreToProps, mapDispatchToProps)(PagedSpyingLog);
export default withRouter(PagedSpyingLog); export default PagedSpyingLog;