Skip to content

Commit

Permalink
Merge pull request #227 from domino14/bug/226/challenge_results
Browse files Browse the repository at this point in the history
Reload challenge leaderboard data on dialog open.
  • Loading branch information
domino14 authored Mar 13, 2017
2 parents cedf3c8 + 5ecc5a8 commit 70107f3
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 13 deletions.
2 changes: 1 addition & 1 deletion djAerolith/current_version.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
CURRENT_VERSION = '0.10.0.0'
CURRENT_VERSION = '0.10.0.2'
37 changes: 25 additions & 12 deletions djAerolith/wordwalls/static/js/wordwalls/newtable/table_creator.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,9 @@ class TableCreator extends React.Component {
*/
componentDidUpdate(prevProps, prevState) {
let challengeParamsChanged = false;
// If the lexicon changes, we have to load new word lists no matter what.
// If the date changes, we are in the challenges window. We should
// mark challenge parameters as having changed.
if ((prevState.currentLexicon !== this.state.currentLexicon) ||
(prevState.currentDate.format(DATE_FORMAT_STRING) !==
this.state.currentDate.format(DATE_FORMAT_STRING))) {
Expand All @@ -115,18 +118,7 @@ class TableCreator extends React.Component {
if (prevState.currentChallenge !== this.state.currentChallenge ||
challengeParamsChanged) {
// The challenge changed. We should load challenge leaderboard data.
this.showSpinner();
$.ajax({
url: '/wordwalls/api/challengers/',
data: {
lexicon: this.state.currentLexicon,
date: this.state.currentDate.format(DATE_FORMAT_STRING),
challenge: this.state.currentChallenge,
},
method: 'GET',
})
.done(data => this.setState({ challengeData: data || {} }))
.always(() => this.hideSpinner());
this.loadChallengeLeaderboardData();
}
}

Expand All @@ -139,6 +131,24 @@ class TableCreator extends React.Component {
});
}

loadChallengeLeaderboardData() {
if (!this.state.currentChallenge) {
return;
}
this.showSpinner();
$.ajax({
url: '/wordwalls/api/challengers/',
data: {
lexicon: this.state.currentLexicon,
date: this.state.currentDate.format(DATE_FORMAT_STRING),
challenge: this.state.currentChallenge,
},
method: 'GET',
})
.done(data => this.setState({ challengeData: data || {} }))
.always(() => this.hideSpinner());
}

loadInfoForSearchType(option) {
switch (option) {
case SEARCH_TYPE_CHALLENGE:
Expand All @@ -163,6 +173,9 @@ class TableCreator extends React.Component {
// reopens the dialog.
resetDialog() {
this.loadInfoForSearchType(this.state.activeSearchType);
if (this.state.activeSearchType === SEARCH_TYPE_CHALLENGE) {
this.loadChallengeLeaderboardData();
}
}

showModal() {
Expand Down

0 comments on commit 70107f3

Please sign in to comment.