fix: Metadata only updated on correct answers
This commit is contained in:
@@ -89,8 +89,6 @@ 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);
|
||||
|
||||
@@ -41,6 +41,7 @@ interface IProps {
|
||||
loading: boolean;
|
||||
vocab: IVocab[];
|
||||
current: IReviewCard;
|
||||
metadata: IReviewMetadata;
|
||||
popoverOpen: boolean;
|
||||
popoverText: string;
|
||||
popoverColor: string;
|
||||
@@ -62,7 +63,7 @@ const ReviewPageWithRouter = withRouter(
|
||||
// Used for positioning the popover
|
||||
private buttonRef: HTMLButtonElement;
|
||||
private inputRef: HTMLInputElement;
|
||||
private metadata: IReviewMetadata = { correct: 0, wrong: 0 };
|
||||
private sm2_metadata: any = {};
|
||||
|
||||
constructor(props: any) {
|
||||
super(props);
|
||||
@@ -120,7 +121,7 @@ const ReviewPageWithRouter = withRouter(
|
||||
}
|
||||
|
||||
increaseMeta = (correct: number, wrong: number): IReviewMetadata => {
|
||||
const { metadata } = this;
|
||||
const { metadata } = this.props;
|
||||
|
||||
return {
|
||||
wrong: metadata.wrong + wrong,
|
||||
@@ -148,13 +149,15 @@ const ReviewPageWithRouter = withRouter(
|
||||
// TODO: Show it's correct?
|
||||
// Show the next vocab word
|
||||
if (this.reviewQueue.size() === 0) {
|
||||
// Go to the summary screen
|
||||
this.props.setLastReview(this.metadata);
|
||||
// Update the metadata
|
||||
this.props.setReview(this.props.current, this.increaseMeta(1, 0));
|
||||
this.props.setLastReview(this.props.metadata);
|
||||
this.props.setLoading(true);
|
||||
|
||||
// Show the drawer button again
|
||||
this.props.drawerButtonState(true);
|
||||
|
||||
// Go to the summary screen
|
||||
this.props.history.push("/review/summary");
|
||||
} else {
|
||||
// Increase the vocab
|
||||
@@ -165,15 +168,17 @@ const ReviewPageWithRouter = withRouter(
|
||||
this.props.setPopover(true, "Das war fast richtig", "yellow", "black");
|
||||
} else {
|
||||
// Find the IVocab item
|
||||
const vocab = this.vocabFromId(this.props.current.id);
|
||||
if (vocab) {
|
||||
// Re-Add the vocabulary item to the review queue
|
||||
// TODO: Only re-add when it when it's not re-queued
|
||||
// vocabToReviewCard(vocab).forEach(this.reviewQueue.enqueue);
|
||||
} else {
|
||||
console.log("[ReviewPage::checkInput] Could not find IVocab item for wrong IReviewCard");
|
||||
}
|
||||
|
||||
/* const vocab = this.vocabFromId(this.props.current.id);
|
||||
* if (vocab) {
|
||||
* // Re-Add the vocabulary item to the review queue
|
||||
* // TODO: Only re-add when it when it's not re-queued
|
||||
* // vocabToReviewCard(vocab).forEach(this.reviewQueue.enqueue);
|
||||
* } else {
|
||||
* console.log("[ReviewPage::checkInput] Could not find IVocab item for wrong IReviewCard");
|
||||
* }
|
||||
*/
|
||||
// Update the metadata
|
||||
this.props.setReview(this.props.current, this.increaseMeta(0, 1));
|
||||
this.props.setPopover(true, "Das war nicht richtig", "red", "white");
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user