feat: Only mark a level as done when the review is completed
This commit is contained in:
parent
b32603f213
commit
5b399bf0d2
@ -346,7 +346,6 @@ export default class Application extends React.Component<IProps> {
|
|||||||
return <LevelPage
|
return <LevelPage
|
||||||
id={match.params.id}
|
id={match.params.id}
|
||||||
levelVocab={this.getLevelVocab}
|
levelVocab={this.getLevelVocab}
|
||||||
updateDoneLevels={this.updateDoneLevels}
|
|
||||||
setLastReview={this.setLastReview} />;
|
setLastReview={this.setLastReview} />;
|
||||||
} else {
|
} else {
|
||||||
return <Redirect to="/login" />;
|
return <Redirect to="/login" />;
|
||||||
@ -358,6 +357,7 @@ export default class Application extends React.Component<IProps> {
|
|||||||
if (this.isAuthenticated()) {
|
if (this.isAuthenticated()) {
|
||||||
return <ReviewPage
|
return <ReviewPage
|
||||||
reviewType={ReviewType.LEVEL}
|
reviewType={ReviewType.LEVEL}
|
||||||
|
updateDoneLevels={this.updateDoneLevels}
|
||||||
levelId={match.params.id}
|
levelId={match.params.id}
|
||||||
vocabByLevel={this.getLevelVocab}
|
vocabByLevel={this.getLevelVocab}
|
||||||
setLastReview={this.setLastReview} />;
|
setLastReview={this.setLastReview} />;
|
||||||
|
@ -19,7 +19,6 @@ import { IVocab, VocabType } from "../models/vocab";
|
|||||||
interface IProps {
|
interface IProps {
|
||||||
id: string;
|
id: string;
|
||||||
levelVocab: (id: string) => Promise<IVocab[]>;
|
levelVocab: (id: string) => Promise<IVocab[]>;
|
||||||
updateDoneLevels: (id: string) => void;
|
|
||||||
|
|
||||||
history: any;
|
history: any;
|
||||||
|
|
||||||
@ -93,7 +92,6 @@ const LevelPageWithRouter = withRouter(
|
|||||||
|
|
||||||
// Only go to the review if all vocabulary item have been looked at
|
// Only go to the review if all vocabulary item have been looked at
|
||||||
if (vocab.length === lookedAt.length) {
|
if (vocab.length === lookedAt.length) {
|
||||||
this.props.updateDoneLevels(id);
|
|
||||||
this.props.setLoading(true);
|
this.props.setLoading(true);
|
||||||
this.props.history.push(`/review/level/${id}`);
|
this.props.history.push(`/review/level/${id}`);
|
||||||
}
|
}
|
||||||
|
@ -39,6 +39,7 @@ interface IProps {
|
|||||||
levelId?: number;
|
levelId?: number;
|
||||||
vocabByLevel?: (level: number) => Promise<IVocab[]>;
|
vocabByLevel?: (level: number) => Promise<IVocab[]>;
|
||||||
vocabByQueue?: () => Promise<IVocab[]>;
|
vocabByQueue?: () => Promise<IVocab[]>;
|
||||||
|
updateDoneLevels?: (id: string) => void;
|
||||||
setLastReview: (meta: IReviewMetadata, sm2: any, delta: number) => void;
|
setLastReview: (meta: IReviewMetadata, sm2: any, delta: number) => void;
|
||||||
reviewType: ReviewType;
|
reviewType: ReviewType;
|
||||||
|
|
||||||
@ -222,6 +223,16 @@ const ReviewPageWithRouter = withRouter(
|
|||||||
this.props.setLastReview(newMeta, this.sm2_metadata, this.score_delta);
|
this.props.setLastReview(newMeta, this.sm2_metadata, this.score_delta);
|
||||||
this.props.setLoading(true);
|
this.props.setLoading(true);
|
||||||
|
|
||||||
|
// If we're reviewing a level, then that level should be
|
||||||
|
// marked as complete
|
||||||
|
if (this.props.reviewType === ReviewType.LEVEL) {
|
||||||
|
// NOTE: We can ensure that both updateDoneLevels and
|
||||||
|
// levelId are attributes of this.props, since
|
||||||
|
// reviewType === ReviewType.LEVEL requires those.
|
||||||
|
//@ts-ignore
|
||||||
|
this.props.updateDoneLevels(this.props.levelId);
|
||||||
|
}
|
||||||
|
|
||||||
// Show the drawer button again
|
// Show the drawer button again
|
||||||
this.props.drawerButtonState(true);
|
this.props.drawerButtonState(true);
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user