fix: Only add the level ID when it has not been looked at before

This commit is contained in:
Alexander Polynomdivision 2018-09-14 17:19:33 +02:00
parent d8c49fde9c
commit 604da6e604

View File

@ -54,13 +54,13 @@ export default class LevelPage extends React.Component<IProps, IState> {
// Check if the vocab was already looked at // Check if the vocab was already looked at
const lookedAt = this.state.lookedAt.find((el) => el === vocab.id) || vocab.id === 0; const lookedAt = this.state.lookedAt.find((el) => el === vocab.id) || vocab.id === 0;
// TODO: Actually update the "Vocab View" when clicking
return <ListItem button key={this.genUID(vocab)} onClick={() => { return <ListItem button key={this.genUID(vocab)} onClick={() => {
// Prevent the user from using too much memory by always clicking on the elements // Prevent the user from using too much memory by always clicking on the elements
// Show the clicked at vocab word // Show the clicked at vocab word
this.setState({ this.setState({
currentVocab: vocab, currentVocab: vocab,
lookedAt: this.state.lookedAt.concat(vocab.id), lookedAt: lookedAt ? this.state.lookedAt : this.state.lookedAt.concat(vocab.id),
}); });
}}> }}>
<ListItemText> <ListItemText>