fix: Fix the level page handling vocab IDs wrongly

This commit is contained in:
Alexander Polynomdivision 2018-09-30 13:48:20 +02:00
parent adba83f865
commit 2276dad7a7

View File

@ -50,6 +50,7 @@ const LevelPageWithRouter = withRouter(
this.props.levelVocab(this.props.id).then(vocab => {
this.props.setVocab(vocab);
this.props.setCurrentVocab(vocab[0]);
this.props.setLookedAt([vocab[0].id]);
this.props.setLoading(false);
});
@ -68,7 +69,7 @@ const LevelPageWithRouter = withRouter(
renderVocabListItem = (vocab: IVocab): any => {
// Check if the vocab was already looked at
const lookedAt = this.props.lookedAt.find((el) => el === vocab.id) || vocab.id === 0;
const lookedAt = this.props.lookedAt.find((el) => el === vocab.id);
return <ListItem button key={this.genUID(vocab)} onClick={() => {
// Prevent the user from using too much memory by always clicking on the elements
@ -87,6 +88,9 @@ const LevelPageWithRouter = withRouter(
toReview = () => {
const { vocab, lookedAt, id } = this.props;
console.log(this.props);
// Only go to the review if all vocabulary item have been looked at
if (vocab.length === lookedAt.length) {
this.props.updateDoneLevels(id);