this.state = {
word_sets: word_sets,
- submitted: false,
selected: null
};
+ this.submitted = false;
this.judging_sent_recently = false;
}
async handle_submit() {
+
+ /* Don't submit a second time. */
+ if (this.submitted)
+ return;
+
const response = await fetch_post_json(
`judged/${this.props.prompt.id}`,{
word_groups: this.state.word_sets.map(set => Array.from(set))
return;
}
- this.setState({
- submitted: true
- });
+ this.submitted = true;
}
handle_click(word) {
}
render() {
- if (this.state.submitted)
+ if (this.props.players_judged.has(this.props.player.name)) {
return (
<div className="please-wait">
<h2>Submission received</h2>
</div>
);
+ }
const btn_class = "ambiguity-button";
const btn_selected_class = btn_class + " selected";
super(props);
const items = props.prompt.items;
- this.state = {
- submitted: false
- };
+ this.submitted = false;
this.answers = [...Array(items)].map(() => React.createRef());
this.answering_sent_recently = false;
/* Prevent the default page-changing form-submission behavior. */
event.preventDefault();
+ /* And don't submit a second time. */
+ if (this.submitted)
+ return;
+
const response = await fetch_post_json(`answer/${this.props.prompt.id}`, {
answers: this.answers.map(r => r.current.value)
});
/* Everything worked. Server is happy with our answers. */
form.reset();
- this.setState({
- submitted: true
- });
+ this.submitted = true;
}
render() {
- if (this.state.submitted)
+ if (this.props.players_answered.has(this.props.player.name)) {
return (
<div className="please-wait">
<h2>Submission received</h2>
</div>
);
+ }
return (
<div className="active-prompt">
return <Ambiguities
prompt={state.active_prompt}
words={state.ambiguities}
+ player={state.player_info}
players_judged={state.players_judged}
players_judging={state.players_judging}
votes={state.end_judging_votes}
if (state.active_prompt) {
return <ActivePrompt
prompt={state.active_prompt}
+ player={state.player_info}
players_answered={state.players_answered}
players_answering={state.players_answering}
votes={state.end_answers_votes}