Highlighting user's name in the game ladder
This commit is contained in:
+1
-1
@@ -160,7 +160,7 @@ const verifyRequest = (connection) => (req, res) => {
|
|||||||
}, 3000); //3 second delay on account creation
|
}, 3000); //3 second delay on account creation
|
||||||
|
|
||||||
//TODO: prettier verification page
|
//TODO: prettier verification page
|
||||||
res.status(200).write(log('Verification succeeded!', req.query.email));
|
res.status(200).write(log('<p>Verification succeeded!</p><p><a href="/">Return Home</a></p>', req.query.email));
|
||||||
res.end();
|
res.end();
|
||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|||||||
+1
-1
@@ -111,7 +111,7 @@ const isSpying = (connection, user, cb) => {
|
|||||||
|
|
||||||
const getLadderData = (connection, field, start, length, cb) => {
|
const getLadderData = (connection, field, start, length, cb) => {
|
||||||
//moved here for reusability
|
//moved here for reusability
|
||||||
let query = 'SELECT accounts.id AS id, username, soldiers, recruits, gold FROM accounts JOIN profiles ON accounts.id = profiles.accountId ORDER BY ladderRank ASC LIMIT ?, ?;';
|
let query = 'SELECT accounts.id AS id, username, soldiers, recruits, gold FROM accounts JOIN profiles ON accounts.id = profiles.accountId ORDER BY -ladderRank DESC LIMIT ?, ?;';
|
||||||
connection.query(query, [start, length], (err, results) => {
|
connection.query(query, [start, length], (err, results) => {
|
||||||
cb(err, results);
|
cb(err, results);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,4 +1,5 @@
|
|||||||
import React from 'react';
|
import React from 'react';
|
||||||
|
import { connect } from 'react-redux';
|
||||||
import queryString from 'query-string';
|
import queryString from 'query-string';
|
||||||
|
|
||||||
import CommonLinks from '../panels/common_links.jsx';
|
import CommonLinks from '../panels/common_links.jsx';
|
||||||
@@ -43,6 +44,7 @@ class Ladder extends React.Component {
|
|||||||
<PagedLadder
|
<PagedLadder
|
||||||
start={this.state.start}
|
start={this.state.start}
|
||||||
length={this.state.length}
|
length={this.state.length}
|
||||||
|
highlightedName={this.props.username}
|
||||||
getFetch={this.getFetch.bind(this)}
|
getFetch={this.getFetch.bind(this)}
|
||||||
onReceived={this.onReceived.bind(this)}
|
onReceived={this.onReceived.bind(this)}
|
||||||
/>
|
/>
|
||||||
@@ -102,4 +104,18 @@ class Ladder extends React.Component {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const mapStoreToProps = (store) => {
|
||||||
|
return {
|
||||||
|
username: store.account.username
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
const mapDispatchToProps = (dispatch) => {
|
||||||
|
return {
|
||||||
|
//
|
||||||
|
};
|
||||||
|
};
|
||||||
|
|
||||||
|
Ladder = connect(mapStoreToProps, mapDispatchToProps)(Ladder);
|
||||||
|
|
||||||
export default Ladder;
|
export default Ladder;
|
||||||
@@ -26,7 +26,7 @@ class PagedLadder extends React.Component {
|
|||||||
<p className='col centered'>Recruits</p>
|
<p className='col centered'>Recruits</p>
|
||||||
<p className='col centered'>Gold</p>
|
<p className='col centered'>Gold</p>
|
||||||
</div>
|
</div>
|
||||||
{Object.keys(this.state).map((key) =><div key={key}>
|
{Object.keys(this.state).map((key) =><div key={key} className={`${this.props.highlightedName === this.state[key].username ? ' highlight' : ''}`}>
|
||||||
<hr />
|
<hr />
|
||||||
<div className='break' />
|
<div className='break' />
|
||||||
|
|
||||||
@@ -78,6 +78,7 @@ class PagedLadder extends React.Component {
|
|||||||
PagedLadder.propTypes = {
|
PagedLadder.propTypes = {
|
||||||
start: PropTypes.number,
|
start: PropTypes.number,
|
||||||
length: PropTypes.number,
|
length: PropTypes.number,
|
||||||
|
highlightedName: PropTypes.string,
|
||||||
setWarning: PropTypes.func,
|
setWarning: PropTypes.func,
|
||||||
getFetch: PropTypes.func,
|
getFetch: PropTypes.func,
|
||||||
onReceived: PropTypes.func
|
onReceived: PropTypes.func
|
||||||
|
|||||||
Reference in New Issue
Block a user